aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbthread.h
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-12-12 20:31:00 +0000
committerAndrew Burgess <aburgess@redhat.com>2023-08-23 09:57:38 +0100
commit9d7d58e7262eff313be6a1e66b8b026e3e7fed0d (patch)
tree4f400354dec983e1778afb7682505c70cd1727c7 /gdb/gdbthread.h
parent9324bfeab9b819042ddbab4ce8918ee533db651a (diff)
downloadgdb-9d7d58e7262eff313be6a1e66b8b026e3e7fed0d.zip
gdb-9d7d58e7262eff313be6a1e66b8b026e3e7fed0d.tar.gz
gdb-9d7d58e7262eff313be6a1e66b8b026e3e7fed0d.tar.bz2
gdb: centralize "[Thread ...exited]" notifications
Currently, each target backend is responsible for printing "[Thread ...exited]" before deleting a thread. This leads to unnecessary differences between targets, like e.g. with the remote target, we never print such messages, even though we do print "[New Thread ...]". E.g., debugging the gdb.threads/attach-many-short-lived-threads.exp with gdbserver, letting it run for a bit, and then pressing Ctrl-C, we currently see: (gdb) c Continuing. ^C[New Thread 3850398.3887449] [New Thread 3850398.3887500] [New Thread 3850398.3887551] [New Thread 3850398.3887602] [New Thread 3850398.3887653] ... Thread 1 "attach-many-sho" received signal SIGINT, Interrupt. 0x00007ffff7e6a23f in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7fffffffda80, rem=rem@entry=0x7fffffffda80) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 78 in ../sysdeps/unix/sysv/linux/clock_nanosleep.c (gdb) Above, we only see "New Thread" notifications, even though threads were deleted. After this patch, we'll see: (gdb) c Continuing. ^C[Thread 3558643.3577053 exited] [Thread 3558643.3577104 exited] [Thread 3558643.3577155 exited] [Thread 3558643.3579603 exited] ... [New Thread 3558643.3597415] [New Thread 3558643.3600015] [New Thread 3558643.3599965] ... Thread 1 "attach-many-sho" received signal SIGINT, Interrupt. 0x00007ffff7e6a23f in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7fffffffda80, rem=rem@entry=0x7fffffffda80) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 78 in ../sysdeps/unix/sysv/linux/clock_nanosleep.c (gdb) q This commit fixes this by moving the thread exit printing to common code instead, triggered from within delete_thread (or rather, set_thread_exited). There's one wrinkle, though. While most targest want to print: [Thread ... exited] the Windows target wants to print: [Thread ... exited with code <exit_code>] ... and sometimes wants to suppress the notification for the main thread. To address that, this commits adds a delete_thread_with_code function, only used by that target (so far). This fix was originally posted as part of a larger series: https://inbox.sourceware.org/gdb-patches/20221212203101.1034916-1-pedro@palves.net/ But didn't really need to be part of that series. In order to get this fix merged sooner, I (Andrew Burgess) have rebased this commit outside of the original series. Any bugs introduced while splitting this patch out and rebasing, are entirely my own. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30129 Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/gdbthread.h')
-rw-r--r--gdb/gdbthread.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index baff68a..48f32bb 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -623,16 +623,30 @@ extern struct thread_info *add_thread_with_info (process_stratum_target *targ,
/* Delete thread THREAD and notify of thread exit. If the thread is
currently not deletable, don't actually delete it but still tag it
- as exited and do the notification. */
-extern void delete_thread (struct thread_info *thread);
+ as exited and do the notification. EXIT_CODE is the thread's exit
+ code. If SILENT, don't actually notify the CLI. THREAD must not
+ be NULL or an assertion will fail. */
+extern void delete_thread_with_exit_code (thread_info *thread,
+ ULONGEST exit_code,
+ bool silent = false);
+
+/* Delete thread THREAD and notify of thread exit. If the thread is
+ currently not deletable, don't actually delete it but still tag it
+ as exited and do the notification. THREAD must not be NULL or an
+ assertion will fail. */
+extern void delete_thread (thread_info *thread);
/* Like delete_thread, but be quiet about it. Used when the process
this thread belonged to has already exited, for example. */
extern void delete_thread_silent (struct thread_info *thread);
/* Mark the thread exited, but don't delete it or remove it from the
- inferior thread list. */
-extern void set_thread_exited (thread_info *tp, bool silent);
+ inferior thread list. EXIT_CODE is the thread's exit code, if
+ available. If SILENT, then don't inform the CLI about the
+ exit. */
+extern void set_thread_exited (thread_info *tp,
+ gdb::optional<ULONGEST> exit_code = {},
+ bool silent = false);
/* Delete a step_resume_breakpoint from the thread database. */
extern void delete_step_resume_breakpoint (struct thread_info *);