diff options
| author | Tamas Berghammer <tberghammer@google.com> | 2015-03-13 11:16:08 +0000 |
|---|---|---|
| committer | Tamas Berghammer <tberghammer@google.com> | 2015-03-13 11:16:08 +0000 |
| commit | dad4db713de4e2d7e783cde6fc3191624c7bac29 (patch) | |
| tree | 7ea263fe3ec08502ba1301058b0836a4aa7aee64 /lldb/source/Host/android/HostInfoAndroid.cpp | |
| parent | 0cbf0b13e74a1334cd318517789f4c692faf524a (diff) | |
| download | bcm5719-llvm-dad4db713de4e2d7e783cde6fc3191624c7bac29.tar.gz bcm5719-llvm-dad4db713de4e2d7e783cde6fc3191624c7bac29.zip | |
Add filepath to qModuleInfo packet
The file path is currently required on android because the executables
only contain the name of the system libraries without their path. This
CL add an extra field to the qModuleInfo packet to return the full path
of a modul and add logic to locate a shared module on android.
Differential revision: http://reviews.llvm.org/D8221
llvm-svn: 232156
Diffstat (limited to 'lldb/source/Host/android/HostInfoAndroid.cpp')
| -rw-r--r-- | lldb/source/Host/android/HostInfoAndroid.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp b/lldb/source/Host/android/HostInfoAndroid.cpp index de5bae77598..b819f92e95f 100644 --- a/lldb/source/Host/android/HostInfoAndroid.cpp +++ b/lldb/source/Host/android/HostInfoAndroid.cpp @@ -9,8 +9,11 @@ #include "lldb/Host/android/HostInfoAndroid.h" #include "lldb/Host/linux/HostInfoLinux.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" using namespace lldb_private; +using namespace llvm; void HostInfoAndroid::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64) @@ -39,3 +42,55 @@ HostInfoAndroid::GetDefaultShell() { return FileSpec("/system/bin/sh", false); } + +FileSpec +HostInfoAndroid::ResolveLibraryPath(const std::string& module_path, const ArchSpec& arch) +{ + static const char* const ld_library_path_separator = ":"; + static const char* const default_lib32_path[] = { + "/vendor/lib", + "/system/lib", + nullptr + }; + static const char* const default_lib64_path[] = { + "/vendor/lib64", + "/system/lib64", + nullptr + }; + + if (module_path.empty() || module_path[0] == '/') + return FileSpec(module_path.c_str(), true); + + SmallVector<StringRef, 4> ld_paths; + + if (const char* ld_library_path = ::getenv("LD_LIBRARY_PATH")) + StringRef(ld_library_path).split(ld_paths, StringRef(ld_library_path_separator), -1, false); + + const char* const* default_lib_path = nullptr; + switch (arch.GetAddressByteSize()) + { + case 4: + default_lib_path = default_lib32_path; + break; + case 8: + default_lib_path = default_lib64_path; + break; + default: + assert(false && "Unknown address byte size"); + return FileSpec(); + } + + for(const char* const* it = default_lib_path; *it; ++it) + ld_paths.push_back(StringRef(*it)); + + for (const StringRef& path : ld_paths) + { + FileSpec file_candidate(path.str().c_str(), true); + file_candidate.AppendPathComponent(module_path.c_str()); + + if (file_candidate.Exists()) + return file_candidate; + } + + return FileSpec(); +} |

