diff options
Diffstat (limited to 'lldb/source/Host/linux/Host.cpp')
| -rw-r--r-- | lldb/source/Host/linux/Host.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index 110590cd006..0ed07fb8915 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -25,6 +25,9 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Symbol/ObjectFile.h" + using namespace lldb; using namespace lldb_private; @@ -293,6 +296,30 @@ Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstance } static bool +GetELFProcessCPUType (const char *exe_path, ProcessInstanceInfo &process_info) +{ + // Clear the architecture. + process_info.GetArchitecture().Clear(); + + ModuleSpecList specs; + FileSpec filespec (exe_path, false); + const size_t num_specs = ObjectFile::GetModuleSpecifications (filespec, 0, specs); + // GetModuleSpecifications() could fail if the executable has been deleted or is locked. + // But it shouldn't return more than 1 architecture. + assert(num_specs <= 1 && "Linux plugin supports only a single architecture"); + if (num_specs == 1) + { + ModuleSpec module_spec; + if (specs.GetModuleSpecAtIndex (0, module_spec) && module_spec.GetArchitecture().IsValid()) + { + process_info.GetArchitecture () = module_spec.GetArchitecture(); + return true; + } + } + return false; +} + +static bool GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, ProcessStatInfo &stat_info, lldb::pid_t &tracerpid) { tracerpid = 0; @@ -300,9 +327,6 @@ GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, Proce ::memset (&stat_info, 0, sizeof(stat_info)); stat_info.ppid = LLDB_INVALID_PROCESS_ID; - // Architecture is intentionally omitted because that's better resolved - // in other places (see ProcessPOSIX::DoAttachWithID(). - // Use special code here because proc/[pid]/exe is a symbolic link. char link_path[PATH_MAX]; char exe_path[PATH_MAX] = ""; @@ -324,6 +348,10 @@ GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, Proce { exe_path[len - deleted_len] = 0; } + else + { + GetELFProcessCPUType (exe_path, process_info); + } process_info.SetProcessID(pid); process_info.GetExecutableFile().SetFile(exe_path, false); |

