From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oOvZMA+1IGc4Uh4AWB0awg (envelope-from ) for ; Tue, 29 Oct 2024 06:12:31 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=dyxyl.com header.i=@dyxyl.com header.a=rsa-sha256 header.s=default header.b=NE4q7Ont; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BAAE81E590; Tue, 29 Oct 2024 06:12:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,HK_RANDOM_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS autolearn=unavailable autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7AD981E58D for ; Tue, 29 Oct 2024 06:12:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CFA93858402 for ; Tue, 29 Oct 2024 10:12:30 +0000 (GMT) Received: from cp165172.hpdns.net (cp165172.hpdns.net [91.238.165.172]) by sourceware.org (Postfix) with ESMTPS id 118FE385840B for ; Tue, 29 Oct 2024 10:11:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 118FE385840B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dyxyl.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dyxyl.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 118FE385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=91.238.165.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730196718; cv=none; b=mLG7LolgS+BiYg6x+xVLpF31qnLyjPAOfXJD4ES7BBwtJGZY9MkIBkSI8JJjHpa/k9PX/d93Ir0JN91Ds//TmbqkIPhL2JlB53midvcStnvLq4vXMthBWthibI+B2yBxHUW6Cg7XmOmjlZ+aBbqfCRwAM8ffBZ5KvLKXdcxd6QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730196718; c=relaxed/simple; bh=6k2MUS1f+dW0NZW0okaB3wrbXNROi/Bnhyy+op77oi4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xHyOwHxMVje9Yt8AbMh0Kcsqom7G8ifOfxAnxKbZay+VZdA1gNIR7FcziLqkrSlTNDNGB9TqaKN6KPG1PbboKOo+HLEcSI1BDe2JT0X5d/YX4R+WseIWtxqxQ/bNFru1a1KsjzS+IkS8RwBk3I0Km45OdVNfyeISZ0NUc2GZ7d8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dyxyl.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YNsuiMcQHM6o3mozWHc9+gFxOZedDiXDODAqDyEiDKE=; b=NE4q7OntWl0NKXtl7pKgzm1o/J egIBjOovN3QWcqqLnnqa7XWcVhjWWeeNObs3lqQNjcxqnGxyTz+H83J6r5APG+h3WpkCGVR/pChp8 oAiDUH96GpzI/8MNDru+/lduST5z9qgO4q7Jctk+2dMKMMX0HjBTZesijielUAJ3Dx9ZrjfC7feOU v5f2CN+8VSbsFsnx2oN214mvH1WSiH/PblF7QqLJgcXx6VoPY63s9R+n7l0liFma4PwRI9u2FsPmR nryON8yxpZK4kr5FKycY0MrS5KwHuVkwJ3ZfR3IXvE2lYupnWhVk5Q0/ZB57kc53I7vRt5vSSwRb6 ULeX2PEQ==; Received: from cmbg-19-b2-v4wan-170160-cust2145.vm17.cable.virginm.net ([94.175.88.98]:49818 helo=localhost.localdomain) by cp165172.hpdns.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98) (envelope-from ) id 1t5jCV-00000004AVh-16hL; Tue, 29 Oct 2024 10:11:45 +0000 Received: by localhost.localdomain (Postfix, from userid 597) id BD15EE0E5B; Tue, 29 Oct 2024 10:11:44 +0000 (GMT) From: Martin Simmons To: "Ijaz, Abdul B" Cc: aburgess@redhat.com, gdb@sourceware.org, tankut.baris.aktemur@intel.com, christina.schimpe@intel.com, markus.t.metzger@intel.com, pedro@palves.net, tom@tromey.com, simon.marchi@polymtl.ca Subject: Re: [RFC] New command "thread filter" in GDB In-Reply-To: (gdb@sourceware.org) References: <874j4wwamc.fsf@redhat.com> Date: Tue, 29 Oct 2024 10:11:44 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-YourOrg-MailScanner-Information: Please contact the ISP for more information X-YourOrg-MailScanner-ID: 1t5jCV-00000004AVh-16hL X-YourOrg-MailScanner: Found to be clean X-YourOrg-MailScanner-SpamCheck: X-YourOrg-MailScanner-From: qqxnjvamvxwx@dyxyl.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cp165172.hpdns.net X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dyxyl.com X-Get-Message-Sender-Via: cp165172.hpdns.net: authenticated_id: dyxyl/from_h X-Authenticated-Sender: cp165172.hpdns.net: qqxnjvamvxwx@dyxyl.com X-Source: X-Source-Args: X-Source-Dir: X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" I think option#2 is more flexible because it allows for boolean expressions on the location, in particular using || for "or" which might be useful. __Martin >>>>> On Mon, 28 Oct 2024 20:46:11 +0000, Ijaz, Abdul B via Gdb said: >=20 > Thanks Andrew for you feedback. >=20 > Andrew>Having the current location available via convenience variables so= unds useful regardless, though I'd be tempted to suggest it should be split= into two, file and line. >=20 > Abdul > Sure, we can have two convenience variables separately for file a= nd line. It would be easier to use them separately in any expression also. = So, regarding Option#2 then two new convenience variables for thread file a= nd line location information will be added in any case, instead of one comm= on location convenience variable. >=20 > Andrew>The other possibility, which you don't specifically mention would = be using GDB's option system, rather than going with a more natural languag= e syntax (OPTION #1). You could allow something like: > (gdb) thread filter [-location LOC] > [-thread-id LIST] > [expression] >=20 > Abdul> Right, Option#1 can be implemented using GDB' options instead of "= if" and "at" clauses. Main motivation for Option#1 was the existing breakp= oint command and also to be able to share command options with existing thr= ead apply command. But agree using GDB's option system would be better for = Option#1. Only in this suggestion, I would like to keep "-thread-list" hand= ing like Option#1 or #2 to have the handling of it similar to the existing = "thread apply" command instead of having a separate argument for it . This = argument can be a mandatory like "thread apply" command which is either lis= t of thread ids or "all" option to use command for all threads. >=20 > So, lets call it Option#3 to be clear where GDB's options are used instea= d of "if" and "at" clauses. It would be great if you may confirm that comm= and looks fine to you without [-thread-id LIST]. Also it will be really he= lpful and nice if anyone has any opinion regarding this option or other opt= ions mentioned in original email. This will be the new command then using t= his option: >=20 > (gdb) thread filter all/LIST [-location LOC] > [expression] >=20 > Thanks & Best Regards > Abdul Basit >=20 > -----Original Message----- > From: Andrew Burgess =20 > Sent: Monday, October 28, 2024 3:44 PM > To: Ijaz, Abdul B ; gdb@sourceware.org > Cc: Aktemur, Tankut Baris ; Schimpe, Chri= stina ; Metzger, Markus T > Subject: Re: [RFC] New command "thread filter" in GDB >=20 > "Ijaz, Abdul B via Gdb" writes: >=20 > > Hi All, > > > > I am writing to collect your feedback for the new command =E2=80=9Cthre= ad filter=E2=80=9D, we would like to introduce. This new command will pro= cess 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 inpu= t list where the input expression evaluates to true. Here are some exampl= es 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 =E2= =80=9Cx=E2=80=9D is greater than 10. > > * thread filter 10-99 $_thread % 2 =3D=3D 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 =E2=80=9Cpred= icate=E2=80=9D evaluates to true. > > * thread filter all workitem =3D=3D 1234 > > * Find the thread(s) for which the =E2=80=9Cworkitem=E2=80=9D va= riable has a specific value. > > > > Output of all these commands will be string type list of thread ids=20 > > which may be used later for other commands like thread apply, info=20 > > thread or further filtering. For example > > > > * thread filter all $_thread<5 > > > > Filtered threads: > > > > $1 =3D =E2=80=9C1 2 3 4=E2=80=9D > > > > > > Examples of output usage in other command like =E2=80=9Cinfo thread=E2= =80=9D or =E2=80=9Cthread apply=E2=80=9D: > > > > * info threads 1 2 3 4 > > * =E2=80=9Cinfo thread=E2=80=9D command print thread info for th= read ids =E2=80=9C1 2 3 4 5=E2=80=9D > > > > OR > > > > * thread apply 1 2 3 4 p workitem > > * Print a variable with name =E2=80=9Cworkitem=E2=80=9D for all = the threads matching ids filtered by the thread filter command. > > * Thread filter 1 2 3 4 workitem >2 > > * Outputs the ids of thread from the input =E2=80=9C1 2 3 4 5=E2= =80=9D list for which a variable =E2=80=9Cworkitem=E2=80=9D value is great= er than 2. > > > > There is already a =E2=80=9Cthread find=E2=80=9D command in GDB which f= ilters using regex for some fields. It filters the thread(s) using fields l= ike id, thread name etc. The output of this command is thread id, name an= d extra information. But this command is not able to filter using thread l= ocation, expression, private or convenience variables like shown above and = also if there are many threads filtered then its output is not easy to reus= e as an input for other commands. Like if someone want to get =E2=80=9Cinf= o threads=E2=80=9D or =E2=80=9Cthread apply=E2=80=9D for all the filtered t= hreads etc. Mentioning this, to clarify also whether it will be best to u= pdate the existing command or adding a new command would be fine. As exte= nding the existing command will update the output of command. Example of th= e input and outputs of existing =E2=80=9Cthread find=E2=80=9D command. > > > > (gdb) help thread find > > Find threads that match a regular expression. > > Usage: thread find REGEXP > > Will display thread ids whose name, target ID, or extra info matches RE= GEXP. > > (gdb) info threads > > Id Target Id Frame > > * 1 Thread 0x2b80 (LWP 70636) "async" main () at async.c:63 > > 2 Thread 0x640 (LWP 70639) "async" futex_wait (=E2=80=A6) at ../= sysdeps/nptl/futex-internal.h:146 > > 3 Thread 0x7ffff7580640 (LWP 70640) "async" futex_wait (=E2=80=A6)= at ../sysdeps/nptl/futex-internal.h:146 > > (gdb) thread find 7063 > > Thread 1 has target id 'Thread 0x7ffff7d82b80 (LWP 70636)' > > Thread 2 has target id 'Thread 0x7ffff7d81640 (LWP 70639)' > > (gdb) thread find async > > Thread 1 has target name 'async' > > Thread 2 has target name 'async' > > Thread 3 has target name 'async' > > (gdb) thread find async.c > > No threads match 'async.c' > > > > So the new =E2=80=9Cthread filter=E2=80=9D command will handle =E2=80= =9Clocation=E2=80=9D and =E2=80=9Cexpression=E2=80=9D filtering which is no= t handled by =E2=80=9Cthread find=E2=80=9D command. Adding a new command i= nstead of extending =E2=80=9Cthread find=E2=80=9D will avoid changing the o= utput of the existing command. > > > > For the new command =E2=80=9Cthread filter=E2=80=9D, here are two optio= ns considered in handling of =E2=80=9Cexpression=E2=80=9D and =E2=80=9Cloca= tion=E2=80=9D as in input. Output will be same for both options and only i= nput expression and locations can be handled differently. The output is a = list of =E2=80=9Cthread ids=E2=80=9D a string type. Please refer to example= s above for the usage of output from this command as other commands input. = Your feedback will be greatly appreciated regarding which option would be = best here: > > > > OPTION 1: Using "at" and "if" Clauses > > > > In this case for filtering, =E2=80=9Cat=E2=80=9D and =E2=80=9Cif=E2=80= =9D clauses can be added as an optional arguments to this command which tak= es expression as an input for the =E2=80=9Cif=E2=80=9D clause and location = via =E2=80=9Cat=E2=80=9D clause. The =E2=80=9Cif=E2=80=9D clause usage is= similar to similar clause in the =E2=80=9Cbreak=E2=80=9D command. > > > > Command: thread filter [thread-id-list/all] [OPTION] [ at=20 > > filename:linenum] [if expression] > > > > E.g.: > > (gdb) thread filter at main.cpp:3 if $_thread >1 && $_thread<5=20 > > Filtered threads: > > $1=3D =E2=80=9C2 3 4=E2=80=9D > > > > OPTION 2: Using Convenience Variables for Location > > > > Second option is we can avoid =E2=80=9Cif=E2=80=9D and =E2=80=9Cat=E2= =80=9D clauses and add location=20 > > also to the convenience variable (e.g. $_location) then user may just=20 > > filter everything via the convenience variable in the expression. >=20 > Having the current location available via convenience variables sounds us= eful regardless, though I'd be tempted to suggest it should be split into t= wo, file and line. >=20 > The other possibility, which you don't specifically mention would be usin= g GDB's option system, rather than going with a more natural language synta= x (OPTION #1). You could allow something like: >=20 > (gdb) thread filter [-location LOC] > [-thread-id LIST] > [expression] >=20 > with the expression being: everything left on the command line once the a= rguments have been parsed. >=20 > I'm not sure if this is better or not, but you hadn't mentioned this poss= ibility, so I thought I'd offer it up. >=20 > Thanks, > Andrew >=20 >=20 >=20 > > > > Command: thread filter [thread-id-list/all] [OPTION] [expression] > > > > E.g.: > > (gdb) thread filter at main.cpp:3 if ($_thread >1 && $_thread<5 ) &&=20 > > $_streq($_location,=E2=80=9Dmain.cpp:3=E2=80=9D) Filtered threads: > > $1=3D =E2=80=9C2 3 4=E2=80=9D > > =E2=80=9C > > > > What are your thoughts on this topic? Any feedback and new ideas are we= lcome for: > > > > 1. Extending "thread find" vs. New Command "thread filter" > > 2. =E2=80=9COption1=E2=80=9D vs =E2=80=9COptions2=E2=80=9D for the n= ew filtering command. > > > > > > Thanks & Best Regards > > Abdul Basit > > > > Intel Deutschland GmbH > > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > > Tel: +49 89 99 8853-0, www.intel.de > > Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon=20 > > Silva Chairperson of the Supervisory Board: Nicole Lau Registered=20 > > Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 >=20 > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Sil= va > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928 >=20