[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Wed May 29 15:39:35 PDT 2024
https://github.com/clayborg updated https://github.com/llvm/llvm-project/pull/91808
>From 0cc1be6988e6ab5498151f32485f525a66133be2 Mon Sep 17 00:00:00 2001
From: Greg Clayton <clayborg at gmail.com>
Date: Fri, 10 May 2024 13:49:22 -0700
Subject: [PATCH 1/2] Improve performance of .debug_names lookups when
DW_IDX_parent attributes are used.
When a .debug_names table has entries that use the DW_IDX_parent attributes, we can end up with entries in the .debug_names table that are not full definitions. This is because a class that is foward declared, can contain types. For example:
0x0090cdbf: DW_TAG_compile_unit
DW_AT_producer ("clang version 15.0.7")
DW_AT_language (DW_LANG_C_plus_plus_14)
DW_AT_name ("UniqueInstance.cpp")
0x0090cdc7: DW_TAG_namespace
DW_AT_name ("std")
0x0090cdd5: DW_TAG_class_type
DW_AT_name ("ios_base")
DW_AT_declaration (true)
0x0090cdd7: DW_TAG_class_type
DW_AT_name ("Init")
DW_AT_declaration (true)
0x0090cdda: DW_TAG_typedef
DW_AT_type (0x0090ce4e "std::_Ios_Seekdir")
DW_AT_name ("seekdir")
DW_AT_decl_file (0x11)
DW_AT_decl_line (479)
0x0090cde4: DW_TAG_typedef
DW_AT_type (0x0090ce45 "std::_Ios_Openmode")
DW_AT_name ("openmode")
DW_AT_decl_file (0x11)
DW_AT_decl_line (447)
0x0090cdee: DW_TAG_typedef
DW_AT_type (0x0090ce3c "std::_Ios_Iostate")
DW_AT_name ("iostate")
DW_AT_decl_file (0x11)
DW_AT_decl_line (416)
0x0090cdf8: NULL
"std::ios_base" is forward declared and it contains typedefs whose entries in the .debug_names table will point to the DIE at offset 0x0090cdd5. These entries cause our type lookups to try and parse a TON of forward declarations and waste time and resources.
This fix makes sure when/if we find an entry in the .debug_names table, we don't process it if it has a DW_AT_declaration(true) attribute.
---
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 4da0d56fdcacb..eaa9f591ffd41 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -83,6 +83,10 @@ bool DebugNamesDWARFIndex::ProcessEntry(
DWARFDIE die = dwarf.GetDIE(*ref);
if (!die)
return true;
+ // Watch out for forward declarations that appear in the .debug_names tables
+ // only due to being there for a DW_IDX_parent.
+ if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
+ return true;
return callback(die);
}
>From 8faad14da0aac8d207db293333893c5e089a6151 Mon Sep 17 00:00:00 2001
From: Greg Clayton <clayborg at gmail.com>
Date: Wed, 29 May 2024 15:39:02 -0700
Subject: [PATCH 2/2] Fix comment as suggested.
---
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index eaa9f591ffd41..0c7170c0025e0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -83,8 +83,8 @@ bool DebugNamesDWARFIndex::ProcessEntry(
DWARFDIE die = dwarf.GetDIE(*ref);
if (!die)
return true;
- // Watch out for forward declarations that appear in the .debug_names tables
- // only due to being there for a DW_IDX_parent.
+ // Clang erroneously emits index entries for declaration DIEs in case when the
+ // definition is in a type unit (llvm.org/pr77696). Weed those out.
if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
return true;
return callback(die);
More information about the lldb-commits
mailing list