Re: [PATCH v2 23/42] Add dwarf2_per_objfile to dwarf_expr_context and dwarf2_frame_cache

Simon Marchi
2020-05-28T01:44:36Z

On 2020-05-25 3:50 p.m., Simon Marchi wrote:
> On 2020-05-22 5:04 p.m., Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>>
>> Simon> *Note*, there's one spot I'm particularly unsure about. In
>> Simon> dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value, we would save and
>> Simon> overwrite the offset value in the context, along with a bunch of other
>> Simon> state. This is because we might be about to evaluate something in a
>> Simon> different CU that the current one. If the two CUs are in the same
>> Simon> objfile, then the text_offset is the same, as it's a property of the
>> Simon> objfile. However, if the two CUs are possibly in different objfiles,
>> Simon> then it means the text_offsets are different. It would also mean we
>> Simon> would need to save and restore the dwarf2_per_objfile in the context.
>> Simon> Is that even possible?
>>
>> Unfortunately I don't know for sure.
>> However, call_site_for_pc doesn't distinguish between objfiles. So, I
>> suppose I would assume it is possible.
>>
>> Tom
>
> In practice, I'm not sure how that can happen. Can DWARF info in an objfile
> refer to the DWARF info in another objfile? Can there be a subprogram described
> in one and a call site of that subprogram described in another objfile? If we
> are quite sure it can't happen, I would rather not include code for it, that's
> just unnecessary complexity.
>
> A further patch (28/42) happens to tie call sites with an objfile, and adds a
> gdb_assert here making sure that the call site's objfile is the same as the
> callee's objfile.
>
> So I would propose to leave that gdb_assert there, if we are wrong then we'll
> fix that function.

So it turns out that it wasn't there for nothing! Call sites can refer to another
objfile in some occasions. See the follow up in this thread:

https://sourceware.org/pipermail/gdb-patches/2020-May/169077.html

Simon