Re: [PATCH 1/2] gdb/block: remove block_iterator::d::block, remove union

Simon Marchi
2026-02-06T19:01:55Z

On 2026-02-06 11:42, Tom Tromey wrote:
>>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:
>
> Simon> From: Simon Marchi <simon.marchi@efficios.com>
> Simon> The block field is never used. The block is only used to grab a
> Simon> reference to the mdict, which is stored in the mdict_iterator.
>
> Simon> Remove it and remove the union. Leave the compunit_symtab field, whose
> Simon> name unfortunately conflicts with the method.
>
> Seems reasonable to me.
>
> Using an m_ name wouldn't be remiss, we have other cases where we've
> done this but where the field is still "public".
>
> Simon> else
> Simon> {
> Simon> - iter->d.block = block;
> Simon> -
>
> I didn't look to see how the initialization is done, but I wonder if
> this should assign nullptr to the compunit_symtab field.

It could, but I don't think it's necessary. This code path puts the
iterator in FIRST_LOCAL_BLOCK mode (iterate on a single block), and it's
forbidden (protected by the assert added in the following patch) to
access the compunit when in that mode. So it's fine if it stays in an
undefined state.

> Approved-By: Tom Tromey <tom@tromey.com>

Thanks,

Simon