Re: [RFC] New command "thread filter" in GDB

Martin Simmons
2024-10-28T21:12:47Z

>>>>> On Wed, 2 Oct 2024 07:24:21 +0000, Ijaz, Abdul B via Gdb said:
>
> Hi All,
>
> I am writing to collect your feedback for the new command “thread filter”, we would like to introduce. This new command will process the input list of threads and then try to filter them if there is any expression in the input. So it print only filtered thread ids from the input list where the input expression evaluates to true. Here are some examples for the usage of this command:
>
>
> * thread filter 1-9
> * Outputs the ids of threads with single digit
> * thread filter all x > 10
> * Outputs the ids of threads in whose context the variable “x” is greater than 10.
> * thread filter 10-99 $_thread % 2 == 0
> * Outputs the ids of threads whose id is a two-digit even number.
> * thread filter all predicate()
> * Outputs the ids of thread for which the function “predicate” evaluates to true.
> * thread filter all workitem == 1234
> * Find the thread(s) for which the “workitem” variable has a specific value.
>
> Output of all these commands will be string type list of thread ids which may be used later for other commands like thread apply, info thread or further filtering. For example
>
> * thread filter all $_thread<5
>
> Filtered threads:
>
> $1 = “1 2 3 4”
>
>
> Examples of output usage in other command like “info thread” or “thread apply”:
>
> * info threads 1 2 3 4
> * “info thread” command print thread info for thread ids “1 2 3 4 5”

Are you also proposing an extension to "info threads" and "threads
apply"? Otherwise, I don't see how a script can use the result of
"thread filter" in those commands.

Maybe some extension to allow a string type list from a variable like in
the following (currently, you get an error "History value must have
integer type.")?

info threads $1
thread apply $1 p workitem

__Martin