diff options
author | Pedro Alves <pedro@palves.net> | 2022-06-27 20:41:50 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2022-06-28 18:11:29 +0100 |
commit | a9deee17d33235eeba401eebed55c85a742e3358 (patch) | |
tree | 3dbd67fe9ee0566ceab74a4692c7abf42ce7fc60 /gdb/inferior.h | |
parent | 9117c7b452ef76304f4394a97c887d0c4af439f5 (diff) | |
download | fsf-binutils-gdb-a9deee17d33235eeba401eebed55c85a742e3358.zip fsf-binutils-gdb-a9deee17d33235eeba401eebed55c85a742e3358.tar.gz fsf-binutils-gdb-a9deee17d33235eeba401eebed55c85a742e3358.tar.bz2 |
gdb+gdbserver/Linux: avoid reading registers while going through shell
For every stop, Linux GDB and GDBserver save the stopped thread's PC,
in lwp->stop_pc. This is done in save_stop_reason, in both
gdb/linux-nat.c and gdbserver/linux-low.cc. However, while we're
going through the shell after "run", in startup_inferior, we shouldn't
be reading registers, as we haven't yet determined the target's
architecture -- the shell's architecture may not even be the same as
the final inferior's.
In gdb/linux-nat.c, lwp->stop_pc is only needed when the thread has
stopped for a breakpoint, and since when going through the shell, no
breakpoint is going to hit, we could simply teach save_stop_reason to
only record the stop pc when the thread stopped for a breakpoint.
However, in gdbserver/linux-low.cc, lwp->stop_pc is used in more cases
than breakpoint hits (e.g., it's used in tracepoints & the
"while-stepping" feature).
So to avoid GDB vs GDBserver divergence, we apply the same approach to
both implementations.
We set a flag in the inferior (process in GDBserver) whenever it is
being nursed through the shell, and when that flag is set,
save_stop_reason bails out early. While going through the shell,
we'll only ever get process exits (normal or signalled), random
signals, and exec events, so nothing is lost.
Change-Id: If0f01831514d3a74d17efd102875de7d2c6401ad
Diffstat (limited to 'gdb/inferior.h')
-rw-r--r-- | gdb/inferior.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/inferior.h b/gdb/inferior.h index f6e26a3..c376d78 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -551,6 +551,13 @@ public: architecture/description. */ bool needs_setup = false; + /* True if the inferior is starting up (inside startup_inferior), + and we're nursing it along (through the shell) until it is ready + to execute its first instruction. Until that is done, we must + not access inferior memory or registers, as we haven't determined + the target architecture/description. */ + bool starting_up = false; + /* True when we are reading the library list of the inferior during an attach or handling a fork child. */ bool in_initial_library_scan = false; |