Author: Adrian Prantl
Date: 2020-05-06T16:46:22-07:00
New Revision: 01fc85dc9618394868b795c5087d9da03df9c58b

URL: 
https://github.com/llvm/llvm-project/commit/01fc85dc9618394868b795c5087d9da03df9c58b
DIFF: 
https://github.com/llvm/llvm-project/commit/01fc85dc9618394868b795c5087d9da03df9c58b.diff

LOG: 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>

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index f9a4a68c5fec..6d22fbe2e2ee 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -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 
diff erent 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};
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index e8b9b1643ee5..0b532050f855 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -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)

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 729a5303abef..06f0d48c04ca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -57,14 +57,10 @@ class SymbolFileDWARFDebugMap : public 
lldb_private::SymbolFile {
   // 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(

diff  --git a/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
index bbcdb85bc903..ac2c9fed9445 100644
--- a/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
@@ -70,7 +70,10 @@ TEST_F(XcodeSDKModuleTests, TestModuleGetXcodeSDK) {
   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


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to