Skip to content

Commit 21ef272

Browse files
authored
[lldb/DWARF] Search fallback to the manual index in GetFullyQualified… (#102123)
…Type This is needed to ensure we find a type if its definition is in a CU that wasn't indexed. This can happen if the definition is in some precompiled code (e.g. the c++ standard library) which was built with different flags than the rest of the binary.
1 parent 7727853 commit 21ef272

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
371371
!ProcessEntry(entry, callback))
372372
return;
373373
}
374+
m_fallback.GetFullyQualifiedType(context, callback);
374375
}
375376

376377
bool DebugNamesDWARFIndex::SameParentChain(
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
REQUIRES: lld, python
2+
3+
RUN: split-file %s %t
4+
RUN: %clang --target=x86_64-pc-linux -g -gpubnames -c %t/file1.c -o %t-1.o
5+
RUN: %clang --target=x86_64-pc-linux -g -gno-pubnames -c %t/file2.c -o %t-2.o
6+
RUN: llvm-dwarfdump %t-1.o --debug-names | FileCheck %s --check-prefix=PUBNAMES
7+
RUN: llvm-dwarfdump %t-2.o --debug-names | FileCheck %s --check-prefix=NOPUBNAMES
8+
RUN: ld.lld %t-1.o %t-2.o -o %t.out
9+
RUN: %lldb %t.out -s %t/commands -o exit | FileCheck %s
10+
11+
// Precondition check: The first file should contain a debug_names index, but no
12+
// entries for MYSTRUCT.
13+
PUBNAMES: Name Index @ 0x0 {
14+
PUBNAMES-NOT: MYSTRUCT
15+
16+
// The second file should not contain an index.
17+
NOPUBNAMES-NOT: Name Index
18+
19+
// Starting from the variable in the first file, we should be able to find the
20+
// declaration of the type in the first unit, and then match that with the
21+
// definition in the second unit.
22+
CHECK: (lldb) script
23+
CHECK: struct MYSTRUCT {
24+
CHECK-NEXT: int x;
25+
CHECK-NEXT: }
26+
27+
#--- commands
28+
script lldb.target.FindFirstGlobalVariable("struct_ptr").GetType().GetPointeeType()
29+
#--- file1.c
30+
struct MYSTRUCT *struct_ptr;
31+
#--- file2.c
32+
struct MYSTRUCT {
33+
int x;
34+
};
35+
struct MYSTRUCT struct_;

0 commit comments

Comments
 (0)