This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Add optional argument to "info threads" command


Hey, I think this function is useful.

Thanks,
Hui

On Sun, Nov 23, 2008 at 10:12, Michael Snyder <msnyder@vmware.com> 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  <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
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]