Implement "info threads -gid"
authorPedro Alves <palves@redhat.com>
Wed, 13 Jan 2016 10:56:09 +0000 (10:56 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 13 Jan 2016 11:02:05 +0000 (11:02 +0000)
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-13  Pedro Alves  <palves@redhat.com>

* NEWS: Mention "info threads -gid".
* gdbthread.h (struct thread_info) <global_num>: 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-13  Pedro Alves  <palves@redhat.com>

* gdb.multi/tids.exp: Test "info threads -gid".

gdb/doc/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Threads): Document "info threads -gid".

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/gdbthread.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.multi/tids.exp
gdb/thread.c

index d2538084f83f7f002a1d53edde5bfafbd5f0ab43..603af22cd396c98d3dee312a316b3561f2a9ba4a 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-13  Pedro Alves  <palves@redhat.com>
+
+       * NEWS: Mention "info threads -gid".
+       * gdbthread.h (struct thread_info) <global_num>: Mention "info
+       threads -gid".
+       * thread.c (info_threads_command): Handle "-gid".
+       (_initialize_thread): Adjust "info threads" help string to mention
+       -gid.
+
 2016-01-13  Pedro Alves  <palves@redhat.com>
 
        * NEWS: Mention InferiorThread.global_num.
index ff92079301e095a60892e743d382550e4ef7fe06..024c184879ec5a689fd34fe1f523366b6762d1ce 100644 (file)
--- 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.
 
index 65f8ed900a70d9ae1cde397e8a59aba1b5b846da..d723276a9afc6ac1813d85394a17315283eeb96c 100644 (file)
@@ -1,3 +1,7 @@
+2016-01-13  Pedro Alves  <palves@redhat.com>
+
+       * gdb.texinfo (Threads): Document "info threads -gid".
+
 2016-01-13  Pedro Alves  <palves@redhat.com>
 
        * python.texi (Breakpoints In Python) <Breakpoint.thread>: Add
index 786556e854bd3fc9c651ed3971a1008d74b29821..654efa425fe84648dbaffd66796d10b272345273 100644 (file)
@@ -2958,6 +2958,10 @@ threads that you want to display using the thread ID list syntax
 @item
 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})
 
@@ -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
index 5ff38bf084eb93655f5bf77c286acdc28cca2c5a..bfc91245a4313bbed4d35f523b604e43fba04ca6 100644 (file)
@@ -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
index 92989a9a9cad7e1856b4fb51a9a31663cc0ed9e6..c86351863c632a5b5b8aa99a614874ee02d94f64 100644 (file)
@@ -1,3 +1,7 @@
+2016-01-13  Pedro Alves  <palves@redhat.com>
+
+       * gdb.multi/tids.exp: Test "info threads -gid".
+
 2016-01-13  Pedro Alves  <palves@redhat.com>
 
        * gdb.multi/tids.exp: Test InferiorThread.global_num and
index 6895f3c9561aa0e7819da0e4ee1dec0298a06a2d..b0c768fbc39cf926dad9040404dec3f57dece32f 100644 (file)
@@ -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"
 
index dd8f7da0d647038e198c1cba96d6be5b90a6a194..8ec6a38e391c4bd50e76bb141263a88495d350f1 100644 (file)
@@ -1403,7 +1403,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.  */
@@ -2107,7 +2116,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."));
 
This page took 0.058379 seconds and 4 git commands to generate.