Skip to content

Commit a816b65

Browse files
committed
Manual DWARF index: don't skip over -gmodules debug info
This fixes a regression introduced by https://reviews.llvm.org/D131437. The intention of the patch was to avoid indexing DWO skeleton units, but it also skipped over full DWARF compile units linked via a -gmodules DW_AT_dwo_name attribute. This patch restores the functionality and adds a test for it. Differential Revision: https://reviews.llvm.org/D142683
1 parent 639f70c commit a816b65

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,27 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
161161
// though as some functions have template parameter types and other things
162162
// that cause extra copies of types to be included, but we should find these
163163
// types in the .dwo file only as methods could have return types removed and
164-
// we don't have to index incomplete types from the skeletone compile unit.
164+
// we don't have to index incomplete types from the skeleton compile unit.
165165
if (unit.GetDWOId()) {
166166
if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
167167
// Type units in a dwp file are indexed separately, so we just need to
168-
// process the split unit here. However, if the split unit is in a dwo file,
169-
// then we need to process type units here.
168+
// process the split unit here. However, if the split unit is in a dwo
169+
// file, then we need to process type units here.
170170
if (dwo_symbol_file == dwp) {
171171
IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
172172
} else {
173173
DWARFDebugInfo &dwo_info = dwo_symbol_file->DebugInfo();
174174
for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
175175
IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
176176
}
177+
return;
177178
}
178-
} else {
179-
// We either have a normal compile unit which we want to index.
180-
IndexUnitImpl(unit, cu_language, set);
179+
// The unit has a dwo_id, but this isn't a .dwo skeleton unit, so
180+
// the assumption is that this is a file produced by -gmodules and
181+
// that we want to index it.
181182
}
183+
// We have a normal compile unit which we want to index.
184+
IndexUnitImpl(unit, cu_language, set);
182185
}
183186

184187
void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
typedef int anchor_t;
2+
3+
struct TypeFromPCH {
4+
int field;
5+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// UNSUPPORTED: system-windows
2+
3+
// Test that LLDB can follow DWO links produced by -gmodules debug
4+
// info to find a type in a precompiled header.
5+
//
6+
// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header %S/Inputs/pch.h -g -c -o %t.pch
7+
// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c -include-pch %t.pch %s -c -o %t.o
8+
// RUN: %clangxx_host %t.o -o %t.exe
9+
// RUN: lldb-test symbols -dump-clang-ast -find type --language=C99 \
10+
// RUN: -compiler-context 'AnyModule:*,Struct:TypeFromPCH' %t.exe | FileCheck %s
11+
12+
anchor_t anchor;
13+
14+
int main(int argc, char **argv) { return 0; }
15+
16+
// CHECK: Found 1 type
17+
// CHECK: "TypeFromPCH"
18+
// CHECK: FieldDecl {{.*}} field

0 commit comments

Comments
 (0)