diff --git a/gdb/record-full.c b/gdb/record-full.c index a681ef9fe51..074d0cd63fc 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -370,6 +370,15 @@ record_full_is_used (void) || t == &record_full_core_ops); } +/* see record-full.h. */ +bool +record_full_is_replaying () +{ + auto target = dynamic_cast + (current_inferior ()->target_at (record_stratum)); + return target != nullptr && RECORD_FULL_IS_REPLAY; +} + /* Command lists for "set/show record full". */ static struct cmd_list_element *set_record_full_cmdlist; diff --git a/gdb/record-full.h b/gdb/record-full.h index e8eb041311b..07f97d241a2 100644 --- a/gdb/record-full.h +++ b/gdb/record-full.h @@ -31,6 +31,9 @@ extern int record_full_arch_list_add_end (void); /* Returns true if the process record target is open. */ extern int record_full_is_used (void); +/* Whether the inferior is being replayed, or is executing normally. */ +extern bool record_full_is_replaying (); + extern scoped_restore_tmpl record_full_gdb_operation_disable_set (); #endif /* RECORD_FULL_H */ diff --git a/gdb/thread.c b/gdb/thread.c index 4ee46936861..5892b158603 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -50,6 +50,7 @@ #include "inline-frame.h" #include "stack.h" #include "interps.h" +#include "record-full.h" /* See gdbthread.h. */ @@ -998,7 +999,13 @@ validate_registers_access (void) reason, but is marked running from the user's perspective. E.g., the thread is waiting for its turn in the step-over queue. */ if (tp->executing ()) - error (_("Selected thread is running.")); + { + /* If we are replaying with the record-full subsystem, even though + the thread is executing, it is always safe to read from it since + replay execution is just GDB reading and writing to a regcache. */ + if (!record_full_is_replaying ()) + error (_("Selected thread is running.")); + } } /* See gdbthread.h. */ @@ -1016,7 +1023,11 @@ can_access_registers_thread (thread_info *thread) /* ... or from a spinning thread. FIXME: see validate_registers_access. */ if (thread->executing ()) - return false; + { + /* See validate_registers_access. */ + if (!record_full_is_replaying ()) + return false; + } return true; }