[lldb-dev] LLDB does not respect platform sysroot when loading core on Linux

Ted Woodward via lldb-dev lldb-dev at lists.llvm.org
Fri Jul 20 12:01:21 PDT 2018


Instead of setting the sysroot, try the command

image search-paths add / /path/to/remote/shared/libraries/

 

That adds to the list that the dynamic loader uses to map shared object
paths.

 

It uses a simple text substitution, so in the above case,

/usr/lib/libc.so

Becomes

/path/to/remote/shared/libraries/usr/lib/libc.so

 

Matching up trailing slashes is critical, as I learned the hard way!

 

Ted

 

--

Qualcomm Innovation Center, Inc.

The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project

 

From: lldb-dev [mailto:lldb-dev-bounces at lists.llvm.org] On Behalf Of Eugene
Birukov via lldb-dev
Sent: Friday, July 20, 2018 1:13 PM
To: lldb-dev at lists.llvm.org
Subject: [lldb-dev] LLDB does not respect platform sysroot when loading core
on Linux

 

Hello,

 

I would appreciate advise how to fix this correctly.

 

I have a core dump from somebody's RHEL Linux and I am trying to open it on
my Ubuntu. I have all the shared libraries from the target sitting under my
local directory. So, GDB happily opens the core after I issue "set sysroot
/path/to/local/root", but LLDB release_60 fails to do it.

 

I follow instructions from Greg's Clayton mail
http://lists.llvm.org/pipermail/lldb-dev/2016-January/009236.html :

 

(lldb) platform select --sysroot /path/to/remote/shared/libraries
remote-linux

(lldb) <load core>

 

Under debugger, I see that LLDB successfully created Platform object with
m_sdk_root set to my path and the Target uses it as its platform:

 

(gdb) p target_sp->m_platform_sp->m_sdk_sysroot

$42 = {

  m_string = 0x80e070 "/tmp/debugcore.3WyoW4/lib2"

}

 

But this value is not used when it comes to
DynamicLoaderPOSIXDYLD::LoadAllCurrentModules. 

(gdb) bt

#0  lldb_private::ModuleList::GetSharedModule (module_spec=...,
module_sp=std::shared_ptr (empty) 0x0,

    module_search_paths_ptr=0x83ad60, old_module_sp_ptr=0x7fffffffbb50,
did_create_ptr=0x7fffffffbb07,

    always_create=false) at
/home/eugene/llvm/tools/lldb/source/Core/ModuleList.cpp:710

#1  0x00007fffedc2d130 in lldb_private::Platform::<lambda(const
lldb_private::ModuleSpec&)>::operator()(const lldb_private::ModuleSpec &)
const (__closure=0x8581b0, spec=...)

    at /home/eugene/llvm/tools/lldb/source/Target/Platform.cpp:234

#2  0x00007fffedc34ff2 in std::_Function_handler<lldb_private::Status(const
lldb_private::ModuleSpec&), lldb_private::Platform::GetSharedModule(const
lldb_private::ModuleSpec&, lldb_private::Process*, lldb::ModuleSP&, const
lldb_private::FileSpecList*, lldb::ModuleSP*, bool*)::<lambda(const
lldb_private::ModuleSpec&)> >::_M_invoke(const std::_Any_data &, const
lldb_private::ModuleSpec &) (__functor=..., __args#0=...) at
/usr/include/c++/5/functional:1857

#3  0x00007fffedc37978 in std::function<lldb_private::Status
(lldb_private::ModuleSpec const&)>::operator()(lldb_private::ModuleSpec
const&) const (this=0x7fffffffba80, __args#0=...) at
/usr/include/c++/5/functional:2267

#4  0x00007fffedc3375a in
lldb_private::Platform::GetRemoteSharedModule(lldb_private::ModuleSpec
const&, lldb_private::Process*, std::shared_ptr<lldb_private::Module>&,
std::function<lldb_private::Status (lldb_private::ModuleSpec const&)>
const&, bool*) (this=0x839330, module_spec=..., process=0x84d310,
module_sp=std::shared_ptr (empty) 0x0,

    module_resolver=..., did_create_ptr=0x7fffffffbb07)

    at /home/eugene/llvm/tools/lldb/source/Target/Platform.cpp:1628

#5  0x00007fffedc2d2cd in lldb_private::Platform::GetSharedModule
(this=0x839330, module_spec=...,

    process=0x84d310, module_sp=std::shared_ptr (empty) 0x0,
module_search_paths_ptr=0x83ad60,

    old_module_sp_ptr=0x7fffffffbb50, did_create_ptr=0x7fffffffbb07)

    at /home/eugene/llvm/tools/lldb/source/Target/Platform.cpp:240

#6  0x00007fffedc9957c in lldb_private::Target::GetSharedModule
(this=0x846960, module_spec=..., error_ptr=0x0)

    at /home/eugene/llvm/tools/lldb/source/Target/Target.cpp:1952

#7  0x00007fffef8e0d11 in lldb_private::DynamicLoader::LoadModuleAtAddress
(this=0x9a0a70, file=...,

    link_map_addr=139700267943784, base_addr=139700263510016,
base_addr_is_offset=true)

    at /home/eugene/llvm/tools/lldb/source/Core/DynamicLoader.cpp:171

#8  0x00007fffedd8fb55 in DynamicLoaderPOSIXDYLD::LoadAllCurrentModules
(this=0x9a0a70)

    at
/home/eugene/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/Dynamic
LoaderPOSIXDYLD.cpp:537

#9  0x00007fffedd8de52 in DynamicLoaderPOSIXDYLD::DidAttach (this=0x9a0a70)

    at
/home/eugene/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/Dynamic
LoaderPOSIXDYLD.cpp:171

#10 0x00007fffedc476d9 in lldb_private::Process::LoadCore (this=0x84d310)

    at /home/eugene/llvm/tools/lldb/source/Target/Process.cpp:2853

 

I simply do not see any reference to sysroot in the GetSharedModule() code.
What is there - it is only scanning module_search_paths_ptr looking for
file. This would not work because the scan ignores the directory part of the
module: it takes the next path from the list and appends the file name. What
I need instead - take m_sdk_sysroot from Platform and append the full module
- including directory - to it.

 

Unfortunately, GetSharedModule() is a static method and does not have any
clue what is current platform or current target. So, should I pass another
argument down there with sysroot or what? I have correct platform object at
frame 4.

 

Thanks,

Eugene

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20180720/e68c6ded/attachment.html>


More information about the lldb-dev mailing list