Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Add optional argument to "info threads" command
@ 2008-11-24 12:44 Michael Snyder
  2008-11-24 15:19 ` teawater
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Michael Snyder @ 2008-11-24 12:44 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

I've long been frustrated because I could not ask for
info about just one or more threads.

This patch makes use of command parsing code in breakpoint.c
to give "info threads" the same optional arguments as "info
breakpoints", ie. a list of one or more threads of interest,
or a range of threads (eg. "5-9").

Documentation updated.

OK?


[-- Attachment #2: infothread2.txt --]
[-- Type: text/plain, Size: 2681 bytes --]

2008-11-22  Michael Snyder  <msnyder@promb-2s-dhcp151.eng.vmware.com>

	* thread.c (info_threads_command): Parse arguments for optional
	list (or range) of threads to which the command shall apply.
	(_initialize_thread): Explain extension in help string.

2008-11-22  Michael Snyder  <msnyder@promb-2s-dhcp151.eng.vmware.com>

	* gdb.texinfo (Debugging Programs with Multiple Threads):
	Document new optional argument to "info threads" command.

Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.98
diff -u -p -r1.98 thread.c
--- thread.c	17 Nov 2008 12:13:49 -0000	1.98
+++ thread.c	23 Nov 2008 02:11:22 -0000
@@ -752,7 +752,34 @@ The current thread <Thread ID %d> has te
 static void
 info_threads_command (char *arg, int from_tty)
 {
-  print_thread_info (uiout, -1, -1);
+  char *p = arg;
+  char *p1;
+  int num, match;
+  struct thread_info *tp;
+
+  if (p == NULL)
+    print_thread_info (uiout, -1, -1);
+  else
+    while (*p)
+      {
+	match = 0;
+	p1 = p;
+	num = get_number_or_range (&p1);
+	if (num == 0)
+	  warning (_("bad thread number at or near '%s'"), p);
+	else
+	  {
+	    for (tp = thread_list; tp; tp = tp->next)
+	      if (num == tp->num)
+		{
+		  match = 1;
+		  print_thread_info (uiout, num, -1);
+		}
+	    if (match == 0)
+	      printf_unfiltered (_("No thread number %d.\n"), num);
+	  }
+	p = p1;
+      }
 }
 
 /* Switch from one thread to another. */
@@ -1116,7 +1143,7 @@ _initialize_thread (void)
   struct cmd_list_element *c;
 
   c = add_info ("threads", info_threads_command,
-		_("IDs of currently known threads."));
+		_("IDs of currently known threads, or optionally specified threads."));
   set_cmd_no_selected_thread_ok (c);
 
   c = add_prefix_cmd ("thread", class_run, thread_command, _("\
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.536
diff -u -p -r1.536 gdb.texinfo
--- doc/gdb.texinfo	22 Nov 2008 12:14:33 -0000	1.536
+++ doc/gdb.texinfo	23 Nov 2008 02:11:23 -0000
@@ -2491,9 +2491,11 @@ number---always a single integer---with 
 
 @table @code
 @kindex info threads
-@item info threads
-Display a summary of all threads currently in your
-program.  @value{GDBN} displays for each thread (in this order):
+@item info threads @r{[}@var{threads}@r{]} @r{[}@var{range}@dots{}@r{]}
+Display a summary of all threads currently in your program.  
+Optional argument means display information only
+about the specified threads or range of threads.
+@value{GDBN} displays for each thread (in this order):
 
 @enumerate
 @item

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-11-24 23:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-24 12:44 [RFA] Add optional argument to "info threads" command Michael Snyder
2008-11-24 15:19 ` teawater
2008-11-24 16:33 ` Pedro Alves
2008-11-24 21:22   ` Michael Snyder
2008-11-24 22:10     ` Pedro Alves
2008-11-24 23:03       ` Pedro Alves
2008-11-25  8:48       ` Michael Snyder
2008-11-25 16:06         ` Pedro Alves
2008-11-24 23:22 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox