<div dir="ltr"><div>Will look like this now:<br><br>(lldb) platform process list<br>...<br>5920 5917 mikesart 6 x86_64--linux tee<br>5923 1 mikesart 6 x86_64--linux wineserver<br>6004 1 mikesart 6 x86_64--linux wine64-preloader<br>
6049 1 mikesart 4 i386--linux wine-preloader<br><br></div><div>I'll check in after this is ok'd. Thanks!<br></div><div> -Mike<br></div><div><div><div><br>Index: source/Host/linux/Host.cpp<br>===================================================================<br>
--- source/Host/linux/Host.cpp (revision 182064)<br>+++ source/Host/linux/Host.cpp (working copy)<br>@@ -18,6 +18,8 @@<br> // C++ Includes<br> // Other libraries and framework includes<br> // Project includes<br>+#include "llvm/Support/ELF.h"<br>
+<br> #include "lldb/Core/Error.h"<br> #include "lldb/Target/Process.h"<br> <br>@@ -25,6 +27,9 @@<br> #include "lldb/Core/DataBufferHeap.h"<br> #include "lldb/Core/DataExtractor.h"<br>
<br>+#include "lldb/Core/ModuleSpec.h"<br>+#include "lldb/Symbol/ObjectFile.h"<br>+<br> using namespace lldb;<br> using namespace lldb_private;<br> <br>@@ -47,7 +52,6 @@<br> // Get the process info with additional information from /proc/$PID/stat (like process state, and tracer pid).<br>
static bool GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, ProcessStatInfo &stat_info, lldb::pid_t &tracerpid);<br> <br>-<br> namespace<br> {<br> <br>@@ -293,6 +297,37 @@<br> }<br>
<br> static bool<br>+GetProcessCPUTypeFromExecutable (const char *exe_path, ProcessInstanceInfo &process_info)<br>+{<br>+ // Clear the architecture.<br>+ process_info.GetArchitecture().Clear();<br>+<br>+ ModuleSpecList specs;<br>
+ FileSpec filespec (exe_path, false);<br>+ const size_t num_specs = ObjectFile::GetModuleSpecifications (filespec, 0, specs);<br>+ assert(num_specs == 1 && "Linux plugin supports only a single architecture");<br>
+ if (num_specs == 1)<br>+ {<br>+ ModuleSpec module_spec;<br>+ if (specs.GetModuleSpecAtIndex (0, module_spec) && module_spec.GetArchitecture().IsValid())<br>+ {<br>+ const llvm::Triple &host_triple = Host::GetArchitecture (Host::eSystemDefaultArchitecture).GetTriple();<br>
+ llvm::Triple &module_triple = module_spec.GetArchitecture().GetTriple();<br>+<br>+ // If the vendor or OS is unknown, use the host information. The ArchType has to come from the executable.<br>
+ if (module_triple.getVendor() == llvm::Triple::UnknownVendor)<br>+ module_triple.setVendorName (host_triple.getVendorName());<br>+ if (module_triple.getOS() == llvm::Triple::UnknownOS)<br>
+ module_triple.setOSName (host_triple.getOSName());<br>+<br>+ process_info.GetArchitecture () = module_spec.GetArchitecture();<br>+ return true;<br>+ }<br>+ }<br>+ return false; <br>
+}<br>+<br>+static bool<br> GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, ProcessStatInfo &stat_info, lldb::pid_t &tracerpid)<br> {<br> tracerpid = 0;<br>@@ -300,9 +335,6 @@<br>
::memset (&stat_info, 0, sizeof(stat_info));<br> stat_info.ppid = LLDB_INVALID_PROCESS_ID;<br> <br>- // Architecture is intentionally omitted because that's better resolved<br>- // in other places (see ProcessPOSIX::DoAttachWithID().<br>
-<br> // Use special code here because proc/[pid]/exe is a symbolic link.<br> char link_path[PATH_MAX];<br> char exe_path[PATH_MAX] = "";<br>@@ -324,6 +356,10 @@<br> {<br> exe_path[len - deleted_len] = 0;<br>
}<br>+ else<br>+ {<br>+ GetProcessCPUTypeFromExecutable (exe_path, process_info);<br>+ }<br> <br> process_info.SetProcessID(pid);<br> process_info.GetExecutableFile().SetFile(exe_path, false);<br>
<br></div></div></div></div>