From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21263 invoked by alias); 4 Sep 2013 08:19:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21250 invoked by uid 89); 4 Sep 2013 08:19:46 -0000 Received: from nm7.bullet.mail.bf1.yahoo.com (HELO nm7.bullet.mail.bf1.yahoo.com) (98.139.212.166) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 04 Sep 2013 08:19:46 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RDNS_NONE autolearn=no version=3.3.2 X-HELO: nm7.bullet.mail.bf1.yahoo.com Received: from [98.139.214.32] by nm7.bullet.mail.bf1.yahoo.com with NNFMP; 04 Sep 2013 08:19:42 -0000 Received: from [98.139.212.237] by tm15.bullet.mail.bf1.yahoo.com with NNFMP; 04 Sep 2013 08:19:42 -0000 Received: from [127.0.0.1] by omp1046.mail.bf1.yahoo.com with NNFMP; 04 Sep 2013 08:19:42 -0000 Received: (qmail 97069 invoked by uid 60001); 4 Sep 2013 08:19:42 -0000 Received: from [110.93.212.98] by web142604.mail.bf1.yahoo.com via HTTP; Wed, 04 Sep 2013 01:19:41 PDT References: <521E2414.40602@codesourcery.com> <52254BC6.1050105@codesourcery.com> Message-ID: <1378282781.96893.YahooMailNeo@web142604.mail.bf1.yahoo.com> Date: Wed, 04 Sep 2013 08:19:00 -0000 From: Mohsan Saleem Reply-To: Mohsan Saleem Subject: Re: [PATCH] fix PR-12417 To: "gdb-patches@sourceware.org" In-Reply-To: <52254BC6.1050105@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00124.txt.bz2 Ping -- Mohsan Saleem ________________________________ From: Mohsan Saleem To: gdb-patches@sourceware.org=20 Sent: Tuesday, 3 September 2013 7:39 AM Subject: [PATCH] fix PR-12417 Hi! Here is the patch for PR-12417 to print the thread names. gdb\Changlog 2013-09-03=A0 Mohsan Saleem=A0 =A0=A0=A0 PR threads/12417 =A0=A0=A0 * thread.c (thread_name): New function. =A0=A0=A0 (add_thread_with_info): Update to print thread name. =A0=A0=A0 (thread_apply_all_command): Likewise. =A0=A0=A0 (thread_apply_command): Likewise. =A0=A0=A0 (thread_find_command): Likewise. =A0=A0=A0 (do_captured_thread_select): Likewise. Index: ./gdb/thread.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.155 diff -u -p -r1.155 thread.c --- ./gdb/thread.c=A0=A0=A0 15 Jul 2013 11:14:32 -0000=A0=A0=A0 1.155 +++ ./gdb/thread.c=A0=A0=A0 3 Sep 2013 02:36:11 -0000 @@ -64,6 +64,7 @@ static void info_threads_command (char * =A0 static void thread_apply_command (char *, int); =A0 static void restore_current_thread (ptid_t); =A0 static void prune_threads (void); +static const char *thread_name (struct thread_info *); =A0 /* Data to cleanup thread array.=A0 */ @@ -78,6 +79,14 @@ struct thread_array_cleanup =A0 }; +const char * +thread_name (struct thread_info *ti) +{ +=A0 const char *name; +=A0 name =3D ti->name !=3D NULL ? ti->name : target_thread_name (ti); +=A0 return name !=3D NULL ? name : ""; +} + =A0 struct thread_info* =A0 inferior_thread (void) =A0 { @@ -251,7 +260,7 @@ add_thread_with_info (ptid_t ptid, struc =A0 =A0 result->private =3D private; =A0 =A0 if (print_thread_events) -=A0 =A0 printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid)); +=A0 =A0 printf_unfiltered (_("[New %s \"%s\"\n"), target_pid_to_str (ptid)= , thread_name (result)); =A0 =A0 annotate_new_thread (); =A0 =A0 return result; @@ -1256,9 +1265,10 @@ thread_apply_all_command (char *cmd, int =A0 =A0 =A0 =A0 =A0 if (thread_alive (tp_array[k])) =A0 =A0 =A0 =A0 =A0 =A0 { =A0 =A0 =A0 =A0 =A0 =A0 =A0 switch_to_thread (tp_array[k]->ptid); -=A0 =A0 =A0 =A0 =A0 =A0 printf_filtered (_("\nThread %d (%s):\n"), -=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0=A0=A0tp_array[k]->num, -=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0=A0=A0target_pid_to_str (inferior_pti= d)); +=A0 =A0 =A0 =A0 =A0 =A0 printf_filtered (_("\nThread %d \"%s\" (%s):\n"), +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A0tp_array[k]->= num, +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A0thread_name (= tp_array[k]), +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A0target_pid_to= _str (inferior_ptid)); =A0 =A0 =A0 =A0 =A0 =A0 =A0 execute_command (cmd, from_tty); =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Restore exact command used previously.=A0 */ @@ -1310,7 +1320,7 @@ thread_apply_command (char *tidlist, int =A0 =A0=A0=A0 { =A0 =A0=A0=A0 =A0 switch_to_thread (tp->ptid); -=A0=A0=A0 =A0 printf_filtered (_("\nThread %d (%s):\n"), tp->num, +=A0=A0=A0 =A0 printf_filtered (_("\nThread %d \"%s\" (%s):\n"), tp->num, t= hread_name (tp), =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0target_pid_to_str (inferior_ptid= )); =A0 =A0=A0=A0 =A0 execute_command (cmd, from_tty); @@ -1406,16 +1416,16 @@ thread_find_command (char *arg, int from =A0 =A0 =A0 =A0 tmp =3D target_pid_to_str (tp->ptid); =A0 =A0 =A0 =A0 if (tmp !=3D NULL && re_exec (tmp)) =A0 =A0=A0=A0 { -=A0=A0=A0 =A0 printf_filtered (_("Thread %d has target id '%s'\n"), -=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0tp->num, tmp); +=A0 =A0 =A0 =A0 =A0 printf_filtered (_("Thread %d \"%s\" has target id '%s= '\n"), +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0tp->num, thread_name (tp), tmp); =A0 =A0=A0=A0 =A0 match++; =A0 =A0=A0=A0 } =A0 =A0 =A0 =A0 tmp =3D target_extra_thread_info (tp); =A0 =A0 =A0 =A0 if (tmp !=3D NULL && re_exec (tmp)) =A0 =A0=A0=A0 { -=A0=A0=A0 =A0 printf_filtered (_("Thread %d has extra info '%s'\n"), -=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0tp->num, tmp); +=A0=A0=A0 =A0 printf_filtered (_("Thread %d \"%s\" has extra info '%s'\n"), +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0tp->num, thread_name (tp), tmp); =A0 =A0=A0=A0 =A0 match++; =A0 =A0=A0=A0 } =A0 =A0 =A0 } @@ -1456,7 +1466,9 @@ do_captured_thread_select (struct ui_out =A0 =A0 ui_out_text (uiout, "[Switching to thread "); =A0 =A0 ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferio= r_ptid)); -=A0 ui_out_text (uiout, " ("); +=A0 ui_out_text (uiout, " \""); +=A0 ui_out_text (uiout, thread_name (tp)); +=A0 ui_out_text (uiout, "\" ("); =A0 =A0 ui_out_text (uiout, target_pid_to_str (inferior_ptid)); =A0 =A0 ui_out_text (uiout, ")]"); Index: gdb/testsuite/gdb.threads/thread-find.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/thread-find.exp,v retrieving revision 1.9 diff -u -p -r1.9 thread-find.exp --- gdb/testsuite/gdb.threads/thread-find.exp=A0=A0=A0 1 Jan 2013 06:41:27 = -0000=A0=A0=A0 1.9 +++ gdb/testsuite/gdb.threads/thread-find.exp=A0=A0=A0 3 Sep 2013 02:36:11 = -0000 @@ -186,17 +186,17 @@ gdb_test "thread find threadname_1" \ =A0 if { [info exists thread6] } then { =A0 =A0 =A0 gdb_test "thread find $thread6" \ -=A0=A0=A0 "Thread 6 has .*$thread6.*" "find thread id 6" +=A0=A0=A0 "Thread 6 \"threadname_6\" has .*$thread6.*" "find thread id 6" =A0 =A0 =A0 gdb_test "thread find $thread5" \ -=A0=A0=A0 "Thread 5 has .*$thread5.*" "find thread id 5" +=A0=A0=A0 "Thread 5 \"threadname_5\" has .*$thread5.*" "find thread id 5" =A0 =A0 =A0 gdb_test "thread find $thread4" \ -=A0=A0=A0 "Thread 4 has .*$thread4.*" "find thread id 4" +=A0=A0=A0 "Thread 4 \"threadname_4\" has .*$thread4.*" "find thread id 4" =A0 =A0 =A0 gdb_test "thread find $thread3" \ -=A0=A0=A0 "Thread 3 has .*$thread3.*" "find thread id 3" +=A0=A0=A0 "Thread 3 \"threadname_3\" has .*$thread3.*" "find thread id 3" =A0 =A0 =A0 gdb_test "thread find $thread2" \ -=A0=A0=A0 "Thread 2 has .*$thread2.*" "find thread id 2" +=A0=A0=A0 "Thread 2 \"threadname_2\" has .*$thread2.*" "find thread id 2" =A0 =A0 =A0 gdb_test "thread find $thread1" \ -=A0=A0=A0 "Thread 1 has .*$thread1.*" "find thread id 1" +=A0=A0=A0 "Thread 1 \"threadname_1\" has .*$thread1.*" "find thread id 1" =A0 } =A0 # @@ -224,17 +224,17 @@ if { [info exists process6] } then { =A0 if { [info exists lwp6] } then { =A0 =A0 =A0 gdb_test "thread find $lwp6" \ -=A0=A0=A0 "Thread 6 has .*$lwp6.*" "find lwp id 6" +=A0=A0=A0 "Thread 6 \"threadname_6\" has .*$lwp6.*" "find lwp id 6" =A0 =A0 =A0 gdb_test "thread find $lwp5" \ -=A0=A0=A0 "Thread 5 has .*$lwp5.*" "find lwp id 5" +=A0=A0=A0 "Thread 5 \"threadname_5\" has .*$lwp5.*" "find lwp id 5" =A0 =A0 =A0 gdb_test "thread find $lwp4" \ -=A0=A0=A0 "Thread 4 has .*$lwp4.*" "find lwp id 4" +=A0=A0=A0 "Thread 4 \"threadname_4\" has .*$lwp4.*" "find lwp id 4" =A0 =A0 =A0 gdb_test "thread find $lwp3" \ -=A0=A0=A0 "Thread 3 has .*$lwp3.*" "find lwp id 3" +=A0=A0=A0 "Thread 3 \"threadname_3\" has .*$lwp3.*" "find lwp id 3" =A0 =A0 =A0 gdb_test "thread find $lwp2" \ -=A0=A0=A0 "Thread 2 has .*$lwp2.*" "find lwp id 2" +=A0=A0=A0 "Thread 2 \"threadname_2\" has .*$lwp2.*" "find lwp id 2" =A0 =A0 =A0 gdb_test "thread find $lwp1" \ -=A0=A0=A0 "Thread 1 has .*$lwp1.*" "find lwp id 1" +=A0=A0=A0 "Thread 1 \"threadname_1\" has .*$lwp1.*" "find lwp id 1" =A0 } =A0 # Test no match. Thanks! -- Mohsan Saleem=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0