Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Print thread name in thread apply headers
@ 2015-08-20 19:10 Dr. David Alan Gilbert
  0 siblings, 0 replies; only message in thread
From: Dr. David Alan Gilbert @ 2015-08-20 19:10 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-20 19:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 19:10 [PATCH] Print thread name in thread apply headers Dr. David Alan Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox