From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Print thread name in thread apply headers
Date: Thu, 20 Aug 2015 19:10:00 -0000 [thread overview]
Message-ID: <20150820191033.GD2251@work-vm> (raw)
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
reply other threads:[~2015-08-20 19:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150820191033.GD2251@work-vm \
--to=dgilbert@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox