Skip to content

Commit ddf40e0

Browse files
authored
[lldb] Correctly reconstruct simplified names for type units (llvm#107240)
We need to resolve the type signature to get a hold of the template argument dies. The associated test case passes even without this patch, but it only does it by accident (because the subsequent code considers the types to be in an anonymous namespace and this not subject to uniqueing). This will change once my other patch starts resolving names correctly.
1 parent 24267a7 commit ddf40e0

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class DWARFASTParser {
5858
virtual void EnsureAllDIEsInDeclContextHaveBeenParsed(
5959
CompilerDeclContext decl_context) = 0;
6060

61-
virtual std::string GetDIEClassTemplateParams(const DWARFDIE &die) = 0;
61+
virtual std::string GetDIEClassTemplateParams(DWARFDIE die) = 0;
6262

6363
static std::optional<SymbolFile::ArrayInfo>
6464
ParseChildArrayInfo(const DWARFDIE &parent_die,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,10 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
818818
&attrs.decl, clang_type, resolve_state, payload);
819819
}
820820

821-
std::string
822-
DWARFASTParserClang::GetDIEClassTemplateParams(const DWARFDIE &die) {
821+
std::string DWARFASTParserClang::GetDIEClassTemplateParams(DWARFDIE die) {
822+
if (DWARFDIE signature_die = die.GetReferencedDIE(DW_AT_signature))
823+
die = signature_die;
824+
823825
if (llvm::StringRef(die.GetName()).contains("<"))
824826
return {};
825827

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
106106
/// \return A string, including surrounding '<>', of the template parameters.
107107
/// If the DIE's name already has '<>', returns an empty string because
108108
/// it's assumed that the caller is using the DIE name anyway.
109-
std::string GetDIEClassTemplateParams(
110-
const lldb_private::plugin::dwarf::DWARFDIE &die) override;
109+
std::string
110+
GetDIEClassTemplateParams(lldb_private::plugin::dwarf::DWARFDIE die) override;
111111

112112
void MapDeclDIEToDefDIE(const lldb_private::plugin::dwarf::DWARFDIE &decl_die,
113113
const lldb_private::plugin::dwarf::DWARFDIE &def_die);

lldb/test/Shell/SymbolFile/DWARF/x86/type-definition-search.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44

55
// REQUIRES: lld
66

7-
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-a.o -g -gsimple-template-names -DFILE_A
8-
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-b.o -g -gsimple-template-names -DFILE_B
9-
// RUN: ld.lld %t-a.o %t-b.o -o %t
10-
// RUN: %lldb %t -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
11-
12-
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-a.o -g -fdebug-types-section -DFILE_A
13-
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-b.o -g -fdebug-types-section -DFILE_B
14-
// RUN: ld.lld %t-a.o %t-b.o -o %t
15-
// RUN: %lldb %t -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
7+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-n-a.o -g -gsimple-template-names -DFILE_A
8+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-n-b.o -g -gsimple-template-names -DFILE_B
9+
// RUN: ld.lld %t-n-a.o %t-n-b.o -o %t-n
10+
// RUN: %lldb %t-n -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
11+
12+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-t-a.o -g -fdebug-types-section -DFILE_A
13+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-t-b.o -g -fdebug-types-section -DFILE_B
14+
// RUN: ld.lld %t-t-a.o %t-t-b.o -o %t-t
15+
// RUN: %lldb %t-t -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
16+
17+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-tn-a.o -g -fdebug-types-section -gsimple-template-names -DFILE_A
18+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-tn-b.o -g -fdebug-types-section -gsimple-template-names -DFILE_B
19+
// RUN: ld.lld %t-tn-a.o %t-tn-b.o -o %t-tn
20+
// RUN: %lldb %t-tn -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
1621

1722
// CHECK: (lldb) target variable
1823
// CHECK-NEXT: (ReferencesBoth<'A'>) both_a = {

0 commit comments

Comments
 (0)