Skip to content

Manual DWARF index: don't skip over -gmodules debug info #6146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,27 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
// though as some functions have template parameter types and other things
// that cause extra copies of types to be included, but we should find these
// types in the .dwo file only as methods could have return types removed and
// we don't have to index incomplete types from the skeletone compile unit.
// we don't have to index incomplete types from the skeleton compile unit.
if (unit.GetDWOId()) {
if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
// Type units in a dwp file are indexed separately, so we just need to
// process the split unit here. However, if the split unit is in a dwo file,
// then we need to process type units here.
// process the split unit here. However, if the split unit is in a dwo
// file, then we need to process type units here.
if (dwo_symbol_file == dwp) {
IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
} else {
DWARFDebugInfo &dwo_info = dwo_symbol_file->DebugInfo();
for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
}
return;
}
} else {
// We either have a normal compile unit which we want to index.
IndexUnitImpl(unit, cu_language, set);
// The unit has a dwo_id, but this isn't a .dwo skeleton unit, so
// the assumption is that this is a file produced by -gmodules and
// that we want to index it.
}
// We have a normal compile unit which we want to index.
IndexUnitImpl(unit, cu_language, set);
}

void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def setUp(self):
self.main_source_spec = lldb.SBFileSpec(self.main_source)

@swiftTest
@expectedFailureAll(oslist=['linux'], bugnumber='rdar://104671405')
def test_swift_regex(self):
"""Test that C types with builtin metadata emitted are looked up using
external type info provider."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def build(self):
@skipIf(oslist=['windows'])
# We delete the pch that would contains the debug info as part of the setup.
#@skipIf(debug_info=no_match(["dsym"]))
@expectedFailureAll(oslist=['linux'], bugnumber='rdar://104670979')
@swiftTest
def test_dwarf_importer(self):
lldb.SBDebugger.MemoryPressureDetected()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def build(self):
@swiftTest
# This test needs a working Remote Mirrors implementation.
@skipIf(oslist=['windows'])
@expectedFailureAll(oslist=['linux'], bugnumber='rdar://104670979')
def test_dwarf_importer(self):
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
Expand Down Expand Up @@ -67,7 +66,6 @@ def test_dwarf_importer(self):
@swiftTest
# This test needs a working Remote Mirrors implementation.
@skipIf(oslist=['windows'])
@expectedFailureAll(oslist=['linux'], bugnumber='rdar://104670979')
def test_dwarf_importer_exprs(self):
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
Expand Down
5 changes: 5 additions & 0 deletions lldb/test/Shell/SymbolFile/DWARF/Inputs/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
typedef int anchor_t;

struct TypeFromPCH {
int field;
};
18 changes: 18 additions & 0 deletions lldb/test/Shell/SymbolFile/DWARF/clang-gmodules-type-lookup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// UNSUPPORTED: system-windows

// Test that LLDB can follow DWO links produced by -gmodules debug
// info to find a type in a precompiled header.
//
// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c-header %S/Inputs/pch.h -g -c -o %t.pch
// RUN: %clangxx_host -g -gmodules -fmodules -std=c99 -x c -include-pch %t.pch %s -c -o %t.o
// RUN: %clangxx_host %t.o -o %t.exe
// RUN: lldb-test symbols -dump-clang-ast -find type --language=C99 \
// RUN: -compiler-context 'AnyModule:*,Struct:TypeFromPCH' %t.exe | FileCheck %s

anchor_t anchor;

int main(int argc, char **argv) { return 0; }

// CHECK: Found 1 type
// CHECK: "TypeFromPCH"
// CHECK: FieldDecl {{.*}} field