Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mohsan Saleem <mohsansaleem_ms@yahoo.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] gdb bug 12417
Date: Mon, 24 Sep 2012 17:37:00 -0000	[thread overview]
Message-ID: <1348508232.46785.YahooMailNeo@web114411.mail.gq1.yahoo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

Hi,
     Attached patch is for bug 12417, for printing the name of threads while printing the information of a thread. 

Thanks,
Mohsan Saleem

 
--
Mohsan Saleem

[-- Attachment #2: diff.patch --]
[-- Type: application/octet-stream, Size: 5400 bytes --]

diff -ruN ./gdb_old/ChangeLog ./gdb_new/ChangeLog
--- ./gdb_old/ChangeLog	2012-09-24 13:17:34.000000000 +0500
+++ ./gdb_new/ChangeLog	2012-09-24 22:25:44.465441936 +0500
@@ -1,3 +1,12 @@
+2012-09-24  Mohsan Saleem  <mohsansaleem_ms@yahoo.com>
+
+	* thread.c (thread_name): New function. To get thread name
+	(add_thread_with_info): Update to print thread name.
+	(thread_apply_all_command): Likewise.
+	(thread_apply_command): Likewise.
+	(thread_find_command): Likewise.
+	(do_captured_thread_select): Likewise.
+
 2012-09-21  Steve Ellcey  <sellcey@mips.com>
 
 	* configure.ac: Add mips*-mti-elf* target.
diff -ruN ./gdb_old/gdb/testsuite/gdb.threads/thread-find.exp ./gdb_new/gdb/testsuite/gdb.threads/thread-find.exp
--- ./gdb_old/gdb/testsuite/gdb.threads/thread-find.exp	2012-09-24 13:17:38.000000000 +0500
+++ ./gdb_new/gdb/testsuite/gdb.threads/thread-find.exp	2012-09-24 21:55:44.737537299 +0500
@@ -186,17 +186,17 @@
 
 if { [info exists thread6] } then {
     gdb_test "thread find $thread6" \
-	"Thread 6 has .*$thread6.*" "find thread id 6"
+	"Thread 6 threadname_6 has .*$thread6.*" "find thread id 6"
     gdb_test "thread find $thread5" \
-	"Thread 5 has .*$thread5.*" "find thread id 5"
+	"Thread 5 threadname_5 has .*$thread5.*" "find thread id 5"
     gdb_test "thread find $thread4" \
-	"Thread 4 has .*$thread4.*" "find thread id 4"
+	"Thread 4 threadname_4 has .*$thread4.*" "find thread id 4"
     gdb_test "thread find $thread3" \
-	"Thread 3 has .*$thread3.*" "find thread id 3"
+	"Thread 3 threadname_3 has .*$thread3.*" "find thread id 3"
     gdb_test "thread find $thread2" \
-	"Thread 2 has .*$thread2.*" "find thread id 2"
+	"Thread 2 threadname_2 has .*$thread2.*" "find thread id 2"
     gdb_test "thread find $thread1" \
-	"Thread 1 has .*$thread1.*" "find thread id 1"
+	"Thread 1 threadname_1 has .*$thread1.*" "find thread id 1"
 }
 
 #
@@ -224,17 +224,17 @@
 
 if { [info exists lwp6] } then {
     gdb_test "thread find $lwp6" \
-	"Thread 6 has .*$lwp6.*" "find lwp id 6"
+	"Thread 6 threadname_6 has .*$lwp6.*" "find lwp id 6"
     gdb_test "thread find $lwp5" \
-	"Thread 5 has .*$lwp5.*" "find lwp id 5"
+	"Thread 5 threadname_5 has .*$lwp5.*" "find lwp id 5"
     gdb_test "thread find $lwp4" \
-	"Thread 4 has .*$lwp4.*" "find lwp id 4"
+	"Thread 4 threadname_4 has .*$lwp4.*" "find lwp id 4"
     gdb_test "thread find $lwp3" \
-	"Thread 3 has .*$lwp3.*" "find lwp id 3"
+	"Thread 3 threadname_3 has .*$lwp3.*" "find lwp id 3"
     gdb_test "thread find $lwp2" \
-	"Thread 2 has .*$lwp2.*" "find lwp id 2"
+	"Thread 2 threadname_2 has .*$lwp2.*" "find lwp id 2"
     gdb_test "thread find $lwp1" \
-	"Thread 1 has .*$lwp1.*" "find lwp id 1"
+	"Thread 1 threadname_1 has .*$lwp1.*" "find lwp id 1"
 }
 
 # Test no match.
diff -ruN ./gdb_old/gdb/thread.c ./gdb_new/gdb/thread.c
--- ./gdb_old/gdb/thread.c	2012-09-24 13:17:37.000000000 +0500
+++ ./gdb_new/gdb/thread.c	2012-09-24 21:54:46.689540365 +0500
@@ -64,6 +64,7 @@
 static void thread_apply_command (char *, int);
 static void restore_current_thread (ptid_t);
 static void prune_threads (void);
+static const char* thread_name (struct thread_info *);
 
 struct thread_info*
 inferior_thread (void)
@@ -73,6 +74,17 @@
   return tp;
 }
 
+const char*
+thread_name (struct thread_info *ti)
+{
+  const char* name;
+  name = ti->name ? ti->name : target_thread_name(ti);
+  if (name)
+    return name;
+  else
+    return "";
+}
+
 void
 delete_step_resume_breakpoint (struct thread_info *tp)
 {
@@ -236,7 +248,7 @@
   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), thread_name (result));
 
   annotate_new_thread ();
   return result;
@@ -1198,8 +1210,8 @@
       {
 	switch_to_thread (tp->ptid);
 
-	printf_filtered (_("\nThread %d (%s):\n"),
-			 tp->num, target_pid_to_str (inferior_ptid));
+	printf_filtered (_("\nThread %d %s (%s):\n"), tp->num,
+			 thread_name (tp), target_pid_to_str (inferior_ptid));
 	execute_command (cmd, from_tty);
 	strcpy (cmd, saved_cmd);	/* Restore exact command used
 					   previously.  */
@@ -1250,7 +1262,7 @@
 	{
 	  switch_to_thread (tp->ptid);
 
-	  printf_filtered (_("\nThread %d (%s):\n"), tp->num,
+	  printf_filtered (_("\nThread %d %s (%s):\n"), tp->num, thread_name (tp),
 			   target_pid_to_str (inferior_ptid));
 	  execute_command (cmd, from_tty);
 
@@ -1347,16 +1359,16 @@
       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, thread_name (tp), 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, thread_name (tp), tmp);
 	  match++;
 	}
     }
@@ -1397,6 +1409,8 @@
 
   ui_out_text (uiout, "[Switching to thread ");
   ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
+  ui_out_text (uiout, " ");
+  ui_out_text (uiout, thread_name (tp));
   ui_out_text (uiout, " (");
   ui_out_text (uiout, target_pid_to_str (inferior_ptid));
   ui_out_text (uiout, ")]");

             reply	other threads:[~2012-09-24 17:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24 17:37 Mohsan Saleem [this message]
2012-09-24 22:19 ` Sergio Durigan Junior
     [not found] <A62F3BCAE6F6B540A2F2C0E7E4387B9505B5AA72@EU-MBX-01.mgc.mentorg.com>
2012-09-18 13:17 ` Mohsan Saleem
2012-09-19 11:00   ` [PATCH] " Mohsan Saleem
2012-09-19 13:09     ` Jan Kratochvil
2012-09-19 13:22     ` Yao Qi

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=1348508232.46785.YahooMailNeo@web114411.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