From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106522 invoked by alias); 6 Jan 2016 19:12:04 -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 106500 invoked by uid 89); 6 Jan 2016 19:12:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: usplmg20.ericsson.net Received: from usplmg20.ericsson.net (HELO usplmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 06 Jan 2016 19:12:02 +0000 Received: from EUSAAHC003.ericsson.se (Unknown_Domain [147.117.188.81]) by usplmg20.ericsson.net (Symantec Mail Security) with SMTP id A4.CD.06940.0356D865; Wed, 6 Jan 2016 20:04:16 +0100 (CET) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.83) with Microsoft SMTP Server id 14.3.248.2; Wed, 6 Jan 2016 14:11:59 -0500 Subject: Re: [PATCH v3 6/7] Implement "info threads -gid" To: Pedro Alves , References: <1452085418-18300-1-git-send-email-palves@redhat.com> <1452085418-18300-7-git-send-email-palves@redhat.com> From: Simon Marchi Message-ID: <568D66FF.4020700@ericsson.com> Date: Wed, 06 Jan 2016 19:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1452085418-18300-7-git-send-email-palves@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg00101.txt.bz2 On 16-01-06 08:03 AM, Pedro Alves wrote: > This commit makes global thread IDs optionaly visible in "info > threads", with the new "-gid" switch: > > (gdb) info threads -gid > Id GId Target Id Frame > 1.1 1 Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running) > 1.2 3 Thread 0x7ffff77c0700 (LWP 6028) "threads" (running) > 1.3 4 Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running) > 2.1 2 Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running) > 2.2 5 Thread 0x7ffff77c0700 (LWP 6038) "threads" (running) > * 2.3 6 Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running) > > (gdb) info threads > Id Target Id Frame > 1.1 Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running) > 1.2 Thread 0x7ffff77c0700 (LWP 6028) "threads" (running) > 1.3 Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running) > 2.1 Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running) > 2.2 Thread 0x7ffff77c0700 (LWP 6038) "threads" (running) > * 2.3 Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running) > > No regressions on x86_64 Fedora 20. > > gdb/ChangeLog: > 2016-01-06 Pedro Alves > > * NEWS: Mention "info threads -gid". > * gdbthread.h (struct thread_info) : Mention "info > threads -gid". > * thread.c (info_threads_command): Handle "-gid". > (_initialize_thread): Adjust "info threads" help string to mention > -gid. > > gdb/testsuite/ChangeLog: > 2016-01-06 Pedro Alves > > * gdb.multi/tids.exp: Test "info threads -gid". > > gdb/doc/ChangeLog: > 2016-01-06 Pedro Alves > > * gdb.texinfo (Threads): Document "info threads -gid". > --- > gdb/NEWS | 3 +++ > gdb/doc/gdb.texinfo | 19 +++++++++++++------ > gdb/gdbthread.h | 4 ++-- > gdb/testsuite/gdb.multi/tids.exp | 8 ++++++++ > gdb/thread.c | 14 ++++++++++++-- > 5 files changed, 38 insertions(+), 10 deletions(-) > > diff --git a/gdb/NEWS b/gdb/NEWS > index c87a73d..32e7bd3 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -34,6 +34,9 @@ > [Switching to thread 2.1 (Thread 0x7ffff7fc2740 (LWP 8157))] (running) > (gdb) > > +* You can use "info threads -gid" to display the global thread ID of > + all threads. > + > * The new convenience variable $_inferior holds the number of the > current inferior. > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 1bf2208..8ce3b01 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -2959,6 +2959,10 @@ threads that you want to display using the thread ID list syntax > the per-inferior thread number assigned by @value{GDBN} > > @item > +the global thread number assigned by @value{GDBN}, if the @samp{-gid} > +option was specified > + > +@item > the target system's thread identifier (@var{systag}) > > @item > @@ -2989,15 +2993,18 @@ For example, > > If you're debugging multiple inferiors, @value{GDBN} displays thread > IDs using the qualified @var{inferior-num}.@var{thread-num} format. > -Otherwise, only @var{thread-num} is shown: > +Otherwise, only @var{thread-num} is shown. > + > +If you specify the @samp{-gid} option, @value{GDBN} displays a column > +indicating each thread's global thread ID: > > @smallexample > (@value{GDBP}) info threads > - Id Target Id Frame > - 1.1 process 35 thread 13 main (argc=1, argv=0x7ffffff8) > - 1.2 process 35 thread 23 0x34e5 in sigpause () > - 1.3 process 35 thread 27 0x34e5 in sigpause () > -* 2.1 process 65 thread 1 main (argc=1, argv=0x7ffffff8) > + Id GId Target Id Frame > + 1.1 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8) > + 1.2 3 process 35 thread 23 0x34e5 in sigpause () > + 1.3 4 process 35 thread 27 0x34e5 in sigpause () > +* 2.1 2 process 65 thread 1 main (argc=1, argv=0x7ffffff8) > @end smallexample > > On Solaris, you can display more information about user threads with a > diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h > index 6c23687..b8d5ac2 100644 > --- a/gdb/gdbthread.h > +++ b/gdb/gdbthread.h > @@ -216,8 +216,8 @@ struct thread_info > Above, both inferiors 1 and 2 have threads numbered 1-3, but each > thread has its own unique global ID. */ > > - /* The thread's global GDB thread number. This is exposed to MI and > - Python/Scheme. */ > + /* The thread's global GDB thread number. This is exposed to MI, > + Python/Scheme and visible with "info threads -gid". */ > int global_num; > > /* The per-inferior thread number. This is unique in the inferior > diff --git a/gdb/testsuite/gdb.multi/tids.exp b/gdb/testsuite/gdb.multi/tids.exp > index 12aca07..badb1f1 100644 > --- a/gdb/testsuite/gdb.multi/tids.exp > +++ b/gdb/testsuite/gdb.multi/tids.exp > @@ -150,6 +150,14 @@ with_test_prefix "two inferiors" { > info_threads "" "1.1 1.2 2.1 2.2" \ > "info threads again" > > + # Same, but show the global ID. > + gdb_test "info threads -gid" \ > + [multi_line \ > + " 1\.1 +1 +.*" \ > + "\\* 1\.2 +4 +.* thread_function1 .* at .*$srcfile:.*" \ > + " 2\.1 +2 +.*" \ > + " 2\.2 +3 +.* thread_function1 .* at .*$srcfile:.*"] > + > # Confirm the convenience variable show the expected number. > gdb_test "p \$_thread == 2" " = 1" > > diff --git a/gdb/thread.c b/gdb/thread.c > index 64002e1..24eb83e 100644 > --- a/gdb/thread.c > +++ b/gdb/thread.c > @@ -1381,7 +1381,16 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid) > static void > info_threads_command (char *arg, int from_tty) > { > - print_thread_info_1 (current_uiout, arg, 0, -1, 0); > + int show_global_ids = 0; > + > + if (arg != NULL > + && check_for_argument (&arg, "-gid", sizeof ("-gid") - 1)) > + { > + arg = skip_spaces (arg); > + show_global_ids = 1; > + } > + > + print_thread_info_1 (current_uiout, arg, 0, -1, show_global_ids); > } > > /* See gdbthread.h. */ > @@ -2085,7 +2094,8 @@ _initialize_thread (void) > > add_info ("threads", info_threads_command, > _("Display currently known threads.\n\ > -Usage: info threads [ID]...\n\ > +Usage: info threads [-gid] [ID]...\n\ > +-gid: Show global thread IDs.\n\ > If ID is given, it is a space-separated list of IDs of threads to display.\n\ > Otherwise, all threads are displayed.")); > > LGTM.