[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 14:50:02 PDT 2018


EugeneBi updated this revision to Diff 157135.
EugeneBi marked 6 inline comments as done.
EugeneBi added a comment.

Code review followup:

- Restricted change to Platform.cpp
- Restricted change only to remote platforms.


https://reviews.llvm.org/D49685

Files:
  source/Target/Platform.cpp


Index: source/Target/Platform.cpp
===================================================================
--- source/Target/Platform.cpp
+++ source/Target/Platform.cpp
@@ -228,17 +228,33 @@
         module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
         did_create_ptr, false);
 
+  // Module resolver lambda.
+  auto resolver = [&](const ModuleSpec &spec) {
+    Status error(eErrorTypeGeneric);
+    // Check if we have sysroot set.
+    if (m_sdk_sysroot) {
+      // Prepend sysroot to module spec.
+      auto resolved_spec(spec);
+      resolved_spec.GetFileSpec().PrependPathComponent(
+        m_sdk_sysroot.GetStringRef());
+      // Try to get shared module with resolved spec.
+      error = ModuleList::GetSharedModule( 
+        resolved_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, 
+        did_create_ptr, false);
+    }
+    // If we don't have sysroot or it didn't work then 
+    // try original module spec.
+    if (!error.Success())
+      error = ModuleList::GetSharedModule(
+        spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, 
+        did_create_ptr, false);
+    if (error.Success() && module_sp)
+      module_sp->SetPlatformFileSpec(spec.GetFileSpec());
+    return error;
+  };
+
   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);
-                                 if (error.Success() && module_sp)
-                                   module_sp->SetPlatformFileSpec(
-                                       spec.GetFileSpec());
-                                 return error;
-                               },
-                               did_create_ptr);
+                               resolver, did_create_ptr);
 }
 
 bool Platform::GetModuleSpec(const FileSpec &module_file_spec,


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


More information about the lldb-commits mailing list