From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6754 invoked by alias); 24 Nov 2008 02:25:59 -0000 Received: (qmail 6664 invoked by uid 22791); 24 Nov 2008 02:25:58 -0000 X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.184) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Nov 2008 02:25:23 +0000 Received: by ti-out-0910.google.com with SMTP id d10so1116647tib.12 for ; Sun, 23 Nov 2008 18:25:12 -0800 (PST) Received: by 10.110.73.19 with SMTP id v19mr4151787tia.30.1227493512250; Sun, 23 Nov 2008 18:25:12 -0800 (PST) Received: by 10.110.103.3 with HTTP; Sun, 23 Nov 2008 18:25:12 -0800 (PST) Message-ID: Date: Mon, 24 Nov 2008 15:19:00 -0000 From: teawater To: "Michael Snyder" Subject: Re: [RFA] Add optional argument to "info threads" command Cc: "gdb-patches@sourceware.org" In-Reply-To: <4928BC24.5020600@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4928BC24.5020600@vmware.com> X-IsSubscribed: yes 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 X-SW-Source: 2008-11/txt/msg00630.txt.bz2 Hey, I think this function is useful. Thanks, Hui On Sun, Nov 23, 2008 at 10:12, Michael Snyder wrote: > > 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? > > > 2008-11-22 Michael Snyder > > * 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 > > * 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 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 >