[1/6] gdb/remote: announce thread exit events for remote targets

Message ID 0215c520c680334efac7f0544d834ec1fb7aff8e.1669634536.git.aburgess@redhat.com
State New
Headers
Series Inferior specific breakpoints |

Commit Message

Andrew Burgess Nov. 28, 2022, 11:25 a.m. UTC
  For some reason the "[Thread XXXX exited]" messages are not printed
inside thread.c from functions like delete_thread, etc as might be
expected.  Instead, each target seems to print the message before
calling delete_thread.

This doesn't seem ideal, and I can't help but feel that the printing
should be moved into thread.c, however, I have not tried to do that in
this commit, as I suspect there will be lots of fallout that needs
fixing up.

Instead, in this commit, I have added the printing code into remote.c,
so that the remote target will now correctly tell the user when a
thread has exited.

This fixes some test failures in gdb.threads/thread-specific-bp.exp
when run with the native-gdbserver and native-extended-gdbserver
board.

When using the native-extended-gdbserver board I still see 1 test
failure, but I think this is not related to the issue fixed in this
commit, so I'm ignoring that for now.
---
 gdb/remote.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index 5118ecd0a31..1737caa579c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3978,6 +3978,10 @@  remote_target::update_thread_list ()
 	      if (has_single_non_exited_thread (tp->inf))
 		continue;
 
+	      if (print_thread_events)
+		gdb_printf (_("[%s exited]\n"),
+			    target_pid_to_str (tp->ptid).c_str ());
+
 	      /* Not found.  */
 	      delete_thread (tp);
 	    }