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

Simon Marchi
2025-11-19T20:51:43Z

On 2025-11-19 11:11, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> I would prefer to not reintroduce the behavior of overwriting the
> Simon> section info in dwarf2_per_cu, because:
>
> Simon> 1. I find it confusing, I like the invariant of dwarf2_per_cu::section
> Simon> points to the stub, and dwarf2_cu::section points to where we
> Simon> actually read the debug info from.
>
> The "overwrite" behavior was super messy and hard to untangle, so +1 to
> getting rid of that.
>
> I was wondering if the new invariant is sufficiently documented. I
> somewhat think the comments in dwarf2_per_cu should be updated to
> explain it. Also while dwarf2_cu::section has a comment, I'm left
> wondering about dwarf2_cu::header.

I have a subsequent patch that updates the comments in dwarf2_per_cu for
the section, offset and length fields. You can get a preview here:

https://review.lttng.org/c/binutils-gdb/+/15628

I could improve the comment of dwarf2_cu::header to say that it always
comes from where we really read the DIEs from (the .dwo file in case of
split DWARF), if that's what you mean. I would need to check that this
is really true.

Simon