]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdbserver: Queue no-resumed event after thread exit
authorPedro Alves <pedro@palves.net>
Fri, 22 Apr 2022 20:03:07 +0000 (21:03 +0100)
committerPedro Alves <pedro@palves.net>
Mon, 12 Dec 2022 19:04:15 +0000 (19:04 +0000)
commit190583a1b6441e3541ecae2198640e9ae9a46eba
treeaa5a5c19e9d31f42ab9faadc9ed534a7e422775f
parent658b3049fafea5a2b4fa34bc0e23fea0e6bfb28d
gdbserver: Queue no-resumed event after thread exit

Normally, if the last thread resumed thread on the target exits, the
server sends a no-resumed event to GDB.  If however, GDB enables the
GDB_THREAD_OPTION_EXIT option on a thread, and, that thread exits, the
server sends a thread exit event for that thread instead.

In all-stop RSP mode, since events can only be forwarded to GDB one at
a time, and the whole target stops whenever an event is reported, GDB
resumes the target again after getting a THREAD_EXITED event, and then
the server finally reports back a no-resumed event if/when
appropriate.

For non-stop RSP though, events are asynchronous, and if the server
sends a thread-exit event for the last resumed thread, the no-resumed
event is never sent.  This patch makes sure that in non-stop mode, the
server queues a no-resumed event after the thread-exit event if it was
the last resumed thread that exited.

Without this, we'd see failures in step-over-thread-exit testcases
added later in the series, like so:

   continue
   Continuing.
 - No unwaited-for children left.
 - (gdb) PASS: gdb.threads/step-over-thread-exit.exp: displaced-stepping=off: non-stop=on: target-non-stop=on: schedlock=off: ns_stop_all=1: continue stops when thread exits
 + FAIL: gdb.threads/step-over-thread-exit.exp: displaced-stepping=off: non-stop=on: target-non-stop=on: schedlock=off: ns_stop_all=1: continue stops when thread exits (timeout)

(and other similar ones)

Change-Id: I927d78b30f88236dbd5634b051a716f72420e7c7
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/server.cc
gdbserver/target.cc
gdbserver/target.h