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_v2 3/8] Add FLAGS... arguments to 'thread apply'.


On 06/05/2018 09:49 PM, Philippe Waroquiers wrote:
> Enhance 'thread apply' command to also accepts  FLAGS... arguments.
> 
> Some examples usages for this new argument:
>    thread apply all -s frame apply all -s p some_local_var_somewhere
>       Prints the thread id, frame location and some_local_var_somewhere
>       value in frames of threads that have such local var.
> 
> To make the life of the user easier, the most typical use cases
> have shortcuts :
>    taas  : shortcut for 'thread apply all -s'
>    tfaas : shortcut for 'thread apply all -s frame apply all -s"
> 
> An example usage :
>    tfaas p some_local_var_somewhere
>      same as the longer:
>         'thread apply all -s frame apply all -s p some_local_var_somewhere'

Same comments on -q/-s and [FLAGS...]/[OPTION...] etc. also apply here.

>     separated list of numbers, or ranges, or the keyword `all'.  Ranges consist
>     of two numbers separated by a hyphen.  Examples:
> @@ -1592,6 +1631,10 @@ tp_array_compar (const thread_info *a, const thread_info *b)
>  static void
>  thread_apply_all_command (const char *cmd, int from_tty)
>  {
> +  int print_what_v = 1; /* Print thread id/thread/lwp.  */
> +  bool cont;
> +  bool silent;
> +
>    tp_array_compar_ascending = false;
>    if (cmd != NULL
>        && check_for_argument (&cmd, "-ascending", strlen ("-ascending")))
> @@ -1600,8 +1643,13 @@ thread_apply_all_command (const char *cmd, int from_tty)
>        tp_array_compar_ascending = true;
>      }
>  
> +  if (cmd != NULL)
> +    check_for_flags_vqcs ("thread apply all", &cmd,
> +			  &print_what_v, 1,
> +			  &cont, &silent);

So here we see a case where there's really no good
reason this shouldn't work:

 (gdb) thread apply all -q -ascending -c p 1
 thread apply all only accepts flags vqcs given individually

>  
> +
> +/* Implementation of the "taas" command.  */
> +
> +static void
> +taas_command (const char *cmd, int from_tty)
> +{
> +  std::string expanded = std::string ("thread apply all -s ") + std::string (cmd);
> +  execute_command (expanded.c_str (), from_tty);
> +}
> +
> +/* Implementation of the "tfaas" command.  */
> +
> +static void
> +tfaas_command (const char *cmd, int from_tty)
> +{
> +  std::string expanded = std::string ("thread apply all -s frame apply all -s ") + std::string (cmd);
> +  execute_command (expanded.c_str (), from_tty);

Overly long lines above.

Thanks,
Pedro Alves


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