From patchwork Thu Aug 20 19:10:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 8328 Received: (qmail 86596 invoked by alias); 20 Aug 2015 19:10:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 86583 invoked by uid 89); 20 Aug 2015 19:10:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS, T_HK_NAME_DR autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 20 Aug 2015 19:10:38 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8F62691588 for ; Thu, 20 Aug 2015 19:10:37 +0000 (UTC) Received: from work-vm (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7KJAYNh031545 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 20 Aug 2015 15:10:37 -0400 Date: Thu, 20 Aug 2015 20:10:34 +0100 From: "Dr. David Alan Gilbert" To: gdb-patches@sourceware.org Subject: [PATCH] Print thread name in thread apply headers Message-ID: <20150820191033.GD2251@work-vm> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes 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. */