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>
This commit is contained in:
Adrian Prantl 2020-05-06 10:34:51 -07:00
parent d71c3c425c
commit 01fc85dc96
4 changed files with 16 additions and 10 deletions

View File

@ -777,9 +777,6 @@ XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
if (!dwarf_cu)
return {};
ModuleSP module_sp = m_objfile_sp->GetModule();
if (!module_sp)
return {};
const DWARFBaseDIE cu_die = dwarf_cu->GetNonSkeletonUnit().GetUnitDIEOnly();
if (!cu_die)
return {};
@ -788,7 +785,18 @@ XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
return {};
const char *sysroot =
cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
module_sp->RegisterXcodeSDK(sdk, sysroot);
// Register the sysroot path remapping with the module belonging to
// the CU as well as the one belonging to the symbol file. The two
// would be different if this is an OSO object and module is the
// corresponding debug map, in which case both should be updated.
ModuleSP module_sp = comp_unit.GetModule();
if (module_sp)
module_sp->RegisterXcodeSDK(sdk, sysroot);
ModuleSP local_module_sp = m_objfile_sp->GetModule();
if (local_module_sp && local_module_sp != module_sp)
local_module_sp->RegisterXcodeSDK(sdk, sysroot);
return {sdk};
}

View File

@ -628,8 +628,7 @@ SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) {
return eLanguageTypeUnknown;
}
XcodeSDK
SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
if (oso_dwarf)

View File

@ -57,14 +57,10 @@ public:
// Compile Unit function calls
lldb::LanguageType
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
lldb_private::XcodeSDK
ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
bool ForEachExternalModule(

View File

@ -70,7 +70,10 @@ debug_info:
SymbolFileDWARF &sym_file = dwarf_cu->GetSymbolFileDWARF();
CompUnitSP comp_unit = sym_file.GetCompileUnitAtIndex(0);
ASSERT_TRUE((bool)comp_unit.get());
ModuleSP module = t.GetModule();
ASSERT_EQ(module->GetSourceMappingList().GetSize(), 0u);
XcodeSDK sdk = sym_file.ParseXcodeSDK(*comp_unit);
ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX);
ASSERT_EQ(module->GetSourceMappingList().GetSize(), 1u);
}
#endif