<div dir="ltr">Thanks! I've added this as Issue 250130.1:<div><br></div><div><a href="https://dwarfstd.org/issues/250130.1.html">https://dwarfstd.org/issues/250130.1.html</a></div><div><br></div><div>-cary</div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Jan 30, 2025 at 4:01 AM Michael Buch via Dwarf-discuss <<a href="mailto:dwarf-discuss@lists.dwarfstd.org">dwarf-discuss@lists.dwarfstd.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># Allow alternate encoding of DW_AT_object_pointer as a variable index<br>
instead of DIE reference<br>
<br>
## Background<br>
<br>
`DW_AT_object_pointer` is used by LLDB to conveniently determine the<br>
CV-qualifiers<br>
and storage class of C++ member functions when reconstructing types from DWARF.<br>
GCC currently emits `DW_AT_object_pointer` on both declaration and<br>
definition DIEs [1].<br>
Clang does not emit them on declarations, making the LLDB heuristics<br>
to find the object<br>
parameter fragile. We tried attaching `DW_AT_object_pointer` to<br>
declarations in Clang<br>
too [2], but that came at the cost of a ~5-10% increase in the<br>
`.debug_info` section size<br>
for some users, so we reverted it. This proposal describes an<br>
alternate encoding of the<br>
`DW_AT_object_pointer` which allows us to add it to declaration DIEs without<br>
incurring such size overheads.<br>
<br>
## Overview<br>
<br>
The idea is to encode the index of the `DW_TAG_formal_parameter` that is the<br>
object parameter instead of a DIE reference. This index could then be of form<br>
`DW_FORM_implicit_const`, so we don't pay the 4 bytes for each reference,<br>
but instead pay for it once in the abbreviation.<br>
<br>
The implementation in Clang for this is currently being discussed in [3].<br>
<br>
The DWARF spec currently only mentions `reference` as the attribute class<br>
of `DW_AT_object_pointer`. So consumers may be surprised by this alternate<br>
encoding. Hence we thought it'd be good to run this past the committee.<br>
<br>
An alternative solution could be a new attribute describing the object<br>
parameter index (e.g., `DW_AT_object_pointer_index` with a `constant`<br>
attribute class).<br>
<br>
## Proposed Changes<br>
<br>
In chapter "7.5.4 Attribute Encodings", change the "Table 7.5:<br>
Attribute encodings"<br>
table as follows:<br>
<br>
[ORIGINAL TEXT]<br>
>>>>>>>>>>>>>>><br>
Attribute Name                 | Value | Classes<br>
-----------------------------------------------------------------------<br>
...<br>
DW_AT_object_pointer    | 0x64  | reference<br>
...<br>
[NEW TEXT]<br>
==========<br>
Attribute Name                 | Value | Classes<br>
-----------------------------------------------------------------------<br>
...<br>
DW_AT_object_pointer    | 0x64  | reference, constant<br>
...<br>
<<<<<<<<<<<<<<<<br>
<br>
In chapter "5.7.8 Member Function Entries", extend the attribute class<br>
recommendation<br>
as follows:<br>
<br>
[ORIGINAL TEXT]<br>
>>>>>>>>>>>>>>><br>
If the member function entry describes a non-static member function, then that<br>
entry has a DW_AT_object_pointer attribute whose value is a reference to the<br>
formal parameter entry that corresponds to the object for which the function is<br>
called.<br>
[NEW TEXT]<br>
==========<br>
If the member function entry describes a non-static member function, then that<br>
entry has a DW_AT_object_pointer attribute whose value is a reference to the<br>
formal parameter entry that corresponds to the object for which the function is<br>
called. A producer may also choose to represent it as a constant whose value is<br>
the zero-based index of the formal parameter that corresponds to the object<br>
parameter.<br>
<<<<<<<<<<<<<<<<br>
<br>
## References<br>
<br>
* [1]: <a href="https://godbolt.org/z/3TWjTfWon" rel="noreferrer" target="_blank">https://godbolt.org/z/3TWjTfWon</a><br>
* [2]: <a href="https://github.com/llvm/llvm-project/pull/122742" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/pull/122742</a><br>
* [3]: <a href="https://github.com/llvm/llvm-project/pull/124790" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/pull/124790</a><br>
-- <br>
Dwarf-discuss mailing list<br>
<a href="mailto:Dwarf-discuss@lists.dwarfstd.org" target="_blank">Dwarf-discuss@lists.dwarfstd.org</a><br>
<a href="https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss" rel="noreferrer" target="_blank">https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss</a><br>
</blockquote></div>