Re: [PATCH 4/6] gdb/dwarf: when in dwarf2_cu, read addr_size from dwarf2_cu::header

Simon Marchi
2025-11-19T20:47:06Z

On 2025-11-19 09:30, Andrew Burgess wrote:
> Simon Marchi <simon.marchi@efficios.com> writes:
>
>> This patch fixes a crash caused by GDB trying to read from a section not
>> read in. The bug happens in those specific circumstances:
>>
>> - reading a type unit from .dwo
>> - that type unit has a stub in the main file
>> - there is a GDB index (.gdb_index) present
>>
>> This crash is the cause of the following test failure:
>>
>> $ Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.dwarf2/fission-reread.exp ...
>> ERROR: GDB process no longer exists
>
> It's probably worth mentioning that this failure only occurs when using
> the cc-with-gdb-index board.

Fixed.

> I would encourage you to consider extending the existing test to cover
> this case without needing to test with the cc-with-gdb-index board. I
> think the reality is most people don't test every patch with every
> board. But I do understand that, if taken to extreme, that would mean
> running every test in every mode, which clearly doesn't scale. But when
> we run into a regression my instinct is to ensure that the default test
> mode covers this case. And there's plenty of precedent for this in the
> testsuite, e.g. gdb.server/*.exp. You're welcome to take the test
> changes from the patch linked above if that is useful.

Good idea, I'll check that.

> Also in the patch linked above is the addition of an assert:
>
> gdb_assert (this->section ()->readin);
>
> in 'dwarf2_per_cu::get_header ()'. I haven't checked the later patches
> from this series yet, so maybe you already do something similar, but if
> not, maybe it would be good to add something like that in this patch,
> given that this is dealing with the assert caused by the section not
> being read in?

Haven't checked the review comments on that patch yet, but the following
patch removes dwarf2_per_cu::get_header.

Thanks,

Simon