[PATCH] D49685: LLDB does not respect platform sysroot when loading core on Linux
Eugene Birukov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 23 11:23:40 PDT 2018
EugeneBi created this revision.
EugeneBi added reviewers: labath, clayborg.
Herald added a subscriber: llvm-commits.
The situation arises when we are trying to load a core dump which was generated on a different machine
running a different version of Linux. The problem is that shared libraries differ on these machines and
LLDB either fails to load some libraries or loads wrong ones.
How it should work:
1. We copy the directory tree with libraries from target machine into some local directory
2. in LLDB, create a platform setting sysroot to that directory
3. Create target using that platform
The fix is to pass additional "sysroot" argument from lldb_private::Platform::GetSharedModule to
lldb_private::ModuleList::GetSharedModule
Repository:
rL LLVM
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
@@ -225,13 +225,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
@@ -707,7 +707,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);
@@ -726,9 +730,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 =
@@ -762,7 +763,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
@@ -541,7 +541,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.156833.patch
Type: text/x-patch
Size: 3649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180723/26da6709/attachment.bin>
More information about the llvm-commits
mailing list