================
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+    return llvm::StringRef();
+  return die.GetName(this);
+}
----------------
clayborg wrote:

If the attribute isn't in the current DIE (it is in a `DW_AT_specification` or 
`DW_AT_abstract_origin`), the `DWARFDebugInfoEntry::GetAttributeValue(...)` 
function will just run this code:
```
    if (GetAttributeValue(cu, DW_AT_specification, form_value)) {
      DWARFDIE die = form_value.Reference();
      if (die) {
```
or
```
    if (GetAttributeValue(cu, DW_AT_abstract_origin, form_value)) {
      DWARFDIE die = form_value.Reference();
      if (die) {
```
Both of these go back to the DWARFDIE class which will cause all of the DIEs to 
be parsed in the DWARFUnit anyway. So the peek function will work, it will just 
do a lot more work than you expected. Note that if the `DW_AT_specification` or 
`DW_AT_abstract_origin` attributes can represent a DIE from another compile 
unit of they use the `DW_FORM_ref_addr`, which can point across compile units. 
So it will take some more work to make the `DWARFUnit::PeekDIEName` work and be 
as efficient as needed.

https://github.com/llvm/llvm-project/pull/78486
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to