diff options
| author | Tamas Berghammer <tberghammer@google.com> | 2015-03-24 11:15:23 +0000 |
|---|---|---|
| committer | Tamas Berghammer <tberghammer@google.com> | 2015-03-24 11:15:23 +0000 |
| commit | 7cb18bf537ed319eaa06f12ed39f85594bed641a (patch) | |
| tree | e5274e908c82a83438c117d6cc750a81c2b67462 /lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp | |
| parent | 2a403d1c01e74a6c0fab3a7d70d06ee901209c76 (diff) | |
Fetch module specification from remote process also
Previously the remote module sepcification was fetched only from the
remote platform. With this CL if we have a remote process then we ask it
if it have any information from a given module. It is required because
on android the dynamic linker only reports the name of the SO file and
the platform can't always find it without a full path (the process can
do it based on /proc/<pid>/maps).
Differential revision: http://reviews.llvm.org/D8547
llvm-svn: 233061
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index fd3a62eab428..bdf1d7205f6f 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -136,12 +136,13 @@ PtraceWrapper((req), (pid), (addr), (data), (data_size), (error)) #endif +using namespace lldb; +using namespace lldb_private; +using namespace llvm; + // Private bits we only need internally. namespace { - using namespace lldb; - using namespace lldb_private; - static void * const EXIT_OPERATION = nullptr; const UnixSignals& @@ -1051,8 +1052,6 @@ namespace } -using namespace lldb_private; - // Simple helper function to ensure flags are enabled on the given file // descriptor. static bool @@ -3979,3 +3978,42 @@ NativeProcessLinux::RequestThreadStop (const lldb::pid_t pid, const lldb::tid_t return err; } + +Error +NativeProcessLinux::GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) +{ + char maps_file_name[32]; + snprintf(maps_file_name, sizeof(maps_file_name), "/proc/%" PRIu64 "/maps", GetID()); + + FileSpec maps_file_spec(maps_file_name, false); + if (!maps_file_spec.Exists()) { + file_spec.Clear(); + return Error("/proc/%" PRIu64 "/maps file doesn't exists!", GetID()); + } + + FileSpec module_file_spec(module_path, true); + + std::ifstream maps_file(maps_file_name); + std::string maps_data_str((std::istreambuf_iterator<char>(maps_file)), std::istreambuf_iterator<char>()); + StringRef maps_data(maps_data_str.c_str()); + + while (!maps_data.empty()) + { + StringRef maps_row; + std::tie(maps_row, maps_data) = maps_data.split('\n'); + + SmallVector<StringRef, 16> maps_columns; + maps_row.split(maps_columns, StringRef(" "), -1, false); + + if (maps_columns.size() >= 6) + { + file_spec.SetFile(maps_columns[5].str().c_str(), false); + if (file_spec.GetFilename() == module_file_spec.GetFilename()) + return Error(); + } + } + + file_spec.Clear(); + return Error("Module file (%s) not found in /proc/%" PRIu64 "/maps file!", + module_file_spec.GetFilename().AsCString(), GetID()); +} |
