Skip to content

Commit ce7fa42

Browse files
committed
fixup! don't create custom label if declaration is from a type-unit
1 parent 16b9675 commit ce7fa42

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
@@ -2496,8 +2496,10 @@ llvm::Error SymbolFileDWARF::FindAndResolveFunction(
24962496
if (entry.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0))
24972497
return true;
24982498

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

0 commit comments

Comments
 (0)