Skip to content

Commit aeebf1f

Browse files
committed
fixup! don't create custom label if declaration is from a type-unit
1 parent 03fb460 commit aeebf1f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,22 @@ static const char *GetMangledOrStructorName(const DWARFDIE &die) {
279279
}
280280

281281
static std::optional<std::string> MakeLLDBFuncAsmLabel(const DWARFDIE &die) {
282+
const DWARFUnit *cu = die.GetCU();
283+
if (!cu)
284+
return std::nullopt;
285+
286+
// FIXME: Workaround for when the declaration DIE for a method is in a
287+
// type-unit. The definition DIE's specification points to the declaration DIE
288+
// in the compile-unit, so if we encoded the DIE from the type-unit, the DIEs
289+
// wouldn't match and the label decoder would error out.
290+
if (die.IsMethod() && cu->IsTypeUnit()) {
291+
const char *mangled = die.GetMangledName(/*substitute_name_allowed=*/false);
292+
if (!mangled)
293+
return std::nullopt;
294+
295+
return mangled;
296+
}
297+
282298
const char *name = GetMangledOrStructorName(die);
283299
if (!name)
284300
return std::nullopt;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,8 +2497,10 @@ llvm::Error SymbolFileDWARF::FindAndResolveFunction(
24972497
if (entry.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0))
24982498
return true;
24992499

2500-
// TODO: this specification check doesn't work if declaration DIE was in a
2501-
// type-unit (we should only encode DIEs from .debug_info).
2500+
// FIXME: this specification check doesn't work if declaration DIE was in a
2501+
// type-unit. We currently work around this by only creating the
2502+
// LLDB function call labels when the declaration DIE was *not* in a
2503+
// type-unit.
25022504
auto spec = entry.GetAttributeValueAsReferenceDIE(DW_AT_specification);
25032505
if (!spec)
25042506
return true;

0 commit comments

Comments
 (0)