From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aNtcN8iUH2d4Xx0AWB0awg (envelope-from ) for ; Mon, 28 Oct 2024 09:42:32 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Wr3pwaN8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CD3C31E56E; Mon, 28 Oct 2024 09:42:32 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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=ham 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 15DDE1E37A for ; Mon, 28 Oct 2024 09:42:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AEF143858C31 for ; Mon, 28 Oct 2024 13:42:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEF143858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1730122951; bh=izB6KcrByWom3kznIg9n+qhlcMOdK5oYM8mMKhDkRmg=; h=References:In-Reply-To:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Wr3pwaN8C9ysa73WYcfooJzH/Bn6/KELXE67PXgtUfF4xltFqNUVRpAJVbVrB2z3r AMsB+ut60tbW1HvL7tvvIknxhRdAx7BowN7Dj5SFn3lm2Kx2hyzo+8sCavSO+K8q4h PthqWPfgp6GyVMaE9lMMzsUtfDCupGUFbAsLQ0+E= Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 4D306385840E for ; Mon, 28 Oct 2024 13:41:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D306385840E ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4D306385840E ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730122913; cv=none; b=jobYFP/Azh1zCq8T8Bzy1XrKqYg3fxn8kJd7/NsSDcIlFq6oPbEtuXwwtj4z0IHeVBOHfT5n3ij7zBkiUmG2K84cp4GcY/0mSuZSyjDRkprG23ij8gFecc+dNPTE/NfJkhNaL9hWsNXgxdjwqsAKmwR2++3FtS0S0twtX5DlQY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730122913; c=relaxed/simple; bh=fg8egSSGH+thMrt8r/u/DryB3mE8xGwpQ2kKIcveTE0=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=kx6Q0vQ2dwXKnGbeCgBmpmCoFBJj2lfXTDnc74SOZS5Xafp7iuXjmFgz6EFVfRhio7BWM5BLOCmwCUgiIq72sCbLnuuze9Hl59POJVE0yu0VGL6ZplbAWsM9CIFHUGiAAaZPpOq/lOktdfsi2hyGzsasz+KSkSc7LXEQvRTRzU8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-539e59dadebso5070512e87.0 for ; Mon, 28 Oct 2024 06:41:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730122908; x=1730727708; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=izB6KcrByWom3kznIg9n+qhlcMOdK5oYM8mMKhDkRmg=; b=ZD98YhiVquwpQoYh6r9+JPxY/7kZ2z7B0shvn5DiFe81imkfw3bWUilXJjrpGtNd3H IL//yMCaiaZW4wNlCTFABR699Z6vvaH3RmkfhzISgYHPkl9rufy+tb7aiJ6NZacSZpyi m0lunbaFoKsIfUne9UWMwfll9ONfI3vm7tZuaXHYatufefRXY/g2ptwmDknnbsGQyWUN QZRmQ0RJMfVwjfrSEsK/cr9jGMskhneHZlxtd/TuPOFj7FoDSEbGE2xa5RHyLQ54Ph2l 4ps0lL9ZD3+TOzGB2rQ4zvw1J9PehWsvIR3r/FCkpcxontTH1LS1VzMFi+glkFdtYLcY 6w3Q== X-Gm-Message-State: AOJu0Yxpv5kLOpcLLsYPKIfJ3qLjcwXH+9GwgoRbocNB7+Vd1WaPMFtX IdYvzvLV1MxMR6hVg0MmGml4iVhLMeqadZCfJPd7mw8TxUT4YZX/O7MM3s426GHg+OroEdoaBw2 40pd36x63ufbHutCIq5KoUc2iXQ8= X-Google-Smtp-Source: AGHT+IEzXyVAmWaFhiJPyNsjYPibqzLva/1KQaErtO7LgmhVzE8LTIr72hMYxACfDm01fVMnTnw/AqmXRQ/gnrQovNk= X-Received: by 2002:a05:6512:2210:b0:539:adb0:b91 with SMTP id 2adb3069b0e04-53b34c8ee46mr2647310e87.57.1730122907348; Mon, 28 Oct 2024 06:41:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 28 Oct 2024 15:41:34 +0200 Message-ID: Subject: Re: [PING][RFC] New command "thread filter" in GDB To: "Ijaz, Abdul B" Cc: "gdb@sourceware.org" , "Aktemur, Tankut Baris" , "Schimpe, Christina" , "Metzger, Markus T" , "pedro@palves.net" , Andrew Burgess , "simon.marchi@polymtl.ca" , "tom@tromey.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: , From: Dov Grobgeld via Gdb Reply-To: Dov Grobgeld Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" Sounds useful! I once wrote a related gdb command that I called "threadgrep" that shows any thread (actually the corresponding "where" line) that in the call stack has a match to a regular expression. I guess such functionality could be implemented by your predicate() function. Regards, On Mon, Oct 28, 2024 at 1:58=E2=80=AFPM Ijaz, Abdul B via Gdb wrote: > > Ping. > > Thanks & Best Regards > Abdul Basit > > From: Ijaz, Abdul B > > Sent: Wednesday, October 2, 2024 9:24 AM > To: gdb@sourceware.org > Cc: Aktemur, Tankut Baris >; Schimpe, Christina >; Metzger, Markus T > > Subject: [RFC] New command "thread filter" in GDB > > Hi All, > > I am writing to collect your feedback for the new command =E2=80=9Cthread= filter=E2=80=9D, we would like to introduce. This new command will proce= ss the input list of threads and then try to filter them if there is any ex= pression 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 =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=9Cpredic= ate=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 vari= able 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 fur= ther 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 thre= ad 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 th= e 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 fil= ters using regex for some fields. It filters the thread(s) using fields lik= e id, thread name etc. The output of this command is thread id, name and = extra information. But this command is not able to filter using thread loc= ation, expression, private or convenience variables like shown above and al= so if there are many threads filtered then its output is not easy to reuse = as an input for other commands. Like if someone want to get =E2=80=9Cinfo = threads=E2=80=9D or =E2=80=9Cthread apply=E2=80=9D for all the filtered thr= eads etc. Mentioning this, to clarify also whether it will be best to upd= ate the existing command or adding a new command would be fine. As extend= ing the existing command will update the output of command. Example of the = 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 REGE= XP. > (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 ../sy= sdeps/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=9Cl= ocation=E2=80=9D and =E2=80=9Cexpression=E2=80=9D filtering which is not ha= ndled by =E2=80=9Cthread find=E2=80=9D command. Adding a new command inste= ad of extending =E2=80=9Cthread find=E2=80=9D will avoid changing the outpu= t of the existing command. > > For the new command =E2=80=9Cthread filter=E2=80=9D, here are two options= considered in handling of =E2=80=9Cexpression=E2=80=9D and =E2=80=9Clocati= on=E2=80=9D as in input. Output will be same for both options and only inp= ut expression and locations can be handled differently. The output is a li= st of =E2=80=9Cthread ids=E2=80=9D a string type. Please refer to examples = above for the usage of output from this command as other commands input. Y= our feedback will be greatly appreciated regarding which option would be be= st 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 takes = 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 si= milar to similar clause in the =E2=80=9Cbreak=E2=80=9D command. > > Command: thread filter [thread-id-list/all] [OPTION] [ at filename:linenu= m] [if expression] > > E.g.: > (gdb) thread filter at main.cpp:3 if $_thread >1 && $_thread<5 > 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 also to the convenience variable (e.g. $_locat= ion) then user may just filter everything via the convenience variable in t= he expression. > > Command: thread filter [thread-id-list/all] [OPTION] [expression] > > E.g.: > (gdb) thread filter at main.cpp:3 if ($_thread >1 && $_thread<5 ) && $_st= req($_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 welc= ome 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 new= 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 Sil= va > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928