Re: [PATCH 16/43] Simplify dwarf_expr_context class interface

Simon Marchi via Gdb-patches
2021-04-28T19:19:17Z

On 2021-04-28 11:39 a.m., Zoran Zaric wrote:>
>>>
>>> This was more me venting about that particular design choice
>>
>> Haha, it indeed did feel this way.
>>
>>> because the reality is that an address size has to be consistent with what is defined in the original object file but there is no interface to always get it in a clean way in gdb.
>>
>> In this case, it looks like it's because an expression can come from a
>> DIE attribute, directly linked to a CU. So the address size comes from
>> that CU's header. And at other times, the expression comes from a frame
>> description entry (FDE) / common information entry (CIE), so the address
>> size comes from that CIE's header. So I don't see any other easy way than
>> making the caller provide it.
>>
>>> It makes sense for me to remove that comment altogether in the next iteration and thing about a future change that would clean it up.
>>
>> Ok. Or, just make a simple comment. You could say that ADDRESS_SIZE is
>> the address size coming from the CU's header or the CIE's header,
>> depending on the context.
>
> Right, but all these sources come from a single object file and by the standard they all need to be consistent, otherwise things couldn't really work.
>
>>
>> Anyway, this is all perhaps subject to change if I understand correctly.
>> In the end do you still expose a class, or just one function, to
>> evaluate a DWARF expression?
>>
>> Simon
>>
>
> Right, and ideally, because the per_objfile always has to be present, it would make sense that it also contains the address size information that should get it from any header that is present in that objfile and if there are more then one, they should all be consistent.
>
> Does this makes sense?

Yeah, I suppose. In DWARF5, it says that about the address_size field
of the CIE header:

If a compilation unit exists for this frame, its address size must
match the address size here.

In any case, It's not a big problem for now I think to pass in the
address size.

Simon