Skip to content

Commit 4422a08

Browse files
Merge pull request #6156 from adrian-prantl/D142683
Replace temporary patch with llvm.org version
2 parents 6b91728 + a0db373 commit 4422a08

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ class DWARFUnit : public lldb_private::UserID {
222222

223223
uint8_t GetUnitType() const { return m_header.GetUnitType(); }
224224
bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
225+
/// Note that this check only works for DWARF5+.
226+
bool IsSkeletonUnit() const { return GetUnitType() == llvm::dwarf::DW_UT_skeleton; }
225227

226228
llvm::Optional<uint64_t> GetStringOffsetSectionItem(uint32_t index) const;
227229

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
163163
// types in the .dwo file only as methods could have return types removed and
164164
// we don't have to index incomplete types from the skeleton compile unit.
165165
if (unit.GetDWOId()) {
166+
// Index the .dwo or dwp instead of the skeleton unit.
166167
if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
167168
// Type units in a dwp file are indexed separately, so we just need to
168169
// process the split unit here. However, if the split unit is in a dwo
@@ -176,9 +177,17 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
176177
}
177178
return;
178179
}
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.
180+
// This was a DWARF5 skeleton CU and the .dwo file couldn't be located.
181+
if (unit.GetVersion() >= 5 && unit.IsSkeletonUnit())
182+
return;
183+
184+
// Either this is a DWARF 4 + fission CU with the .dwo file
185+
// missing, or it's a -gmodules pch or pcm. Try to detect the
186+
// latter by checking whether the first DIE is a DW_TAG_module.
187+
// If it's a pch/pcm, continue indexing it.
188+
if (unit.GetDIE(unit.GetFirstDIEOffset()).GetFirstChild().Tag() !=
189+
llvm::dwarf::DW_TAG_module)
190+
return;
182191
}
183192
// We have a normal compile unit which we want to index.
184193
IndexUnitImpl(unit, cu_language, set);

lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Test that LLDB can follow DWO links produced by -gmodules debug
44
// info to find a type in a precompiled header.
5-
//
5+
//
66
// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header %S/Inputs/pch.h -g -c -o %t.pch
77
// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c -include-pch %t.pch %s -c -o %t.o
88
// RUN: %clangxx_host %t.o -o %t.exe
@@ -15,4 +15,4 @@ int main(int argc, char **argv) { return 0; }
1515

1616
// CHECK: Found 1 type
1717
// CHECK: "TypeFromPCH"
18-
// CHECK: FieldDecl {{.*}} field
18+
// CHECK: FieldDecl {{.*}} field

0 commit comments

Comments
 (0)