diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2024-02-21 11:47:03 +0000 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2024-09-13 10:25:28 +0000 |
commit | 2586986632367d5c469224bd85e4ff6c1bd1a334 (patch) | |
tree | 10418729729b4f9e01ad216d370b4a8b15b5f1de /config/codeset.m4 | |
parent | 3f75b095204e480e5b0fd10806a5da60e1595c20 (diff) | |
download | gdb-2586986632367d5c469224bd85e4ff6c1bd1a334.zip gdb-2586986632367d5c469224bd85e4ff6c1bd1a334.tar.gz gdb-2586986632367d5c469224bd85e4ff6c1bd1a334.tar.bz2 |
gdb, infrun: fix silent inferior switch in do_target_wait()
In do_target_wait(), we iterate over inferiors and call
do_target_wait_1(), which eventually calls target_wait() per inferior.
Each time, we wait for minus_one_ptid.
In some cases, e.g. gdb.threads/detach-step-over.exp, we ask to wait for
one inferior, and get an event from a different inferior back without
noticing the inferior switch.
Wait for a single inferior, instead. Since we iterate over all inferiors,
we still cover everything.
This exposes another bug with STOP_QUIETLY_NO_SIGSTOP handling.
After attaching, we interrupt all threads in the new inferior, then call
do_target_wait() to receive the stopped events. This randomly selects an
inferior to start waiting for and iterates over all inferiors starting
from there.
The initial stop event for the main thread is already queued up, so we
wouldn't actually wait() if we had started with the new inferior. Or if
we had waited for minus_one_ptid, which would then have silently switched
inferiors.
Since we no longer allow that, we may actually wait() for the new inferior
and find other events to report, out of which we randomly select one.
If we selected an event for another thread, e.g. one that had been
interrupted as part of non-stop attach, STOP_QUIETLY_NO_SIGSTOP would be
applied to that thread (unnecessarily), leaving the main thread with a
SIGSTOP event but last_resume_kind = 0 (resume_continue).
When the main thread is later selected, SIGSTOP is reported to the user.
Normally, linux-nat's wait() turns the SIGSTOP it uses for interrupting
threads into GDB_SIGNAL_0. This is based on last_resume_kind, which is
set to 2 (resume_stop) when sending SIGSTOP to interrupt a thread.
We do this for all threads of the new inferior when interrupting them as
part of non-stop attach. Except for the main thread, which we expect to
be reported before the first wait().
Set last_resume_kind to resume_stop for the main thread after attaching.
Diffstat (limited to 'config/codeset.m4')
0 files changed, 0 insertions, 0 deletions