+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.
[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.
+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
@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})
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
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
+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
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"
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. */
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."));