diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-04-03 14:52:07 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-04-17 13:47:13 -0400 |
commit | 9145fd43029d2ed2a352ccf93f76b6f5b6dbb94d (patch) | |
tree | 9760b5f44daaa0c8b06dd98fdb50fe850f24483b /gdb/testsuite/gdb.cp | |
parent | 98994c7a18347c7248d2cf01d1dad6772907b813 (diff) | |
download | gdb-9145fd43029d2ed2a352ccf93f76b6f5b6dbb94d.zip gdb-9145fd43029d2ed2a352ccf93f76b6f5b6dbb94d.tar.gz gdb-9145fd43029d2ed2a352ccf93f76b6f5b6dbb94d.tar.bz2 |
gdb: switch to right inferior in fetch_inferior_event
The problem explained and fixed in the previous patch could have also
been fixed by this patch. But I think it's good change anyhow, that
could prevent future bugs, so here it is.
fetch_inferior_event switches to an arbitrary (in practice, the first) inferior
of the process target of the inferior used to fetch the event. The idea is
that the event handling code will need to do some target calls, so we want to
switch to an inferior that has target target.
However, you can have two inferiors that share a process target, but with one
inferior having an additional target on top:
inf 1 inf 2
----- -----
another target
process target process target
exec exec
Let's say inferior 2 is selected by do_target_wait and returns an event that is
really synthetized by "another target". This "another target" could be a
thread or record stratum target (in the case explained by the previous patch,
it was the arch stratum target, but it's because the amd-dbgapi abuses the arch
layer). fetch_inferior_event will then switch to the first inferior with
"process target", so inferior 1. handle_signal_stop then tries to fetch the
thread's registers:
ecs->event_thread->set_stop_pc
(regcache_read_pc (get_thread_regcache (ecs->event_thread)));
This will try to get the thread's register by calling into the current target
stack, the stack of inferior 1. This is problematic because "another target"
might have a special fetch_registers implementation.
I think it would be a good idea to switch to the inferior for which the
even was reported, not just some inferior of the same process target.
This will ensure that any target call done before we eventually call
context_switch will be done on the full target stack that reported the
event.
Not all events are associated to an inferior though. For instance,
TARGET_WAITKIND_NO_RESUMED. In those cases, some targets return
null_ptid, some return minus_one_ptid (ideally the expected return value
should be clearly defined / documented). So, if the ptid returned is
either of these, switch to an arbitrary inferior with that process
target, as before.
Change-Id: I1ffc8c1095125ab591d0dc79ea40025b1d7454af
Reviewed-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/testsuite/gdb.cp')
0 files changed, 0 insertions, 0 deletions