From: Mohsan Saleem <mohsansaleem_ms@yahoo.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: gdb bug 12417
Date: Tue, 18 Sep 2012 13:17:00 -0000 [thread overview]
Message-ID: <1347974206.13036.YahooMailNeo@web114403.mail.gq1.yahoo.com> (raw)
In-Reply-To: <A62F3BCAE6F6B540A2F2C0E7E4387B9505B5AA72@EU-MBX-01.mgc.mentorg.com>
[-- Attachment #1: Type: text/plain, Size: 141 bytes --]
Hi,
Attached patch is for bug 12417, for printing the name of threads while printing the information of a thread.
Thanks,
Mohsan Saleem
[-- Attachment #2: 12417.patch --]
[-- Type: application/octet-stream, Size: 3976 bytes --]
--- /root/Desktop/gdb/thread.c 2012-09-03 00:53:02.620254912 -0700
+++ ./gdb/thread.c 2012-09-03 00:58:04.399469614 -0700
@@ -243,12 +243,14 @@
struct thread_info *
add_thread_with_info (ptid_t ptid, struct private_thread_info *private)
{
+ char *name;
struct thread_info *result = add_thread_silent (ptid);
+ name = result->name ? result->name : target_thread_name (result);
result->private = private;
if (print_thread_events)
- printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
+ printf_unfiltered (_("[New %s ] %s\n"), target_pid_to_str (ptid), name);
annotate_new_thread ();
return result;
@@ -1192,7 +1194,7 @@
{
struct thread_info *tp;
struct cleanup *old_chain;
- char *saved_cmd;
+ char *saved_cmd, *name;
if (cmd == NULL || *cmd == '\000')
error (_("Please specify a command following the thread ID list"));
@@ -1209,8 +1211,9 @@
if (thread_alive (tp))
{
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, name, target_pid_to_str (inferior_ptid));
execute_command (cmd, from_tty);
strcpy (cmd, saved_cmd); /* Restore exact command used
previously. */
@@ -1222,7 +1225,7 @@
static void
thread_apply_command (char *tidlist, int from_tty)
{
- char *cmd;
+ char *cmd, *name;
struct cleanup *old_chain;
char *saved_cmd;
struct get_number_or_range_state state;
@@ -1260,8 +1263,8 @@
else
{
switch_to_thread (tp->ptid);
-
- printf_filtered (_("\nThread %d (%s):\n"), tp->num,
+ name = tp->name ? tp->name : target_thread_name (tp);
+ printf_filtered (_("\nThread %d %s (%s):\n"), tp->num, name,
target_pid_to_str (inferior_ptid));
execute_command (cmd, from_tty);
@@ -1283,7 +1286,6 @@
{
if (ptid_equal (inferior_ptid, null_ptid))
error (_("No thread selected"));
-
if (target_has_stack)
{
if (is_exited (inferior_ptid))
@@ -1327,7 +1329,7 @@
thread_find_command (char *arg, int from_tty)
{
struct thread_info *tp;
- char *tmp;
+ char *tmp, *name;
unsigned long match = 0;
if (arg == NULL || *arg == '\0')
@@ -1338,6 +1340,7 @@
error (_("Invalid regexp (%s): %s"), tmp, arg);
update_thread_list ();
+
for (tp = thread_list; tp; tp = tp->next)
{
if (tp->name != NULL && re_exec (tp->name))
@@ -1354,20 +1357,20 @@
tp->num, tmp);
match++;
}
-
+ name = tp->name ? tp->name : target_thread_name (tp);
tmp = target_pid_to_str (tp->ptid);
if (tmp != NULL && re_exec (tmp))
{
- printf_filtered (_("Thread %d has target id '%s'\n"),
- tp->num, tmp);
+ printf_filtered (_("Thread %d %s has target id '%s'\n"),
+ tp->num, name, tmp);
match++;
}
tmp = target_extra_thread_info (tp);
if (tmp != NULL && re_exec (tmp))
{
- printf_filtered (_("Thread %d has extra info '%s'\n"),
- tp->num, tmp);
+ printf_filtered (_("Thread %d %s has extra info '%s'\n"),
+ tp->num, name, tmp);
match++;
}
}
@@ -1391,6 +1394,7 @@
{
int num;
struct thread_info *tp;
+ char *name;
num = value_as_long (parse_and_eval (tidstr));
@@ -1405,9 +1409,12 @@
switch_to_thread (tp->ptid);
annotate_thread_changed ();
+ name = tp->name ? tp->name : target_thread_name (tp);
ui_out_text (uiout, "[Switching to thread ");
- ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
+ ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
+ ui_out_text (uiout, " ");
+ ui_out_text (uiout, name);
ui_out_text (uiout, " (");
ui_out_text (uiout, target_pid_to_str (inferior_ptid));
ui_out_text (uiout, ")]");
next parent reply other threads:[~2012-09-18 13:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <A62F3BCAE6F6B540A2F2C0E7E4387B9505B5AA72@EU-MBX-01.mgc.mentorg.com>
2012-09-18 13:17 ` Mohsan Saleem [this message]
2012-09-19 11:00 ` [PATCH] " Mohsan Saleem
2012-09-19 13:09 ` Jan Kratochvil
2012-09-19 13:22 ` Yao Qi
2012-09-19 13:44 ` Keith Seitz
2012-09-19 16:07 ` Mohsan Saleem
2012-09-19 16:16 ` Sergio Durigan Junior
2012-09-22 13:15 ` Jan Kratochvil
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=1347974206.13036.YahooMailNeo@web114403.mail.gq1.yahoo.com \
--to=mohsansaleem_ms@yahoo.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