From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/7] [gdb] Use block::super_blocks
Date: Thu, 23 Apr 2026 08:35:28 +0200 [thread overview]
Message-ID: <20260423063530.1074175-6-tdevries@suse.de> (raw)
In-Reply-To: <20260423063530.1074175-1-tdevries@suse.de>
Use block::super_blocks in a few locations to simplify code.
---
gdb/ada-lang.c | 9 +++------
gdb/symmisc.c | 9 ++++-----
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 71a338ce17e..da6c3b04dd9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13825,9 +13825,7 @@ class ada_language : public language_defn
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (const block *b = get_selected_block (0);
- b != nullptr;
- b = b->superblock ())
+ for (auto b : block::super_blocks (get_selected_block (0)))
{
if (b->is_static_block ())
surrounding_static_block = b; /* For elmin of dups */
@@ -13852,9 +13850,8 @@ class ada_language : public language_defn
auto callback = [&] (compunit_symtab *s)
{
QUIT;
- for (const block *b = s->blockvector ()->static_block ();
- b != nullptr;
- b = b->superblock ())
+ for (auto b
+ : block::super_blocks (s->blockvector ()->static_block ()))
{
/* Don't do this block twice. */
if (b == surrounding_static_block)
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 89374bd8a2f..5a34986ebc2 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -961,11 +961,10 @@ block_depth (const struct block *block)
{
int i = 0;
- while ((block = block->superblock ()) != NULL)
- {
- i++;
- }
- return i;
+ for (auto b [[maybe_unused]]: block::super_blocks (block))
+ i++;
+
+ return i - 1;
}
\f
--
2.51.0
next prev parent reply other threads:[~2026-04-23 6:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 6:35 [PATCH 0/7] [gdb] Add superblocks range loops Tom de Vries
2026-04-23 6:35 ` [PATCH 1/7] [gdb] Use block::function_block Tom de Vries
2026-04-23 14:33 ` Tom Tromey
2026-04-24 12:19 ` Tom de Vries
2026-04-23 6:35 ` [PATCH 2/7] [gdbsupport] Add parameterless iterator_range constructor Tom de Vries
2026-04-23 14:34 ` Tom Tromey
2026-04-24 12:20 ` Tom de Vries
2026-04-23 6:35 ` [PATCH 3/7] [gdbsupport] Factor out base_next_iterator Tom de Vries
[not found] ` <87340kpbwx.fsf@tromey.com>
2026-04-30 4:49 ` Tom de Vries
2026-05-01 12:54 ` Tom de Vries
2026-05-01 13:00 ` Tom de Vries
2026-04-30 16:24 ` Simon Marchi
2026-04-30 19:09 ` Simon Marchi
2026-05-01 12:57 ` Tom Tromey
2026-05-01 13:20 ` Tom de Vries
2026-05-01 13:15 ` Tom de Vries
2026-04-23 6:35 ` [PATCH 4/7] [gdb] Add block::superblocks Tom de Vries
2026-04-27 11:11 ` Jan Vrany
2026-05-01 13:06 ` Tom de Vries
2026-04-30 16:24 ` Simon Marchi
2026-05-01 13:19 ` Tom de Vries
2026-04-23 6:35 ` Tom de Vries [this message]
2026-04-24 16:27 ` [PATCH 5/7] [gdb] Use block::super_blocks Tom Tromey
2026-04-24 21:24 ` Tom de Vries
2026-04-23 6:35 ` [PATCH 6/7] [gdb] Add block::function_blocks Tom de Vries
2026-04-23 6:35 ` [PATCH 7/7] [gdb] Use block::function_blocks Tom de Vries
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=20260423063530.1074175-6-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/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