Implement "info threads -gid"

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".
This commit is contained in:
Pedro Alves 2016-01-13 10:56:09 +00:00
parent 22a0232400
commit c84f6bbfe5
8 changed files with 55 additions and 10 deletions

View 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."));