Skip to content

Commit 54c1c1e

Browse files
committed
ParseXcodeSDK: Register both the CU module and the SymbolFile module.
For Swift LLDB (but potentially also for module support in Clang-land) we need a way to accumulate the path remappings produced by Module::RegisterXcodeSDK(). In order to make this work for SymbolFileDebugMaps, registering the search path remapping with both modules is necessary. Differential Revision: https://reviews.llvm.org/D79384 <rdar://problem/62750529> (cherry picked from commit 01fc85d)
1 parent 5d6bcae commit 54c1c1e

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,6 @@ XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
842842
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
843843
if (!dwarf_cu)
844844
return {};
845-
ModuleSP module_sp = m_objfile_sp->GetModule();
846-
if (!module_sp)
847-
return {};
848845
const DWARFBaseDIE cu_die = dwarf_cu->GetNonSkeletonUnit().GetUnitDIEOnly();
849846
if (!cu_die)
850847
return {};
@@ -853,7 +850,18 @@ XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
853850
return {};
854851
const char *sysroot =
855852
cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
856-
module_sp->RegisterXcodeSDK(sdk, sysroot);
853+
// Register the sysroot path remapping with the module belonging to
854+
// the CU as well as the one belonging to the symbol file. The two
855+
// would be different if this is an OSO object and module is the
856+
// corresponding debug map, in which case both should be updated.
857+
ModuleSP module_sp = comp_unit.GetModule();
858+
if (module_sp)
859+
module_sp->RegisterXcodeSDK(sdk, sysroot);
860+
861+
ModuleSP local_module_sp = m_objfile_sp->GetModule();
862+
if (local_module_sp && local_module_sp != module_sp)
863+
local_module_sp->RegisterXcodeSDK(sdk, sysroot);
864+
857865
return {sdk};
858866
}
859867

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,7 @@ SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) {
630630
return eLanguageTypeUnknown;
631631
}
632632

633-
XcodeSDK
634-
SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
633+
XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
635634
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
636635
SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
637636
if (oso_dwarf)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile {
5757
// Compile Unit function calls
5858
lldb::LanguageType
5959
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
60-
6160
lldb_private::XcodeSDK
6261
ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
63-
6462
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
65-
6663
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
67-
6864
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
6965

7066
bool ForEachExternalModule(

lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ TEST_F(XcodeSDKModuleTests, TestModuleGetXcodeSDK) {
7070
SymbolFileDWARF &sym_file = dwarf_cu->GetSymbolFileDWARF();
7171
CompUnitSP comp_unit = sym_file.GetCompileUnitAtIndex(0);
7272
ASSERT_TRUE((bool)comp_unit.get());
73+
ModuleSP module = t.GetModule();
74+
ASSERT_EQ(module->GetSourceMappingList().GetSize(), 0u);
7375
XcodeSDK sdk = sym_file.ParseXcodeSDK(*comp_unit);
7476
ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX);
77+
ASSERT_EQ(module->GetSourceMappingList().GetSize(), 1u);
7578
}
7679
#endif

0 commit comments

Comments
 (0)