public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Ensure selected thread after thread exit stop
@ 2023-12-20 21:21 Pedro Alves
0 siblings, 0 replies; only message in thread
From: Pedro Alves @ 2023-12-20 21:21 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d0b591497952db37ed7a5545ced7aad64433f79a
commit d0b591497952db37ed7a5545ced7aad64433f79a
Author: Pedro Alves <pedro@palves.net>
Date: Mon Nov 20 17:49:08 2023 +0000
Ensure selected thread after thread exit stop
While making step over thread exit work properly on AMDGPU, I noticed
that if there's a breakpoint on top of the exit syscall, and,
displaced stepping is off, then when GDB reports "Command aborted,
thread exited.", GDB also switches focus to a random thread, instead
of leaving the exited thread as selected:
(gdb) thread
[Current thread is 6, lane 0 (AMDGPU Lane 1:4:1:1/0 (0,0,0)[0,0,0])]
(gdb) si
Command aborted, thread exited.
(gdb) thread
[Current thread is 5 (Thread 0x7ffff626f640 (LWP 3248392))]
(gdb)
The previous patch extended gdb.threads/step-over-thread-exit.exp to
exercise this on GNU/Linux (on the CPU side), and there, after that
"si", we always end up with the exiting thread as selected even
without this fix, but that's just a concidence, there's a code path
that happens to select the exiting thread for an unrelated reason.
This commit add the explict switch, fixing the latent problem for
GNU/Linux, and the actual problem on AMDGPU. I wrote a gdb.rocm/
testcase for this, but it can't be upstreamed yet, until more pieces
of the DWARF machinery are upstream as well.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I6ff57a79514ac0142bba35c749fe83d53d9e4e51
Diff:
---
gdb/infrun.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 45c1b4a79bb..6dc0a2bb9a5 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5895,7 +5895,14 @@ handle_thread_exited (execution_control_state *ecs)
if (abort_cmd)
{
+ /* We're stopping for the thread exit event. Switch to the
+ event thread again, as finish_step_over may have switched
+ threads. */
+ switch_to_thread (ecs->event_thread);
+
+ /* Emit [Thread ... exited] notification. */
delete_thread (ecs->event_thread);
+
ecs->event_thread = nullptr;
return false;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-20 21:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-20 21:21 [binutils-gdb] Ensure selected thread after thread exit stop Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).