Skip to content

Commit b922242

Browse files
[lldb][DWARFUnit] Implement PeekDIEName query
This allows us to not parse the entire DIE.
1 parent d0a2150 commit b922242

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
191191
return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
192192
return DWARFDIE(); // Not found
193193
}
194+
195+
llvm::StringRef
196+
DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
197+
if(DWARFUnit *cu = GetUnit(die_ref))
198+
return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
199+
return llvm::StringRef();
200+
}

lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
4343
bool ContainsTypeUnits();
4444
DWARFDIE GetDIE(const DIERef &die_ref);
4545

46+
/// Returns the AT_Name of this DIE, if it exists, without parsing the entire
47+
/// compile unit. An empty is string is returned upon error or if the
48+
/// attribute is not present.
49+
llvm::StringRef PeekDIEName(const DIERef &die_ref);
50+
4651
enum {
4752
eDumpFlag_Verbose = (1 << 0), // Verbose dumping
4853
eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
663663
return DWARFDIE(); // Not found
664664
}
665665

666+
llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
667+
const DWARFDataExtractor &data = GetData();
668+
DWARFDebugInfoEntry die;
669+
if (!die.Extract(data, this, &die_offset))
670+
return llvm::StringRef();
671+
return die.GetName(this);
672+
}
673+
666674
DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
667675
ExtractUnitDIEIfNeeded();
668676
if (m_dwo)

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
187187

188188
DWARFDIE GetDIE(dw_offset_t die_offset);
189189

190+
/// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
191+
/// parsing the entire compile unit. An empty is string is returned upon
192+
/// error or if the attribute is not present.
193+
llvm::StringRef PeekDIEName(dw_offset_t die_offset);
194+
190195
DWARFUnit &GetNonSkeletonUnit();
191196

192197
static uint8_t GetAddressByteSize(const DWARFUnit *cu);

0 commit comments

Comments
 (0)