Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/7] [gdbsupport] Factor out base_next_iterator
Date: Fri, 1 May 2026 15:20:57 +0200	[thread overview]
Message-ID: <43ea8c40-2938-420b-98ba-24eef1241d9c@suse.de> (raw)
In-Reply-To: <d334adca-137d-4eb4-9724-972c7ac23d47@simark.ca>

On 4/30/26 9:09 PM, Simon Marchi wrote:
> On 4/30/26 12:24 PM, Simon Marchi wrote:
>> Rather than copy paste what I mean here, I pushed what I think it could
>> look like to the users/simark/next-iterator branch.
>>
>> https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/simark/next-iterator
>> https://sourceware.org/cgit/binutils-gdb/log/?h=users/simark/next-iterator
>>
>> But just to illustrate here is how the function block iterator and
>> range are implemented:
>>
>>    /* Iterator and range type to iterate over this block and its superblocks
>>       within a function.  */
>>
>>    struct function_block_incrementer
>>    {
>>      const block *operator() (const block &b) const noexcept
>>      {
>>        /* If the current item is the function-defining block, we're done.  */
>>        if (b.function () != nullptr)
>> 	return nullptr;
>>
>>        return b.superblock ();
>>      }
>>    };
>>
>>    using function_block_iterator
>>      = base_next_iterator<const block, function_block_incrementer>;
>>    using function_block_range = iterator_range<function_block_iterator>;
> 
> Just a note: in your version, if you pass a global or static block to
> function_block_iterator, it sets the item to nullptr right away, so you
> iterate on nothing.  I couldn't do that in my version, so I chose to
> assert that the block isn't global or static, which puts the
> responsibillity on the caller not to call this on a global or static
> block.  The only caller is in ada-lang.c, it passes the result of
> get_frame_block().  I guess that a block from a frame is always in a
> function (is not the global or static block), but if that assumption
> isn't true, then a check would be needed in the caller.

I think letting the iterator sort this out is the better option.

Thanks,
- Tom

  parent reply	other threads:[~2026-05-01 13:21 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 [this message]
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 ` [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=43ea8c40-2938-420b-98ba-24eef1241d9c@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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