From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Pedro Alves <pedro@palves.net>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "guinevere@redhat.com" <guinevere@redhat.com>,
"eliz@gnu.org" <eliz@gnu.org>
Subject: RE: [PATCH v3 2/2] gdb: add a '-stopped' option to "info threads"
Date: Mon, 5 May 2025 16:17:04 +0000 [thread overview]
Message-ID: <DM4PR11MB73039958AA69A291435B8026C48E2@DM4PR11MB7303.namprd11.prod.outlook.com> (raw)
In-Reply-To: <9f6d19b6-3d0a-4491-bfde-52daa45cefbe@palves.net>
On Thursday, April 24, 2025 9:23 PM, Pedro Alves wrote:
> Hi!
>
> On 2025-04-04 14:36, Tankut Baris Aktemur wrote:
> > Add a '-stopped' option to the "info threads" command to print stopped
> > threads only and skip the running ones. This is a convenience flag to
> > filter out the running threads in programs that have many threads.
> >
> > Suppose we have an application with 5 threads, 2 of which have hit a
> > breakpoint. The "info threads" command in the non-stop mode gives:
> >
> > (gdb) info threads
> > Id Target Id Frame
> > * 1 Thread 0x7ffff7d99740 (running)
> > 2 Thread 0x7ffff7d98700 something () at file.c:30
> > 3 Thread 0x7ffff7597700 (running)
> > 4 Thread 0x7ffff6d96700 something () at file.c:30
> > 5 Thread 0x7ffff6595700 (running)
> > (gdb)
> >
> > Using the "-stopped" flag, we get
> >
> > (gdb) info threads -stopped
> > Id Target Id Frame
> > 2 Thread 0x7ffff7d98700 something () at file.c:30
> > 4 Thread 0x7ffff6d96700 something () at file.c:30
> > (gdb)
> >
> > When combined with a thread ID, the behavior is as follows:
> >
> > (gdb) info threads 3
> > Id Target Id Frame
> > 3 Thread 0x7ffff7597700 (running)
> > (gdb) info threads -stopped 3
> > No stopped threads match '3'.
> > (gdb)
> >
> > Regression-tested on X86_64 Linux.
> >
> > Reviewed-By: Eli Zaretskii <eliz@gnu.org>
> > Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
> > ---
> > gdb/NEWS | 5 +
> > gdb/doc/gdb.texinfo | 6 +-
> > gdb/testsuite/gdb.base/options.exp | 11 +-
> > .../gdb.threads/info-threads-stopped.c | 78 +++++++++++++
> > .../gdb.threads/info-threads-stopped.exp | 107 ++++++++++++++++++
> > gdb/thread.c | 17 ++-
> > 6 files changed, 220 insertions(+), 4 deletions(-)
> > create mode 100644 gdb/testsuite/gdb.threads/info-threads-stopped.c
> > create mode 100644 gdb/testsuite/gdb.threads/info-threads-stopped.exp
> >
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index 6a557bb4af9..d5c55c3c938 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -56,6 +56,11 @@ info sharedlibrary
> > command are now for the full memory range allocated to the shared
> > library.
> >
> > +info threads [-gid] [-stopped] [ID]...
> > + This command now takes an optional flag, '-stopped', that causes only
> > + the stopped threads to be printed. The flag can be useful to get a
> > + reduced list when there is a large number of unstopped threads.
>
>
> Cool!
>
> (I would have added -running too while at it, and make "thread apply -stopped" work too.
>
> And then:
>
> "info threads -stopped -running"
>
> would print both stopped and running.
>
> Same logic as "info lanes -active -inactive" including both active and inactive in
> our offlist discussions.)
Hi Pedro,
Thanks a lot for the thorough review. I'll soon send the next revision.
I also added "-running" per your suggestion, but let's please complete this
series first. I'd like to send "thread apply -stopped" separately.
Thank you.
-Baris
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 Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2025-05-05 16:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 9:19 [PATCH 0/3] Option to show stopped threads only Tankut Baris Aktemur via Gdb-patches
2023-04-05 9:20 ` [PATCH 1/3] gdb: pass info_threads_opts to print_thread_info_1 Tankut Baris Aktemur via Gdb-patches
2023-04-05 9:20 ` [PATCH 2/3] gdb, doc: add the missing '-gid' option to 'info threads' Tankut Baris Aktemur via Gdb-patches
2023-04-05 9:56 ` Eli Zaretskii via Gdb-patches
2023-04-05 10:12 ` Aktemur, Tankut Baris via Gdb-patches
2023-04-05 9:20 ` [PATCH 3/3] gdb: add a '-stopped' option to "info threads" Tankut Baris Aktemur via Gdb-patches
2023-04-05 10:00 ` Eli Zaretskii via Gdb-patches
2023-04-05 10:19 ` Aktemur, Tankut Baris via Gdb-patches
2023-04-05 10:50 ` Eli Zaretskii via Gdb-patches
2023-04-05 11:31 ` Aktemur, Tankut Baris via Gdb-patches
2023-04-05 11:56 ` Eli Zaretskii via Gdb-patches
2025-04-24 14:50 ` Pedro Alves
2025-03-18 18:04 ` [PATCH v2 0/2] Option to show stopped threads only Tankut Baris Aktemur
2025-03-18 18:05 ` [PATCH v2 1/2] gdb: pass info_threads_opts to print_thread_info_1 Tankut Baris Aktemur
2025-03-18 18:05 ` [PATCH v2 2/2] gdb: add a '-stopped' option to "info threads" Tankut Baris Aktemur
2025-03-28 16:38 ` [PATCH v2 0/2] Option to show stopped threads only Guinevere Larsen
2025-04-04 13:39 ` Aktemur, Tankut Baris
2025-04-04 13:36 ` [PATCH v3 " Tankut Baris Aktemur
2025-04-04 13:36 ` [PATCH v3 1/2] gdb: pass info_threads_opts to print_thread_info_1 Tankut Baris Aktemur
2025-04-24 18:09 ` Pedro Alves
2025-04-04 13:36 ` [PATCH v3 2/2] gdb: add a '-stopped' option to "info threads" Tankut Baris Aktemur
2025-04-24 19:23 ` Pedro Alves
2025-05-05 16:17 ` Aktemur, Tankut Baris [this message]
2025-04-23 8:00 ` [PATCH v3 0/2] Option to show stopped threads only Aktemur, Tankut Baris
2025-04-24 17:53 ` Pedro Alves
2025-05-05 16:19 ` [PATCH v4 0/3] Option to show stopped/running " Tankut Baris Aktemur
2025-05-05 16:19 ` [PATCH v4 1/3] gdb: pass info_threads_opts to print_thread_info_1 Tankut Baris Aktemur
2025-05-05 16:19 ` [PATCH v4 2/3] gdb: update "info threads" output when no threads match the arguments Tankut Baris Aktemur
2025-05-05 17:19 ` Eli Zaretskii
2025-05-05 16:19 ` [PATCH v4 3/3] gdb: add '-stopped' and '-running' options to "info threads" Tankut Baris Aktemur
2025-05-05 17:21 ` Eli Zaretskii
2025-05-09 20:54 ` [PATCH v4 0/3] Option to show stopped/running threads only Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM4PR11MB73039958AA69A291435B8026C48E2@DM4PR11MB7303.namprd11.prod.outlook.com \
--to=tankut.baris.aktemur@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
--cc=pedro@palves.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox