Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Jan Vrany <jan@vrany.io>, gdb-patches@sourceware.org
Subject: Re: [PATCH 4/7] [gdb] Add block::superblocks
Date: Fri, 1 May 2026 15:06:19 +0200	[thread overview]
Message-ID: <c246fc4d-40a7-4b9a-b65e-97a6f93c5708@suse.de> (raw)
In-Reply-To: <68a8fb3fdf0ed5a00262f8d37e31f879b0da214b.camel@vrany.io>

On 4/27/26 1:11 PM, Jan Vrany wrote:
>> Add a function block::superblocks that can be used to transform:
> 
> Hi,
> 
> a nit: shouldn't the commit summary and message say super_blocks (with underscore)?
> 
> 

Hi Jan,

yes, though now I've renamed it to blocks::block_and_superblocks, so 
that's fixed in the v1 ( 
https://sourceware.org/pipermail/gdb-patches/2026-May/227068.html ).

> On Thu, 2026-04-23 at 08:35 +0200, Tom de Vries wrote:
>> Add a function block::superblocks that can be used to transform:
>> ...
>>    while (block != NULL)
>>      {
>>        ...
>>        block = block->superblock ();
>>      }
>> ...
>> into:
>> ...
>>    for (auto b : block::super_blocks (block))
>>      {
>>        ...
>>      }
>> ...
>>
>> I'm not sure about the name.  It might suggest that block is not included in
>> the iteration, but in fact it is.
> 
> 
>> I considered block::block_and_supers () instead, but it seems a bit awkward.
> 
> I'd personally prefer block::block_and_supers over block::super_blocks. It's bit
> awkward, but better awkward than misleading.
> 

Thanks for weighing in.  As mentioned, I've gone with 
blocks::block_and_superblocks, so I hope that's clear enough.

>> ---
>>   gdb/block.h | 36 ++++++++++++++++++++++++++++++++++++
>>   1 file changed, 36 insertions(+)
>>
>> diff --git a/gdb/block.h b/gdb/block.h
>> index 091120ae2b8..4a1db79d7ed 100644
>> --- a/gdb/block.h
>> +++ b/gdb/block.h
>> @@ -108,6 +108,27 @@ struct blockranges
>>
>>   struct block : public allocate_on_obstack<block>
>>   {
>> +  /* Variant of next_iterator using the superblock field instead of next.  */
>> +  struct superblock_iterator : base_next_iterator<const block>
>> +  {
>> +    typedef superblock_iterator self_type;
>> +
>> +    explicit superblock_iterator (value_type item)
>> +      : base_next_iterator (item)
>> +    {
>> +    }
>> +
>> +    superblock_iterator () = default;
>> +
>> +    self_type &operator++ ()
>> +    {
>> +      this->m_item = this->m_item->superblock ();
>> +      return *this;
>> +    }
>> +  };
>> +
>> +  using superblock_range = iterator_range<superblock_iterator>;
>> +
>>     /* Return this block's start address.  */
>>     CORE_ADDR start () const
>>     { return m_start; }
>> @@ -306,6 +327,21 @@ struct block : public allocate_on_obstack<block>
>>
>>     struct dynamic_prop *static_link () const;
>>
>>
> 
> I think comment would be useful here, especially as "super_blocks"
> returns this block AND all its superblocks.
> 

I've added comments in the v1, thanks for pointing this out.

Thanks,
- Tom

>> +  superblock_range super_blocks () const
>> +  {
>> +    superblock_range::iterator begin (this);
>> +
>> +    return superblock_range (std::move (begin));
>> +  }
>> +
>> +  static superblock_range super_blocks (const block *b)
>> +  {
>> +    if (b == nullptr)
>> +      return superblock_range ();
>> +
>> +    return b->super_blocks ();
>> +  }
>> +
> 
> 
> Thanks!
> 
> Jan
> 
> 


  reply	other threads:[~2026-05-01 13:06 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 [this message]
2026-04-30 16:24   ` Simon Marchi
2026-05-01 13:19     ` Tom de Vries
2026-04-23  6:35 ` [PATCH 5/7] [gdb] Use block::super_blocks Tom de Vries
2026-04-24 16:27   ` 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=c246fc4d-40a7-4b9a-b65e-97a6f93c5708@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=jan@vrany.io \
    /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