[Lldb-commits] [PATCH] D49685: LLDB does not respect platform sysroot when loading core on Linux

Eugene Birukov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 24 11:21:33 PDT 2018


EugeneBi updated this revision to Diff 157088.
EugeneBi added a comment.

Rebased to recent master.
Included the whole file in diff.


https://reviews.llvm.org/D49685

Files:
  include/lldb/Core/ModuleList.h
  source/Core/ModuleList.cpp
  source/Target/Platform.cpp


Index: source/Target/Platform.cpp
===================================================================
--- source/Target/Platform.cpp
+++ source/Target/Platform.cpp
@@ -226,13 +226,14 @@
   if (IsHost())
     return ModuleList::GetSharedModule(
         module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
-        did_create_ptr, false);
+        did_create_ptr, false, m_sdk_sysroot.AsCString());
 
   return GetRemoteSharedModule(module_spec, process, module_sp,
                                [&](const ModuleSpec &spec) {
                                  Status error = ModuleList::GetSharedModule(
                                      spec, module_sp, module_search_paths_ptr,
-                                     old_module_sp_ptr, did_create_ptr, false);
+                                     old_module_sp_ptr, did_create_ptr, false,
+                                     m_sdk_sysroot.AsCString());
                                  if (error.Success() && module_sp)
                                    module_sp->SetPlatformFileSpec(
                                        spec.GetFileSpec());
Index: source/Core/ModuleList.cpp
===================================================================
--- source/Core/ModuleList.cpp
+++ source/Core/ModuleList.cpp
@@ -770,7 +770,11 @@
                                    ModuleSP &module_sp,
                                    const FileSpecList *module_search_paths_ptr,
                                    ModuleSP *old_module_sp_ptr,
-                                   bool *did_create_ptr, bool always_create) {
+                                   bool *did_create_ptr, bool always_create,
+                                   const char* sysroot) {
+  // Make sure no one else can try and get or create a module while this
+  // function is actively working on it by doing an extra lock on the
+  // global mutex list.
   ModuleList &shared_module_list = GetSharedModuleList();
   std::lock_guard<std::recursive_mutex> guard(
       shared_module_list.m_modules_mutex);
@@ -789,9 +793,6 @@
   const FileSpec &module_file_spec = module_spec.GetFileSpec();
   const ArchSpec &arch = module_spec.GetArchitecture();
 
-  // Make sure no one else can try and get or create a module while this
-  // function is actively working on it by doing an extra lock on the global
-  // mutex list.
   if (!always_create) {
     ModuleList matching_module_list;
     const size_t num_matching_modules =
@@ -825,7 +826,11 @@
   if (module_sp)
     return error;
 
-  module_sp.reset(new Module(module_spec));
+  auto resolved_module_spec(module_spec);
+  if (sysroot != nullptr)
+    resolved_module_spec.GetFileSpec().PrependPathComponent(sysroot);
+
+  module_sp.reset(new Module(resolved_module_spec));
   // Make sure there are a module and an object file since we can specify a
   // valid file path with an architecture that might not be in that file. By
   // getting the object file we can guarantee that the architecture matches
Index: include/lldb/Core/ModuleList.h
===================================================================
--- include/lldb/Core/ModuleList.h
+++ include/lldb/Core/ModuleList.h
@@ -537,7 +537,8 @@
                                 const FileSpecList *module_search_paths_ptr,
                                 lldb::ModuleSP *old_module_sp_ptr,
                                 bool *did_create_ptr,
-                                bool always_create = false);
+                                bool always_create = false,
+                                const char* sysroot = nullptr);
 
   static bool RemoveSharedModule(lldb::ModuleSP &module_sp);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49685.157088.patch
Type: text/x-patch
Size: 3654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180724/2f262fb4/attachment-0001.bin>


More information about the lldb-commits mailing list