[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 17 11:05:18 PST 2024


================
@@ -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:

One option here is to check if all of the DIEs have been already parsed in the DWARFUnit and if so, grab the existing DIE, and if it hasn't been parsed do this. 

This approach doesn't take care of cases where the current DIE doesn't have a `DW_AT_name`, but it has a `DW_AT_specification` or `DW_AT_abstract_origin` attribute that points to another DIE that does have a name. In this case we will get no name back from this function because it doesn't recurse into the `DW_AT_specification` or `DW_AT_abstract_origin` die.

https://github.com/llvm/llvm-project/pull/78486


More information about the lldb-commits mailing list