This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Print thread name in thread apply headers
- From: "Dr. David Alan Gilbert" <dgilbert at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 20 Aug 2015 20:10:34 +0100
- Subject: [PATCH] Print thread name in thread apply headers
- Authentication-results: sourceware.org; auth=none
The thread name is currently shown in 'info thread' but not in
thread apply. Adding it to thread apply makes it easier to figure out
what's happening in backtraces of multithreaded programs gathered with
a 'thread apply all bt full'.
gdb/ChangeLog:
* thread.c: Add thread name to thread apply headers.
---
gdb/thread.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/gdb/thread.c b/gdb/thread.c
index 4dde722..257e082 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1640,10 +1640,17 @@ thread_apply_all_command (char *cmd, int from_tty)
for (k = 0; k != i; k++)
if (thread_alive (tp_array[k]))
{
- switch_to_thread (tp_array[k]->ptid);
- printf_filtered (_("\nThread %d (%s):\n"),
- tp_array[k]->num,
- target_pid_to_str (inferior_ptid));
+ const char *name;
+
+ tp = tp_array[k];
+ switch_to_thread (tp->ptid);
+
+ name = tp->name ? tp->name : target_thread_name (tp);
+
+ printf_filtered (_("\nThread %d (%s/'%s'):\n"),
+ tp->num,
+ target_pid_to_str (inferior_ptid),
+ name ? name : "");
execute_command (cmd, from_tty);
/* Restore exact command used previously. */
@@ -1693,10 +1700,15 @@ thread_apply_command (char *tidlist, int from_tty)
warning (_("Thread %d has terminated."), start);
else
{
+ const char *name;
+
switch_to_thread (tp->ptid);
- printf_filtered (_("\nThread %d (%s):\n"), tp->num,
- target_pid_to_str (inferior_ptid));
+ name = tp->name ? tp->name : target_thread_name (tp);
+
+ printf_filtered (_("\nThread %d (%s/'%s'):\n"), tp->num,
+ target_pid_to_str (inferior_ptid),
+ name ? name : "");
execute_command (cmd, from_tty);
/* Restore exact command used previously. */
--
2.4.3
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK