<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">FYI, this commit has broken host build on Linux: <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/35862">http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/35862</a>. </div><div>Trying to fix with r355392.</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 4, 2019 at 10:50 PM Zachary Turner via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: zturner<br>
Date: Mon Mar 4 13:51:03 2019<br>
New Revision: 355342<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=355342&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=355342&view=rev</a><br>
Log:<br>
Move ProcessInfo from Host to Utility.<br>
<br>
There are set of classes in Target that describe the parameters of a<br>
process - e.g. it's PID, name, user id, and similar. However, since it<br>
is a bare description of a process and contains no actual functionality,<br>
there's nothing specifically that makes this appropriate for being in<br>
Target -- it could just as well be describing a process on the host, or<br>
some hypothetical virtual process that doesn't even exist.<br>
<br>
To cement this, I'm moving these classes to Utility. It's possible that<br>
we can find a better place for it in the future, but as it is neither<br>
Host specific nor Target specific, Utility seems like the most appropriate<br>
place for the time being.<br>
<br>
After this there is only 2 remaining references to Target from Host,<br>
which I'll address in a followup.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D58842" rel="noreferrer" target="_blank">https://reviews.llvm.org/D58842</a><br>
<br>
Added:<br>
lldb/trunk/include/lldb/Utility/ProcessInfo.h<br>
lldb/trunk/source/Utility/ProcessInfo.cpp<br>
lldb/trunk/unittests/Utility/ProcessInfoTest.cpp<br>
Removed:<br>
lldb/trunk/include/lldb/Host/ProcessInfo.h<br>
lldb/trunk/source/Host/common/ProcessInfo.cpp<br>
lldb/trunk/unittests/Host/ProcessInfoTest.cpp<br>
Modified:<br>
lldb/trunk/include/lldb/Host/Host.h<br>
lldb/trunk/include/lldb/Host/ProcessLaunchInfo.h<br>
lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h<br>
lldb/trunk/include/lldb/Target/Platform.h<br>
lldb/trunk/include/lldb/Target/Process.h<br>
lldb/trunk/include/lldb/module.modulemap<br>
lldb/trunk/source/API/SBProcess.cpp<br>
lldb/trunk/source/API/SBProcessInfo.cpp<br>
lldb/trunk/source/API/SBTarget.cpp<br>
lldb/trunk/source/Host/CMakeLists.txt<br>
lldb/trunk/source/Host/freebsd/Host.cpp<br>
lldb/trunk/source/Host/linux/Host.cpp<br>
lldb/trunk/source/Host/macosx/objcxx/Host.mm<br>
lldb/trunk/source/Host/netbsd/Host.cpp<br>
lldb/trunk/source/Host/openbsd/Host.cpp<br>
lldb/trunk/source/Host/posix/HostInfoPosix.cpp<br>
lldb/trunk/source/Host/windows/Host.cpp<br>
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp<br>
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp<br>
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp<br>
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp<br>
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp<br>
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp<br>
lldb/trunk/source/Target/Process.cpp<br>
lldb/trunk/source/Utility/CMakeLists.txt<br>
lldb/trunk/unittests/Host/CMakeLists.txt<br>
lldb/trunk/unittests/Utility/CMakeLists.txt<br>
<br>
Modified: lldb/trunk/include/lldb/Host/Host.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Host/Host.h (original)<br>
+++ lldb/trunk/include/lldb/Host/Host.h Mon Mar 4 13:51:03 2019<br>
@@ -26,6 +26,9 @@ namespace lldb_private {<br>
<br>
class FileAction;<br>
class ProcessLaunchInfo;<br>
+class ProcessInstanceInfo;<br>
+class ProcessInstanceInfoList;<br>
+class ProcessInstanceInfoMatch;<br>
<br>
//----------------------------------------------------------------------<br>
// Exit Type for inferior processes<br>
<br>
Removed: lldb/trunk/include/lldb/Host/ProcessInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/ProcessInfo.h?rev=355341&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/ProcessInfo.h?rev=355341&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Host/ProcessInfo.h (original)<br>
+++ lldb/trunk/include/lldb/Host/ProcessInfo.h (removed)<br>
@@ -1,101 +0,0 @@<br>
-//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===//<br>
-//<br>
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
-// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#ifndef liblldb_ProcessInfo_h_<br>
-#define liblldb_ProcessInfo_h_<br>
-<br>
-// LLDB headers<br>
-#include "lldb/Utility/ArchSpec.h"<br>
-#include "lldb/Utility/Args.h"<br>
-#include "lldb/Utility/Environment.h"<br>
-#include "lldb/Utility/FileSpec.h"<br>
-<br>
-namespace lldb_private {<br>
-//----------------------------------------------------------------------<br>
-// ProcessInfo<br>
-//<br>
-// A base class for information for a process. This can be used to fill<br>
-// out information for a process prior to launching it, or it can be used for<br>
-// an instance of a process and can be filled in with the existing values for<br>
-// that process.<br>
-//----------------------------------------------------------------------<br>
-class ProcessInfo {<br>
-public:<br>
- ProcessInfo();<br>
-<br>
- ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid);<br>
-<br>
- void Clear();<br>
-<br>
- const char *GetName() const;<br>
-<br>
- size_t GetNameLength() const;<br>
-<br>
- FileSpec &GetExecutableFile() { return m_executable; }<br>
-<br>
- void SetExecutableFile(const FileSpec &exe_file,<br>
- bool add_exe_file_as_first_arg);<br>
-<br>
- const FileSpec &GetExecutableFile() const { return m_executable; }<br>
-<br>
- uint32_t GetUserID() const { return m_uid; }<br>
-<br>
- uint32_t GetGroupID() const { return m_gid; }<br>
-<br>
- bool UserIDIsValid() const { return m_uid != UINT32_MAX; }<br>
-<br>
- bool GroupIDIsValid() const { return m_gid != UINT32_MAX; }<br>
-<br>
- void SetUserID(uint32_t uid) { m_uid = uid; }<br>
-<br>
- void SetGroupID(uint32_t gid) { m_gid = gid; }<br>
-<br>
- ArchSpec &GetArchitecture() { return m_arch; }<br>
-<br>
- const ArchSpec &GetArchitecture() const { return m_arch; }<br>
-<br>
- void SetArchitecture(const ArchSpec &arch) { m_arch = arch; }<br>
-<br>
- lldb::pid_t GetProcessID() const { return m_pid; }<br>
-<br>
- void SetProcessID(lldb::pid_t pid) { m_pid = pid; }<br>
-<br>
- bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; }<br>
-<br>
- void Dump(Stream &s, Platform *platform) const;<br>
-<br>
- Args &GetArguments() { return m_arguments; }<br>
-<br>
- const Args &GetArguments() const { return m_arguments; }<br>
-<br>
- llvm::StringRef GetArg0() const;<br>
-<br>
- void SetArg0(llvm::StringRef arg);<br>
-<br>
- void SetArguments(const Args &args, bool first_arg_is_executable);<br>
-<br>
- void SetArguments(char const **argv, bool first_arg_is_executable);<br>
-<br>
- Environment &GetEnvironment() { return m_environment; }<br>
- const Environment &GetEnvironment() const { return m_environment; }<br>
-<br>
-protected:<br>
- FileSpec m_executable;<br>
- std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.<br>
- // Not all process plug-ins support specifying an argv[0] that differs from<br>
- // the resolved platform executable (which is in m_executable)<br>
- Args m_arguments; // All program arguments except argv[0]<br>
- Environment m_environment;<br>
- uint32_t m_uid;<br>
- uint32_t m_gid;<br>
- ArchSpec m_arch;<br>
- lldb::pid_t m_pid;<br>
-};<br>
-}<br>
-<br>
-#endif // #ifndef liblldb_ProcessInfo_h_<br>
<br>
Modified: lldb/trunk/include/lldb/Host/ProcessLaunchInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/ProcessLaunchInfo.h?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/ProcessLaunchInfo.h?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Host/ProcessLaunchInfo.h (original)<br>
+++ lldb/trunk/include/lldb/Host/ProcessLaunchInfo.h Mon Mar 4 13:51:03 2019<br>
@@ -17,9 +17,9 @@<br>
<br>
#include "lldb/Host/FileAction.h"<br>
#include "lldb/Host/Host.h"<br>
-#include "lldb/Host/ProcessInfo.h"<br>
#include "lldb/Host/PseudoTerminal.h"<br>
#include "lldb/Utility/FileSpec.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
<br>
namespace lldb_private {<br>
<br>
<br>
Modified: lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h (original)<br>
+++ lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h Mon Mar 4 13:51:03 2019<br>
@@ -22,7 +22,6 @@ class HostInfoPosix : public HostInfoBas<br>
public:<br>
static size_t GetPageSize();<br>
static bool GetHostname(std::string &s);<br>
- static UserIDResolver &GetUserIDResolver();<br>
<br>
static uint32_t GetUserID();<br>
static uint32_t GetGroupID();<br>
<br>
Modified: lldb/trunk/include/lldb/Target/Platform.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Target/Platform.h (original)<br>
+++ lldb/trunk/include/lldb/Target/Platform.h Mon Mar 4 13:51:03 2019<br>
@@ -30,6 +30,10 @@<br>
<br>
namespace lldb_private {<br>
<br>
+class ProcessInstanceInfo;<br>
+class ProcessInstanceInfoList;<br>
+class ProcessInstanceInfoMatch;<br>
+<br>
class ModuleCache;<br>
enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 };<br>
<br>
<br>
Modified: lldb/trunk/include/lldb/Target/Process.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Target/Process.h (original)<br>
+++ lldb/trunk/include/lldb/Target/Process.h Mon Mar 4 13:51:03 2019<br>
@@ -28,7 +28,6 @@<br>
#include "lldb/Core/ThreadSafeValue.h"<br>
#include "lldb/Core/UserSettingsController.h"<br>
#include "lldb/Host/HostThread.h"<br>
-#include "lldb/Host/ProcessInfo.h"<br>
#include "lldb/Host/ProcessLaunchInfo.h"<br>
#include "lldb/Host/ProcessRunLock.h"<br>
#include "lldb/Interpreter/Options.h"<br>
@@ -43,6 +42,7 @@<br>
#include "lldb/Utility/Event.h"<br>
#include "lldb/Utility/Listener.h"<br>
#include "lldb/Utility/NameMatches.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StructuredData.h"<br>
#include "lldb/Utility/TraceOptions.h"<br>
@@ -109,62 +109,6 @@ protected:<br>
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;<br>
<br>
//----------------------------------------------------------------------<br>
-// ProcessInstanceInfo<br>
-//<br>
-// Describes an existing process and any discoverable information that pertains<br>
-// to that process.<br>
-//----------------------------------------------------------------------<br>
-class ProcessInstanceInfo : public ProcessInfo {<br>
-public:<br>
- ProcessInstanceInfo()<br>
- : ProcessInfo(), m_euid(UINT32_MAX), m_egid(UINT32_MAX),<br>
- m_parent_pid(LLDB_INVALID_PROCESS_ID) {}<br>
-<br>
- ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid)<br>
- : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX),<br>
- m_parent_pid(LLDB_INVALID_PROCESS_ID) {}<br>
-<br>
- void Clear() {<br>
- ProcessInfo::Clear();<br>
- m_euid = UINT32_MAX;<br>
- m_egid = UINT32_MAX;<br>
- m_parent_pid = LLDB_INVALID_PROCESS_ID;<br>
- }<br>
-<br>
- uint32_t GetEffectiveUserID() const { return m_euid; }<br>
-<br>
- uint32_t GetEffectiveGroupID() const { return m_egid; }<br>
-<br>
- bool EffectiveUserIDIsValid() const { return m_euid != UINT32_MAX; }<br>
-<br>
- bool EffectiveGroupIDIsValid() const { return m_egid != UINT32_MAX; }<br>
-<br>
- void SetEffectiveUserID(uint32_t uid) { m_euid = uid; }<br>
-<br>
- void SetEffectiveGroupID(uint32_t gid) { m_egid = gid; }<br>
-<br>
- lldb::pid_t GetParentProcessID() const { return m_parent_pid; }<br>
-<br>
- void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; }<br>
-<br>
- bool ParentProcessIDIsValid() const {<br>
- return m_parent_pid != LLDB_INVALID_PROCESS_ID;<br>
- }<br>
-<br>
- void Dump(Stream &s, UserIDResolver &resolver) const;<br>
-<br>
- static void DumpTableHeader(Stream &s, bool show_args, bool verbose);<br>
-<br>
- void DumpAsTableRow(Stream &s, UserIDResolver &resolver, bool show_args,<br>
- bool verbose) const;<br>
-<br>
-protected:<br>
- uint32_t m_euid;<br>
- uint32_t m_egid;<br>
- lldb::pid_t m_parent_pid;<br>
-};<br>
-<br>
-//----------------------------------------------------------------------<br>
// ProcessAttachInfo<br>
//<br>
// Describes any information that is required to attach to a process.<br>
@@ -298,94 +242,6 @@ public:<br>
lldb_private::LazyBool disable_aslr;<br>
};<br>
<br>
-//----------------------------------------------------------------------<br>
-// ProcessInstanceInfoMatch<br>
-//<br>
-// A class to help matching one ProcessInstanceInfo to another.<br>
-//----------------------------------------------------------------------<br>
-<br>
-class ProcessInstanceInfoMatch {<br>
-public:<br>
- ProcessInstanceInfoMatch()<br>
- : m_match_info(), m_name_match_type(NameMatch::Ignore),<br>
- m_match_all_users(false) {}<br>
-<br>
- ProcessInstanceInfoMatch(const char *process_name,<br>
- NameMatch process_name_match_type)<br>
- : m_match_info(), m_name_match_type(process_name_match_type),<br>
- m_match_all_users(false) {<br>
- m_match_info.GetExecutableFile().SetFile(process_name,<br>
- FileSpec::Style::native);<br>
- }<br>
-<br>
- ProcessInstanceInfo &GetProcessInfo() { return m_match_info; }<br>
-<br>
- const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; }<br>
-<br>
- bool GetMatchAllUsers() const { return m_match_all_users; }<br>
-<br>
- void SetMatchAllUsers(bool b) { m_match_all_users = b; }<br>
-<br>
- NameMatch GetNameMatchType() const { return m_name_match_type; }<br>
-<br>
- void SetNameMatchType(NameMatch name_match_type) {<br>
- m_name_match_type = name_match_type;<br>
- }<br>
-<br>
- bool NameMatches(const char *process_name) const;<br>
-<br>
- bool Matches(const ProcessInstanceInfo &proc_info) const;<br>
-<br>
- bool MatchAllProcesses() const;<br>
- void Clear();<br>
-<br>
-protected:<br>
- ProcessInstanceInfo m_match_info;<br>
- NameMatch m_name_match_type;<br>
- bool m_match_all_users;<br>
-};<br>
-<br>
-class ProcessInstanceInfoList {<br>
-public:<br>
- ProcessInstanceInfoList() = default;<br>
-<br>
- void Clear() { m_infos.clear(); }<br>
-<br>
- size_t GetSize() { return m_infos.size(); }<br>
-<br>
- void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }<br>
-<br>
- const char *GetProcessNameAtIndex(size_t idx) {<br>
- return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);<br>
- }<br>
-<br>
- size_t GetProcessNameLengthAtIndex(size_t idx) {<br>
- return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);<br>
- }<br>
-<br>
- lldb::pid_t GetProcessIDAtIndex(size_t idx) {<br>
- return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0);<br>
- }<br>
-<br>
- bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) {<br>
- if (idx < m_infos.size()) {<br>
- info = m_infos[idx];<br>
- return true;<br>
- }<br>
- return false;<br>
- }<br>
-<br>
- // You must ensure "idx" is valid before calling this function<br>
- const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const {<br>
- assert(idx < m_infos.size());<br>
- return m_infos[idx];<br>
- }<br>
-<br>
-protected:<br>
- typedef std::vector<ProcessInstanceInfo> collection;<br>
- collection m_infos;<br>
-};<br>
-<br>
// This class tracks the Modification state of the process. Things that can<br>
// currently modify the program are running the program (which will up the<br>
// StopID) and writing memory (which will up the MemoryID.)<br>
@@ -2519,7 +2375,7 @@ public:<br>
///<br>
//------------------------------------------------------------------<br>
void RestoreProcessEvents();<br>
- <br>
+<br>
bool StateChangedIsHijackedForSynchronousResume();<br>
<br>
bool StateChangedIsExternallyHijacked();<br>
<br>
Added: lldb/trunk/include/lldb/Utility/ProcessInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ProcessInfo.h?rev=355342&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ProcessInfo.h?rev=355342&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Utility/ProcessInfo.h (added)<br>
+++ lldb/trunk/include/lldb/Utility/ProcessInfo.h Mon Mar 4 13:51:03 2019<br>
@@ -0,0 +1,251 @@<br>
+//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===//<br>
+//<br>
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
+// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef LLDB_UTILITY_PROCESSINFO_H<br>
+#define LLDB_UTILITY_PROCESSINFO_H<br>
+<br>
+// LLDB headers<br>
+#include "lldb/Utility/ArchSpec.h"<br>
+#include "lldb/Utility/Args.h"<br>
+#include "lldb/Utility/Environment.h"<br>
+#include "lldb/Utility/FileSpec.h"<br>
+#include "lldb/Utility/NameMatches.h"<br>
+<br>
+#include <vector><br>
+<br>
+namespace lldb_private {<br>
+<br>
+class UserIDResolver;<br>
+<br>
+//----------------------------------------------------------------------<br>
+// ProcessInfo<br>
+//<br>
+// A base class for information for a process. This can be used to fill<br>
+// out information for a process prior to launching it, or it can be used for<br>
+// an instance of a process and can be filled in with the existing values for<br>
+// that process.<br>
+//----------------------------------------------------------------------<br>
+class ProcessInfo {<br>
+public:<br>
+ ProcessInfo();<br>
+<br>
+ ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid);<br>
+<br>
+ void Clear();<br>
+<br>
+ const char *GetName() const;<br>
+<br>
+ size_t GetNameLength() const;<br>
+<br>
+ FileSpec &GetExecutableFile() { return m_executable; }<br>
+<br>
+ void SetExecutableFile(const FileSpec &exe_file,<br>
+ bool add_exe_file_as_first_arg);<br>
+<br>
+ const FileSpec &GetExecutableFile() const { return m_executable; }<br>
+<br>
+ uint32_t GetUserID() const { return m_uid; }<br>
+<br>
+ uint32_t GetGroupID() const { return m_gid; }<br>
+<br>
+ bool UserIDIsValid() const { return m_uid != UINT32_MAX; }<br>
+<br>
+ bool GroupIDIsValid() const { return m_gid != UINT32_MAX; }<br>
+<br>
+ void SetUserID(uint32_t uid) { m_uid = uid; }<br>
+<br>
+ void SetGroupID(uint32_t gid) { m_gid = gid; }<br>
+<br>
+ ArchSpec &GetArchitecture() { return m_arch; }<br>
+<br>
+ const ArchSpec &GetArchitecture() const { return m_arch; }<br>
+<br>
+ void SetArchitecture(const ArchSpec &arch) { m_arch = arch; }<br>
+<br>
+ lldb::pid_t GetProcessID() const { return m_pid; }<br>
+<br>
+ void SetProcessID(lldb::pid_t pid) { m_pid = pid; }<br>
+<br>
+ bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; }<br>
+<br>
+ void Dump(Stream &s, Platform *platform) const;<br>
+<br>
+ Args &GetArguments() { return m_arguments; }<br>
+<br>
+ const Args &GetArguments() const { return m_arguments; }<br>
+<br>
+ llvm::StringRef GetArg0() const;<br>
+<br>
+ void SetArg0(llvm::StringRef arg);<br>
+<br>
+ void SetArguments(const Args &args, bool first_arg_is_executable);<br>
+<br>
+ void SetArguments(char const **argv, bool first_arg_is_executable);<br>
+<br>
+ Environment &GetEnvironment() { return m_environment; }<br>
+ const Environment &GetEnvironment() const { return m_environment; }<br>
+<br>
+protected:<br>
+ FileSpec m_executable;<br>
+ std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.<br>
+ // Not all process plug-ins support specifying an argv[0] that differs from<br>
+ // the resolved platform executable (which is in m_executable)<br>
+ Args m_arguments; // All program arguments except argv[0]<br>
+ Environment m_environment;<br>
+ uint32_t m_uid;<br>
+ uint32_t m_gid;<br>
+ ArchSpec m_arch;<br>
+ lldb::pid_t m_pid;<br>
+};<br>
+<br>
+//----------------------------------------------------------------------<br>
+// ProcessInstanceInfo<br>
+//<br>
+// Describes an existing process and any discoverable information that pertains<br>
+// to that process.<br>
+//----------------------------------------------------------------------<br>
+class ProcessInstanceInfo : public ProcessInfo {<br>
+public:<br>
+ ProcessInstanceInfo()<br>
+ : ProcessInfo(), m_euid(UINT32_MAX), m_egid(UINT32_MAX),<br>
+ m_parent_pid(LLDB_INVALID_PROCESS_ID) {}<br>
+<br>
+ ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid)<br>
+ : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX),<br>
+ m_parent_pid(LLDB_INVALID_PROCESS_ID) {}<br>
+<br>
+ void Clear() {<br>
+ ProcessInfo::Clear();<br>
+ m_euid = UINT32_MAX;<br>
+ m_egid = UINT32_MAX;<br>
+ m_parent_pid = LLDB_INVALID_PROCESS_ID;<br>
+ }<br>
+<br>
+ uint32_t GetEffectiveUserID() const { return m_euid; }<br>
+<br>
+ uint32_t GetEffectiveGroupID() const { return m_egid; }<br>
+<br>
+ bool EffectiveUserIDIsValid() const { return m_euid != UINT32_MAX; }<br>
+<br>
+ bool EffectiveGroupIDIsValid() const { return m_egid != UINT32_MAX; }<br>
+<br>
+ void SetEffectiveUserID(uint32_t uid) { m_euid = uid; }<br>
+<br>
+ void SetEffectiveGroupID(uint32_t gid) { m_egid = gid; }<br>
+<br>
+ lldb::pid_t GetParentProcessID() const { return m_parent_pid; }<br>
+<br>
+ void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; }<br>
+<br>
+ bool ParentProcessIDIsValid() const {<br>
+ return m_parent_pid != LLDB_INVALID_PROCESS_ID;<br>
+ }<br>
+<br>
+ void Dump(Stream &s, UserIDResolver &resolver) const;<br>
+<br>
+ static void DumpTableHeader(Stream &s, bool show_args, bool verbose);<br>
+<br>
+ void DumpAsTableRow(Stream &s, UserIDResolver &resolver, bool show_args,<br>
+ bool verbose) const;<br>
+<br>
+protected:<br>
+ uint32_t m_euid;<br>
+ uint32_t m_egid;<br>
+ lldb::pid_t m_parent_pid;<br>
+};<br>
+<br>
+class ProcessInstanceInfoList {<br>
+public:<br>
+ ProcessInstanceInfoList() = default;<br>
+<br>
+ void Clear() { m_infos.clear(); }<br>
+<br>
+ size_t GetSize() { return m_infos.size(); }<br>
+<br>
+ void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }<br>
+<br>
+ const char *GetProcessNameAtIndex(size_t idx) {<br>
+ return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);<br>
+ }<br>
+<br>
+ size_t GetProcessNameLengthAtIndex(size_t idx) {<br>
+ return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);<br>
+ }<br>
+<br>
+ lldb::pid_t GetProcessIDAtIndex(size_t idx) {<br>
+ return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0);<br>
+ }<br>
+<br>
+ bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) {<br>
+ if (idx < m_infos.size()) {<br>
+ info = m_infos[idx];<br>
+ return true;<br>
+ }<br>
+ return false;<br>
+ }<br>
+<br>
+ // You must ensure "idx" is valid before calling this function<br>
+ const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const {<br>
+ assert(idx < m_infos.size());<br>
+ return m_infos[idx];<br>
+ }<br>
+<br>
+protected:<br>
+ std::vector<ProcessInstanceInfo> m_infos;<br>
+};<br>
+<br>
+//----------------------------------------------------------------------<br>
+// ProcessInstanceInfoMatch<br>
+//<br>
+// A class to help matching one ProcessInstanceInfo to another.<br>
+//----------------------------------------------------------------------<br>
+<br>
+class ProcessInstanceInfoMatch {<br>
+public:<br>
+ ProcessInstanceInfoMatch()<br>
+ : m_match_info(), m_name_match_type(NameMatch::Ignore),<br>
+ m_match_all_users(false) {}<br>
+<br>
+ ProcessInstanceInfoMatch(const char *process_name,<br>
+ NameMatch process_name_match_type)<br>
+ : m_match_info(), m_name_match_type(process_name_match_type),<br>
+ m_match_all_users(false) {<br>
+ m_match_info.GetExecutableFile().SetFile(process_name,<br>
+ FileSpec::Style::native);<br>
+ }<br>
+<br>
+ ProcessInstanceInfo &GetProcessInfo() { return m_match_info; }<br>
+<br>
+ const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; }<br>
+<br>
+ bool GetMatchAllUsers() const { return m_match_all_users; }<br>
+<br>
+ void SetMatchAllUsers(bool b) { m_match_all_users = b; }<br>
+<br>
+ NameMatch GetNameMatchType() const { return m_name_match_type; }<br>
+<br>
+ void SetNameMatchType(NameMatch name_match_type) {<br>
+ m_name_match_type = name_match_type;<br>
+ }<br>
+<br>
+ bool NameMatches(const char *process_name) const;<br>
+<br>
+ bool Matches(const ProcessInstanceInfo &proc_info) const;<br>
+<br>
+ bool MatchAllProcesses() const;<br>
+ void Clear();<br>
+<br>
+protected:<br>
+ ProcessInstanceInfo m_match_info;<br>
+ NameMatch m_name_match_type;<br>
+ bool m_match_all_users;<br>
+};<br>
+<br>
+} // namespace lldb_private<br>
+<br>
+#endif // #ifndef LLDB_UTILITY_PROCESSINFO_H<br>
<br>
Modified: lldb/trunk/include/lldb/module.modulemap<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/module.modulemap?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/module.modulemap?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/module.modulemap (original)<br>
+++ lldb/trunk/include/lldb/module.modulemap Mon Mar 4 13:51:03 2019<br>
@@ -39,7 +39,6 @@ module lldb_Host {<br>
module PipeBase { header "Host/PipeBase.h" export * }<br>
module Pipe { header "Host/Pipe.h" export * }<br>
module PosixApi { header "Host/PosixApi.h" export * }<br>
- module ProcessInfo { header "Host/ProcessInfo.h" export * }<br>
module ProcessLauncher { header "Host/ProcessLauncher.h" export * }<br>
module ProcessLaunchInfo { header "Host/ProcessLaunchInfo.h" export * }<br>
module ProcessRunLock { header "Host/ProcessRunLock.h" export * }<br>
<br>
Modified: lldb/trunk/source/API/SBProcess.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/API/SBProcess.cpp (original)<br>
+++ lldb/trunk/source/API/SBProcess.cpp Mon Mar 4 13:51:03 2019<br>
@@ -25,6 +25,7 @@<br>
#include "lldb/Target/Thread.h"<br>
#include "lldb/Utility/Args.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/State.h"<br>
#include "lldb/Utility/Stream.h"<br>
<br>
<br>
Modified: lldb/trunk/source/API/SBProcessInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcessInfo.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcessInfo.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/API/SBProcessInfo.cpp (original)<br>
+++ lldb/trunk/source/API/SBProcessInfo.cpp Mon Mar 4 13:51:03 2019<br>
@@ -9,7 +9,7 @@<br>
#include "lldb/API/SBProcessInfo.h"<br>
<br>
#include "lldb/API/SBFileSpec.h"<br>
-#include "lldb/Target/Process.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
Modified: lldb/trunk/source/API/SBTarget.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/API/SBTarget.cpp (original)<br>
+++ lldb/trunk/source/API/SBTarget.cpp Mon Mar 4 13:51:03 2019<br>
@@ -61,6 +61,7 @@<br>
#include "lldb/Utility/Args.h"<br>
#include "lldb/Utility/FileSpec.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/RegularExpression.h"<br>
<br>
#include "Commands/CommandObjectBreakpoint.h"<br>
<br>
Modified: lldb/trunk/source/Host/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/CMakeLists.txt (original)<br>
+++ lldb/trunk/source/Host/CMakeLists.txt Mon Mar 4 13:51:03 2019<br>
@@ -37,7 +37,6 @@ add_host_subdirectory(common<br>
common/NativeWatchpointList.cpp<br>
common/OptionParser.cpp<br>
common/PipeBase.cpp<br>
- common/ProcessInfo.cpp<br>
common/ProcessLaunchInfo.cpp<br>
common/ProcessRunLock.cpp<br>
common/PseudoTerminal.cpp<br>
<br>
Removed: lldb/trunk/source/Host/common/ProcessInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ProcessInfo.cpp?rev=355341&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ProcessInfo.cpp?rev=355341&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/common/ProcessInfo.cpp (original)<br>
+++ lldb/trunk/source/Host/common/ProcessInfo.cpp (removed)<br>
@@ -1,113 +0,0 @@<br>
-//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//<br>
-//<br>
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
-// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include "lldb/Host/ProcessInfo.h"<br>
-<br>
-#include <climits><br>
-<br>
-#include "lldb/Host/PosixApi.h"<br>
-#include "lldb/Utility/Stream.h"<br>
-<br>
-#include "llvm/ADT/SmallString.h"<br>
-<br>
-using namespace lldb;<br>
-using namespace lldb_private;<br>
-<br>
-ProcessInfo::ProcessInfo()<br>
- : m_executable(), m_arguments(), m_environment(), m_uid(UINT32_MAX),<br>
- m_gid(UINT32_MAX), m_arch(), m_pid(LLDB_INVALID_PROCESS_ID) {}<br>
-<br>
-ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,<br>
- lldb::pid_t pid)<br>
- : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX),<br>
- m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}<br>
-<br>
-void ProcessInfo::Clear() {<br>
- m_executable.Clear();<br>
- m_arguments.Clear();<br>
- m_environment.clear();<br>
- m_uid = UINT32_MAX;<br>
- m_gid = UINT32_MAX;<br>
- m_arch.Clear();<br>
- m_pid = LLDB_INVALID_PROCESS_ID;<br>
-}<br>
-<br>
-const char *ProcessInfo::GetName() const {<br>
- return m_executable.GetFilename().GetCString();<br>
-}<br>
-<br>
-size_t ProcessInfo::GetNameLength() const {<br>
- return m_executable.GetFilename().GetLength();<br>
-}<br>
-<br>
-void ProcessInfo::Dump(Stream &s, Platform *platform) const {<br>
- s << "Executable: " << GetName() << "\n";<br>
- s << "Triple: ";<br>
- m_arch.DumpTriple(s);<br>
- s << "\n";<br>
-<br>
- s << "Arguments:\n";<br>
- m_arguments.Dump(s);<br>
-<br>
- s.Format("Environment:\n{0}", m_environment);<br>
-}<br>
-<br>
-void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,<br>
- bool add_exe_file_as_first_arg) {<br>
- if (exe_file) {<br>
- m_executable = exe_file;<br>
- if (add_exe_file_as_first_arg) {<br>
- llvm::SmallString<128> filename;<br>
- exe_file.GetPath(filename);<br>
- if (!filename.empty())<br>
- m_arguments.InsertArgumentAtIndex(0, filename);<br>
- }<br>
- } else {<br>
- m_executable.Clear();<br>
- }<br>
-}<br>
-<br>
-llvm::StringRef ProcessInfo::GetArg0() const {<br>
- return m_arg0;<br>
-}<br>
-<br>
-void ProcessInfo::SetArg0(llvm::StringRef arg) {<br>
- m_arg0 = arg;<br>
-}<br>
-<br>
-void ProcessInfo::SetArguments(char const **argv,<br>
- bool first_arg_is_executable) {<br>
- m_arguments.SetArguments(argv);<br>
-<br>
- // Is the first argument the executable?<br>
- if (first_arg_is_executable) {<br>
- const char *first_arg = m_arguments.GetArgumentAtIndex(0);<br>
- if (first_arg) {<br>
- // Yes the first argument is an executable, set it as the executable in<br>
- // the launch options. Don't resolve the file path as the path could be a<br>
- // remote platform path<br>
- m_executable.SetFile(first_arg, FileSpec::Style::native);<br>
- }<br>
- }<br>
-}<br>
-<br>
-void ProcessInfo::SetArguments(const Args &args, bool first_arg_is_executable) {<br>
- // Copy all arguments<br>
- m_arguments = args;<br>
-<br>
- // Is the first argument the executable?<br>
- if (first_arg_is_executable) {<br>
- const char *first_arg = m_arguments.GetArgumentAtIndex(0);<br>
- if (first_arg) {<br>
- // Yes the first argument is an executable, set it as the executable in<br>
- // the launch options. Don't resolve the file path as the path could be a<br>
- // remote platform path<br>
- m_executable.SetFile(first_arg, FileSpec::Style::native);<br>
- }<br>
- }<br>
-}<br>
<br>
Modified: lldb/trunk/source/Host/freebsd/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/freebsd/Host.cpp (original)<br>
+++ lldb/trunk/source/Host/freebsd/Host.cpp Mon Mar 4 13:51:03 2019<br>
@@ -23,12 +23,12 @@<br>
<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Utility/DataBufferHeap.h"<br>
#include "lldb/Utility/DataExtractor.h"<br>
#include "lldb/Utility/Endian.h"<br>
#include "lldb/Utility/Log.h"<br>
#include "lldb/Utility/NameMatches.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
<br>
@@ -38,6 +38,10 @@ extern "C" {<br>
extern char **environ;<br>
}<br>
<br>
+namespace lldb_private {<br>
+class ProcessLaunchInfo;<br>
+}<br>
+<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
<br>
Modified: lldb/trunk/source/Host/linux/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/linux/Host.cpp (original)<br>
+++ lldb/trunk/source/Host/linux/Host.cpp Mon Mar 4 13:51:03 2019<br>
@@ -19,7 +19,6 @@<br>
#include "llvm/Object/ELF.h"<br>
#include "llvm/Support/ScopedPrinter.h"<br>
<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Utility/Log.h"<br>
#include "lldb/Utility/Status.h"<br>
<br>
@@ -44,6 +43,10 @@ enum class ProcessState {<br>
};<br>
}<br>
<br>
+namespace lldb_private {<br>
+class ProcessLaunchInfo;<br>
+}<br>
+<br>
static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,<br>
ProcessState &State, ::pid_t &TracerPid) {<br>
auto BufferOrError = getProcFile(Pid, "status");<br>
<br>
Modified: lldb/trunk/source/Host/macosx/objcxx/Host.mm<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/objcxx/Host.mm?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/objcxx/Host.mm?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/macosx/objcxx/Host.mm (original)<br>
+++ lldb/trunk/source/Host/macosx/objcxx/Host.mm Mon Mar 4 13:51:03 2019<br>
@@ -58,7 +58,6 @@<br>
#include "lldb/Host/HostInfo.h"<br>
#include "lldb/Host/ProcessLaunchInfo.h"<br>
#include "lldb/Host/ThreadLauncher.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Utility/ArchSpec.h"<br>
#include "lldb/Utility/CleanUp.h"<br>
#include "lldb/Utility/DataBufferHeap.h"<br>
@@ -67,6 +66,7 @@<br>
#include "lldb/Utility/FileSpec.h"<br>
#include "lldb/Utility/Log.h"<br>
#include "lldb/Utility/NameMatches.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/StreamString.h"<br>
#include "lldb/Utility/StructuredData.h"<br>
#include "lldb/lldb-defines.h"<br>
<br>
Modified: lldb/trunk/source/Host/netbsd/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/netbsd/Host.cpp (original)<br>
+++ lldb/trunk/source/Host/netbsd/Host.cpp Mon Mar 4 13:51:03 2019<br>
@@ -22,12 +22,12 @@<br>
<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Utility/DataBufferHeap.h"<br>
#include "lldb/Utility/DataExtractor.h"<br>
#include "lldb/Utility/Endian.h"<br>
#include "lldb/Utility/Log.h"<br>
#include "lldb/Utility/NameMatches.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
<br>
@@ -40,6 +40,10 @@ extern char **environ;<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
+namespace lldb_private {<br>
+class ProcessLaunchInfo;<br>
+}<br>
+<br>
Environment Host::GetEnvironment() { return Environment(environ); }<br>
<br>
static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,<br>
<br>
Modified: lldb/trunk/source/Host/openbsd/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/openbsd/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/openbsd/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/openbsd/Host.cpp (original)<br>
+++ lldb/trunk/source/Host/openbsd/Host.cpp Mon Mar 4 13:51:03 2019<br>
@@ -19,12 +19,12 @@<br>
<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Utility/DataBufferHeap.h"<br>
#include "lldb/Utility/DataExtractor.h"<br>
#include "lldb/Utility/Endian.h"<br>
#include "lldb/Utility/Log.h"<br>
#include "lldb/Utility/NameMatches.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
<br>
@@ -37,6 +37,10 @@ extern char **environ;<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
+namespace lldb_private {<br>
+class ProcessLaunchInfo;<br>
+}<br>
+<br>
Environment Host::GetEnvironment() {<br>
Environment env;<br>
char *v;<br>
<br>
Modified: lldb/trunk/source/Host/posix/HostInfoPosix.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/HostInfoPosix.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/HostInfoPosix.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/posix/HostInfoPosix.cpp (original)<br>
+++ lldb/trunk/source/Host/posix/HostInfoPosix.cpp Mon Mar 4 13:51:03 2019<br>
@@ -105,7 +105,7 @@ llvm::Optional<std::string> PosixUserIDR<br>
<br>
static llvm::ManagedStatic<PosixUserIDResolver> g_user_id_resolver;<br>
<br>
-UserIDResolver &HostInfoPosix::GetUserIDResolver() {<br>
+UserIDResolver &HostInfoBase::GetUserIDResolver() {<br>
return *g_user_id_resolver;<br>
}<br>
<br>
<br>
Modified: lldb/trunk/source/Host/windows/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Host/windows/Host.cpp (original)<br>
+++ lldb/trunk/source/Host/windows/Host.cpp Mon Mar 4 13:51:03 2019<br>
@@ -13,11 +13,13 @@<br>
#include "lldb/Host/FileSystem.h"<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
-#include "lldb/Target/Process.h"<br>
+#include "lldb/Host/ProcessLaunchInfo.h"<br>
#include "lldb/Utility/DataBufferHeap.h"<br>
#include "lldb/Utility/DataExtractor.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
+#include "lldb/Utility/StreamString.h"<br>
#include "lldb/Utility/StructuredData.h"<br>
<br>
#include "llvm/Support/ConvertUTF.h"<br>
<br>
Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (original)<br>
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Mon Mar 4 13:51:03 2019<br>
@@ -20,11 +20,11 @@<br>
#include "lldb/Symbol/ObjectFile.h"<br>
#include "lldb/Target/MemoryRegionInfo.h"<br>
#include "lldb/Target/Platform.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Target/Target.h"<br>
#include "lldb/Target/Thread.h"<br>
#include "lldb/Target/ThreadPlanRunToAddress.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
<br>
#include <memory><br>
<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp Mon Mar 4 13:51:03 2019<br>
@@ -15,11 +15,11 @@<br>
#include "lldb/Core/PluginManager.h"<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Target/Target.h"<br>
#include "lldb/Utility/ArchSpec.h"<br>
#include "lldb/Utility/FileSpec.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
<br>
@@ -28,6 +28,10 @@<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
+namespace lldb_private {<br>
+class Process;<br>
+}<br>
+<br>
//------------------------------------------------------------------<br>
// Static Variables<br>
//------------------------------------------------------------------<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp Mon Mar 4 13:51:03 2019<br>
@@ -16,16 +16,20 @@<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
#include "lldb/Target/Process.h"<br>
-#include "lldb/Target/Target.h"<br>
#include "lldb/Utility/ArchSpec.h"<br>
#include "lldb/Utility/FileSpec.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
+namespace lldb_private {<br>
+class Process;<br>
+}<br>
+<br>
//------------------------------------------------------------------<br>
// Static Variables<br>
//------------------------------------------------------------------<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Mar 4 13:51:03 2019<br>
@@ -31,6 +31,7 @@<br>
#include "lldb/Target/Process.h"<br>
#include "lldb/Target/Target.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/Timer.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Mon Mar 4 13:51:03 2019<br>
@@ -16,11 +16,11 @@<br>
#include "lldb/Core/PluginManager.h"<br>
#include "lldb/Host/Host.h"<br>
#include "lldb/Host/HostInfo.h"<br>
-#include "lldb/Target/Process.h"<br>
#include "lldb/Target/Target.h"<br>
#include "lldb/Utility/ArchSpec.h"<br>
#include "lldb/Utility/FileSpec.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
<br>
@@ -29,6 +29,10 @@<br>
using namespace lldb;<br>
using namespace lldb_private;<br>
<br>
+namespace lldb_private {<br>
+class Process;<br>
+}<br>
+<br>
//------------------------------------------------------------------<br>
// Static Variables<br>
//------------------------------------------------------------------<br>
<br>
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Mon Mar 4 13:51:03 2019<br>
@@ -24,6 +24,7 @@<br>
#include "lldb/Target/Target.h"<br>
#include "lldb/Utility/FileSpec.h"<br>
#include "lldb/Utility/Log.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/Status.h"<br>
#include "lldb/Utility/StreamString.h"<br>
#include "lldb/Utility/UriParser.h"<br>
<br>
Modified: lldb/trunk/source/Target/Process.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Target/Process.cpp (original)<br>
+++ lldb/trunk/source/Target/Process.cpp Mon Mar 4 13:51:03 2019<br>
@@ -64,6 +64,7 @@<br>
#include "lldb/Utility/Event.h"<br>
#include "lldb/Utility/Log.h"<br>
#include "lldb/Utility/NameMatches.h"<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
#include "lldb/Utility/SelectHelper.h"<br>
#include "lldb/Utility/State.h"<br>
<br>
@@ -278,123 +279,6 @@ bool ProcessProperties::GetStopOnExec()<br>
nullptr, idx, g_properties[idx].default_uint_value != 0);<br>
}<br>
<br>
-void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {<br>
- if (m_pid != LLDB_INVALID_PROCESS_ID)<br>
- s.Printf(" pid = %" PRIu64 "\n", m_pid);<br>
-<br>
- if (m_parent_pid != LLDB_INVALID_PROCESS_ID)<br>
- s.Printf(" parent = %" PRIu64 "\n", m_parent_pid);<br>
-<br>
- if (m_executable) {<br>
- s.Printf(" name = %s\n", m_executable.GetFilename().GetCString());<br>
- s.PutCString(" file = ");<br>
- m_executable.Dump(&s);<br>
- s.EOL();<br>
- }<br>
- const uint32_t argc = m_arguments.GetArgumentCount();<br>
- if (argc > 0) {<br>
- for (uint32_t i = 0; i < argc; i++) {<br>
- const char *arg = m_arguments.GetArgumentAtIndex(i);<br>
- if (i < 10)<br>
- s.Printf(" arg[%u] = %s\n", i, arg);<br>
- else<br>
- s.Printf("arg[%u] = %s\n", i, arg);<br>
- }<br>
- }<br>
-<br>
- s.Format("{0}", m_environment);<br>
-<br>
- if (m_arch.IsValid()) {<br>
- s.Printf(" arch = ");<br>
- m_arch.DumpTriple(s);<br>
- s.EOL();<br>
- }<br>
-<br>
- if (UserIDIsValid()) {<br>
- s.Format(" uid = {0,-5} ({1})\n", GetUserID(),<br>
- resolver.GetUserName(GetUserID()).getValueOr(""));<br>
- }<br>
- if (GroupIDIsValid()) {<br>
- s.Format(" gid = {0,-5} ({1})\n", GetGroupID(),<br>
- resolver.GetGroupName(GetGroupID()).getValueOr(""));<br>
- }<br>
- if (EffectiveUserIDIsValid()) {<br>
- s.Format(" euid = {0,-5} ({1})\n", GetEffectiveUserID(),<br>
- resolver.GetUserName(GetEffectiveUserID()).getValueOr(""));<br>
- }<br>
- if (EffectiveGroupIDIsValid()) {<br>
- s.Format(" egid = {0,-5} ({1})\n", GetEffectiveGroupID(),<br>
- resolver.GetGroupName(GetEffectiveGroupID()).getValueOr(""));<br>
- }<br>
-}<br>
-<br>
-void ProcessInstanceInfo::DumpTableHeader(Stream &s, bool show_args,<br>
- bool verbose) {<br>
- const char *label;<br>
- if (show_args || verbose)<br>
- label = "ARGUMENTS";<br>
- else<br>
- label = "NAME";<br>
-<br>
- if (verbose) {<br>
- s.Printf("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE "<br>
- " %s\n",<br>
- label);<br>
- s.PutCString("====== ====== ========== ========== ========== ========== "<br>
- "======================== ============================\n");<br>
- } else {<br>
- s.Printf("PID PARENT USER TRIPLE %s\n", label);<br>
- s.PutCString("====== ====== ========== ======================== "<br>
- "============================\n");<br>
- }<br>
-}<br>
-<br>
-void ProcessInstanceInfo::DumpAsTableRow(Stream &s, UserIDResolver &resolver,<br>
- bool show_args, bool verbose) const {<br>
- if (m_pid != LLDB_INVALID_PROCESS_ID) {<br>
- s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", m_pid, m_parent_pid);<br>
-<br>
- StreamString arch_strm;<br>
- if (m_arch.IsValid())<br>
- m_arch.DumpTriple(arch_strm);<br>
-<br>
- auto print = [&](UserIDResolver::id_t id,<br>
- llvm::Optional<llvm::StringRef> (UserIDResolver::*get)(<br>
- UserIDResolver::id_t id)) {<br>
- if (auto name = (resolver.*get)(id))<br>
- s.Format("{0,-10} ", *name);<br>
- else<br>
- s.Format("{0,-10} ", id);<br>
- };<br>
- if (verbose) {<br>
- print(m_uid, &UserIDResolver::GetUserName);<br>
- print(m_gid, &UserIDResolver::GetGroupName);<br>
- print(m_euid, &UserIDResolver::GetUserName);<br>
- print(m_egid, &UserIDResolver::GetGroupName);<br>
-<br>
- s.Printf("%-24s ", arch_strm.GetData());<br>
- } else {<br>
- print(m_euid, &UserIDResolver::GetUserName);<br>
- s.Printf(" %-24s ", arch_strm.GetData());<br>
- }<br>
-<br>
- if (verbose || show_args) {<br>
- const uint32_t argc = m_arguments.GetArgumentCount();<br>
- if (argc > 0) {<br>
- for (uint32_t i = 0; i < argc; i++) {<br>
- if (i > 0)<br>
- s.PutChar(' ');<br>
- s.PutCString(m_arguments.GetArgumentAtIndex(i));<br>
- }<br>
- }<br>
- } else {<br>
- s.PutCString(GetName());<br>
- }<br>
-<br>
- s.EOL();<br>
- }<br>
-}<br>
-<br>
Status ProcessLaunchCommandOptions::SetOptionValue(<br>
uint32_t option_idx, llvm::StringRef option_arg,<br>
ExecutionContext *execution_context) {<br>
@@ -564,89 +448,6 @@ llvm::ArrayRef<OptionDefinition> Process<br>
return llvm::makeArrayRef(g_process_launch_options);<br>
}<br>
<br>
-bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {<br>
- if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)<br>
- return true;<br>
- const char *match_name = m_match_info.GetName();<br>
- if (!match_name)<br>
- return true;<br>
-<br>
- return lldb_private::NameMatches(process_name, m_name_match_type, match_name);<br>
-}<br>
-<br>
-bool ProcessInstanceInfoMatch::Matches(<br>
- const ProcessInstanceInfo &proc_info) const {<br>
- if (!NameMatches(proc_info.GetName()))<br>
- return false;<br>
-<br>
- if (m_match_info.ProcessIDIsValid() &&<br>
- m_match_info.GetProcessID() != proc_info.GetProcessID())<br>
- return false;<br>
-<br>
- if (m_match_info.ParentProcessIDIsValid() &&<br>
- m_match_info.GetParentProcessID() != proc_info.GetParentProcessID())<br>
- return false;<br>
-<br>
- if (m_match_info.UserIDIsValid() &&<br>
- m_match_info.GetUserID() != proc_info.GetUserID())<br>
- return false;<br>
-<br>
- if (m_match_info.GroupIDIsValid() &&<br>
- m_match_info.GetGroupID() != proc_info.GetGroupID())<br>
- return false;<br>
-<br>
- if (m_match_info.EffectiveUserIDIsValid() &&<br>
- m_match_info.GetEffectiveUserID() != proc_info.GetEffectiveUserID())<br>
- return false;<br>
-<br>
- if (m_match_info.EffectiveGroupIDIsValid() &&<br>
- m_match_info.GetEffectiveGroupID() != proc_info.GetEffectiveGroupID())<br>
- return false;<br>
-<br>
- if (m_match_info.GetArchitecture().IsValid() &&<br>
- !m_match_info.GetArchitecture().IsCompatibleMatch(<br>
- proc_info.GetArchitecture()))<br>
- return false;<br>
- return true;<br>
-}<br>
-<br>
-bool ProcessInstanceInfoMatch::MatchAllProcesses() const {<br>
- if (m_name_match_type != NameMatch::Ignore)<br>
- return false;<br>
-<br>
- if (m_match_info.ProcessIDIsValid())<br>
- return false;<br>
-<br>
- if (m_match_info.ParentProcessIDIsValid())<br>
- return false;<br>
-<br>
- if (m_match_info.UserIDIsValid())<br>
- return false;<br>
-<br>
- if (m_match_info.GroupIDIsValid())<br>
- return false;<br>
-<br>
- if (m_match_info.EffectiveUserIDIsValid())<br>
- return false;<br>
-<br>
- if (m_match_info.EffectiveGroupIDIsValid())<br>
- return false;<br>
-<br>
- if (m_match_info.GetArchitecture().IsValid())<br>
- return false;<br>
-<br>
- if (m_match_all_users)<br>
- return false;<br>
-<br>
- return true;<br>
-}<br>
-<br>
-void ProcessInstanceInfoMatch::Clear() {<br>
- m_match_info.Clear();<br>
- m_name_match_type = NameMatch::Ignore;<br>
- m_match_all_users = false;<br>
-}<br>
-<br>
ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,<br>
llvm::StringRef plugin_name,<br>
ListenerSP listener_sp,<br>
@@ -4267,11 +4068,11 @@ void Process::ProcessEventData::DoOnRemo<br>
process_sp->GetTarget().RunStopHooks();<br>
if (process_sp->GetPrivateState() == eStateRunning)<br>
SetRestarted(true);<br>
- }<br>
}<br>
}<br>
}<br>
}<br>
+}<br>
<br>
void Process::ProcessEventData::Dump(Stream *s) const {<br>
ProcessSP process_sp(m_process_wp.lock());<br>
<br>
Modified: lldb/trunk/source/Utility/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Utility/CMakeLists.txt (original)<br>
+++ lldb/trunk/source/Utility/CMakeLists.txt Mon Mar 4 13:51:03 2019<br>
@@ -64,6 +64,7 @@ add_lldb_library(lldbUtility<br>
Log.cpp<br>
Logging.cpp<br>
NameMatches.cpp<br>
+ ProcessInfo.cpp<br>
RegisterValue.cpp<br>
RegularExpression.cpp<br>
Reproducer.cpp<br>
<br>
Added: lldb/trunk/source/Utility/ProcessInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ProcessInfo.cpp?rev=355342&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ProcessInfo.cpp?rev=355342&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Utility/ProcessInfo.cpp (added)<br>
+++ lldb/trunk/source/Utility/ProcessInfo.cpp Mon Mar 4 13:51:03 2019<br>
@@ -0,0 +1,310 @@<br>
+//===-- ProcessInstance.cpp -------------------------------------*- C++ -*-===//<br>
+//<br>
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
+// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
+<br>
+#include "lldb/Utility/ArchSpec.h"<br>
+#include "lldb/Utility/Stream.h"<br>
+#include "lldb/Utility/StreamString.h"<br>
+#include "lldb/Utility/UserIDResolver.h"<br>
+#include "llvm/ADT/SmallString.h"<br>
+<br>
+#include <climits><br>
+<br>
+using namespace lldb;<br>
+using namespace lldb_private;<br>
+<br>
+ProcessInfo::ProcessInfo()<br>
+ : m_executable(), m_arguments(), m_environment(), m_uid(UINT32_MAX),<br>
+ m_gid(UINT32_MAX), m_arch(), m_pid(LLDB_INVALID_PROCESS_ID) {}<br>
+<br>
+ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,<br>
+ lldb::pid_t pid)<br>
+ : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX),<br>
+ m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}<br>
+<br>
+void ProcessInfo::Clear() {<br>
+ m_executable.Clear();<br>
+ m_arguments.Clear();<br>
+ m_environment.clear();<br>
+ m_uid = UINT32_MAX;<br>
+ m_gid = UINT32_MAX;<br>
+ m_arch.Clear();<br>
+ m_pid = LLDB_INVALID_PROCESS_ID;<br>
+}<br>
+<br>
+const char *ProcessInfo::GetName() const {<br>
+ return m_executable.GetFilename().GetCString();<br>
+}<br>
+<br>
+size_t ProcessInfo::GetNameLength() const {<br>
+ return m_executable.GetFilename().GetLength();<br>
+}<br>
+<br>
+void ProcessInfo::Dump(Stream &s, Platform *platform) const {<br>
+ s << "Executable: " << GetName() << "\n";<br>
+ s << "Triple: ";<br>
+ m_arch.DumpTriple(s);<br>
+ s << "\n";<br>
+<br>
+ s << "Arguments:\n";<br>
+ m_arguments.Dump(s);<br>
+<br>
+ s.Format("Environment:\n{0}", m_environment);<br>
+}<br>
+<br>
+void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,<br>
+ bool add_exe_file_as_first_arg) {<br>
+ if (exe_file) {<br>
+ m_executable = exe_file;<br>
+ if (add_exe_file_as_first_arg) {<br>
+ llvm::SmallString<128> filename;<br>
+ exe_file.GetPath(filename);<br>
+ if (!filename.empty())<br>
+ m_arguments.InsertArgumentAtIndex(0, filename);<br>
+ }<br>
+ } else {<br>
+ m_executable.Clear();<br>
+ }<br>
+}<br>
+<br>
+llvm::StringRef ProcessInfo::GetArg0() const { return m_arg0; }<br>
+<br>
+void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = arg; }<br>
+<br>
+void ProcessInfo::SetArguments(char const **argv,<br>
+ bool first_arg_is_executable) {<br>
+ m_arguments.SetArguments(argv);<br>
+<br>
+ // Is the first argument the executable?<br>
+ if (first_arg_is_executable) {<br>
+ const char *first_arg = m_arguments.GetArgumentAtIndex(0);<br>
+ if (first_arg) {<br>
+ // Yes the first argument is an executable, set it as the executable in<br>
+ // the launch options. Don't resolve the file path as the path could be a<br>
+ // remote platform path<br>
+ m_executable.SetFile(first_arg, FileSpec::Style::native);<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+void ProcessInfo::SetArguments(const Args &args, bool first_arg_is_executable) {<br>
+ // Copy all arguments<br>
+ m_arguments = args;<br>
+<br>
+ // Is the first argument the executable?<br>
+ if (first_arg_is_executable) {<br>
+ const char *first_arg = m_arguments.GetArgumentAtIndex(0);<br>
+ if (first_arg) {<br>
+ // Yes the first argument is an executable, set it as the executable in<br>
+ // the launch options. Don't resolve the file path as the path could be a<br>
+ // remote platform path<br>
+ m_executable.SetFile(first_arg, FileSpec::Style::native);<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {<br>
+ if (m_pid != LLDB_INVALID_PROCESS_ID)<br>
+ s.Printf(" pid = %" PRIu64 "\n", m_pid);<br>
+<br>
+ if (m_parent_pid != LLDB_INVALID_PROCESS_ID)<br>
+ s.Printf(" parent = %" PRIu64 "\n", m_parent_pid);<br>
+<br>
+ if (m_executable) {<br>
+ s.Printf(" name = %s\n", m_executable.GetFilename().GetCString());<br>
+ s.PutCString(" file = ");<br>
+ m_executable.Dump(&s);<br>
+ s.EOL();<br>
+ }<br>
+ const uint32_t argc = m_arguments.GetArgumentCount();<br>
+ if (argc > 0) {<br>
+ for (uint32_t i = 0; i < argc; i++) {<br>
+ const char *arg = m_arguments.GetArgumentAtIndex(i);<br>
+ if (i < 10)<br>
+ s.Printf(" arg[%u] = %s\n", i, arg);<br>
+ else<br>
+ s.Printf("arg[%u] = %s\n", i, arg);<br>
+ }<br>
+ }<br>
+<br>
+ s.Format("{0}", m_environment);<br>
+<br>
+ if (m_arch.IsValid()) {<br>
+ s.Printf(" arch = ");<br>
+ m_arch.DumpTriple(s);<br>
+ s.EOL();<br>
+ }<br>
+<br>
+ if (UserIDIsValid()) {<br>
+ s.Format(" uid = {0,-5} ({1})\n", GetUserID(),<br>
+ resolver.GetUserName(GetUserID()).getValueOr(""));<br>
+ }<br>
+ if (GroupIDIsValid()) {<br>
+ s.Format(" gid = {0,-5} ({1})\n", GetGroupID(),<br>
+ resolver.GetGroupName(GetGroupID()).getValueOr(""));<br>
+ }<br>
+ if (EffectiveUserIDIsValid()) {<br>
+ s.Format(" euid = {0,-5} ({1})\n", GetEffectiveUserID(),<br>
+ resolver.GetUserName(GetEffectiveUserID()).getValueOr(""));<br>
+ }<br>
+ if (EffectiveGroupIDIsValid()) {<br>
+ s.Format(" egid = {0,-5} ({1})\n", GetEffectiveGroupID(),<br>
+ resolver.GetGroupName(GetEffectiveGroupID()).getValueOr(""));<br>
+ }<br>
+}<br>
+<br>
+void ProcessInstanceInfo::DumpTableHeader(Stream &s, bool show_args,<br>
+ bool verbose) {<br>
+ const char *label;<br>
+ if (show_args || verbose)<br>
+ label = "ARGUMENTS";<br>
+ else<br>
+ label = "NAME";<br>
+<br>
+ if (verbose) {<br>
+ s.Printf("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE "<br>
+ " %s\n",<br>
+ label);<br>
+ s.PutCString("====== ====== ========== ========== ========== ========== "<br>
+ "======================== ============================\n");<br>
+ } else {<br>
+ s.Printf("PID PARENT USER TRIPLE %s\n", label);<br>
+ s.PutCString("====== ====== ========== ======================== "<br>
+ "============================\n");<br>
+ }<br>
+}<br>
+<br>
+void ProcessInstanceInfo::DumpAsTableRow(Stream &s, UserIDResolver &resolver,<br>
+ bool show_args, bool verbose) const {<br>
+ if (m_pid != LLDB_INVALID_PROCESS_ID) {<br>
+ s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", m_pid, m_parent_pid);<br>
+<br>
+ StreamString arch_strm;<br>
+ if (m_arch.IsValid())<br>
+ m_arch.DumpTriple(arch_strm);<br>
+<br>
+ auto print = [&](UserIDResolver::id_t id,<br>
+ llvm::Optional<llvm::StringRef> (UserIDResolver::*get)(<br>
+ UserIDResolver::id_t id)) {<br>
+ if (auto name = (resolver.*get)(id))<br>
+ s.Format("{0,-10} ", *name);<br>
+ else<br>
+ s.Format("{0,-10} ", id);<br>
+ };<br>
+ if (verbose) {<br>
+ print(m_uid, &UserIDResolver::GetUserName);<br>
+ print(m_gid, &UserIDResolver::GetGroupName);<br>
+ print(m_euid, &UserIDResolver::GetUserName);<br>
+ print(m_egid, &UserIDResolver::GetGroupName);<br>
+<br>
+ s.Printf("%-24s ", arch_strm.GetData());<br>
+ } else {<br>
+ print(m_euid, &UserIDResolver::GetUserName);<br>
+ s.Printf(" %-24s ", arch_strm.GetData());<br>
+ }<br>
+<br>
+ if (verbose || show_args) {<br>
+ const uint32_t argc = m_arguments.GetArgumentCount();<br>
+ if (argc > 0) {<br>
+ for (uint32_t i = 0; i < argc; i++) {<br>
+ if (i > 0)<br>
+ s.PutChar(' ');<br>
+ s.PutCString(m_arguments.GetArgumentAtIndex(i));<br>
+ }<br>
+ }<br>
+ } else {<br>
+ s.PutCString(GetName());<br>
+ }<br>
+<br>
+ s.EOL();<br>
+ }<br>
+}<br>
+<br>
+bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {<br>
+ if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)<br>
+ return true;<br>
+ const char *match_name = m_match_info.GetName();<br>
+ if (!match_name)<br>
+ return true;<br>
+<br>
+ return lldb_private::NameMatches(process_name, m_name_match_type, match_name);<br>
+}<br>
+<br>
+bool ProcessInstanceInfoMatch::Matches(<br>
+ const ProcessInstanceInfo &proc_info) const {<br>
+ if (!NameMatches(proc_info.GetName()))<br>
+ return false;<br>
+<br>
+ if (m_match_info.ProcessIDIsValid() &&<br>
+ m_match_info.GetProcessID() != proc_info.GetProcessID())<br>
+ return false;<br>
+<br>
+ if (m_match_info.ParentProcessIDIsValid() &&<br>
+ m_match_info.GetParentProcessID() != proc_info.GetParentProcessID())<br>
+ return false;<br>
+<br>
+ if (m_match_info.UserIDIsValid() &&<br>
+ m_match_info.GetUserID() != proc_info.GetUserID())<br>
+ return false;<br>
+<br>
+ if (m_match_info.GroupIDIsValid() &&<br>
+ m_match_info.GetGroupID() != proc_info.GetGroupID())<br>
+ return false;<br>
+<br>
+ if (m_match_info.EffectiveUserIDIsValid() &&<br>
+ m_match_info.GetEffectiveUserID() != proc_info.GetEffectiveUserID())<br>
+ return false;<br>
+<br>
+ if (m_match_info.EffectiveGroupIDIsValid() &&<br>
+ m_match_info.GetEffectiveGroupID() != proc_info.GetEffectiveGroupID())<br>
+ return false;<br>
+<br>
+ if (m_match_info.GetArchitecture().IsValid() &&<br>
+ !m_match_info.GetArchitecture().IsCompatibleMatch(<br>
+ proc_info.GetArchitecture()))<br>
+ return false;<br>
+ return true;<br>
+}<br>
+<br>
+bool ProcessInstanceInfoMatch::MatchAllProcesses() const {<br>
+ if (m_name_match_type != NameMatch::Ignore)<br>
+ return false;<br>
+<br>
+ if (m_match_info.ProcessIDIsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_info.ParentProcessIDIsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_info.UserIDIsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_info.GroupIDIsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_info.EffectiveUserIDIsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_info.EffectiveGroupIDIsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_info.GetArchitecture().IsValid())<br>
+ return false;<br>
+<br>
+ if (m_match_all_users)<br>
+ return false;<br>
+<br>
+ return true;<br>
+}<br>
+<br>
+void ProcessInstanceInfoMatch::Clear() {<br>
+ m_match_info.Clear();<br>
+ m_name_match_type = NameMatch::Ignore;<br>
+ m_match_all_users = false;<br>
+}<br>
<br>
Modified: lldb/trunk/unittests/Host/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/unittests/Host/CMakeLists.txt (original)<br>
+++ lldb/trunk/unittests/Host/CMakeLists.txt Mon Mar 4 13:51:03 2019<br>
@@ -5,7 +5,6 @@ set (FILES<br>
HostTest.cpp<br>
MainLoopTest.cpp<br>
NativeProcessProtocolTest.cpp<br>
- ProcessInfoTest.cpp<br>
ProcessLaunchInfoTest.cpp<br>
SocketAddressTest.cpp<br>
SocketTest.cpp<br>
<br>
Removed: lldb/trunk/unittests/Host/ProcessInfoTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/ProcessInfoTest.cpp?rev=355341&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/ProcessInfoTest.cpp?rev=355341&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/unittests/Host/ProcessInfoTest.cpp (original)<br>
+++ lldb/trunk/unittests/Host/ProcessInfoTest.cpp (removed)<br>
@@ -1,19 +0,0 @@<br>
-//===-- ProcessInfoTest.cpp -------------------------------------*- C++ -*-===//<br>
-//<br>
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
-// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include "lldb/Host/ProcessInfo.h"<br>
-#include "gtest/gtest.h"<br>
-<br>
-using namespace lldb_private;<br>
-<br>
-TEST(ProcessInfoTest, Constructor) {<br>
- ProcessInfo Info("foo", ArchSpec("x86_64-pc-linux"), 47);<br>
- EXPECT_STREQ("foo", Info.GetName());<br>
- EXPECT_EQ(ArchSpec("x86_64-pc-linux"), Info.GetArchitecture());<br>
- EXPECT_EQ(47u, Info.GetProcessID());<br>
-}<br>
<br>
Modified: lldb/trunk/unittests/Utility/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=355342&r1=355341&r2=355342&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/unittests/Utility/CMakeLists.txt (original)<br>
+++ lldb/trunk/unittests/Utility/CMakeLists.txt Mon Mar 4 13:51:03 2019<br>
@@ -18,6 +18,7 @@ add_lldb_unittest(UtilityTests<br>
LogTest.cpp<br>
NameMatchesTest.cpp<br>
PredicateTest.cpp<br>
+ ProcessInfoTest.cpp<br>
RegisterValueTest.cpp<br>
ReproducerTest.cpp<br>
ReproducerInstrumentationTest.cpp<br>
<br>
Added: lldb/trunk/unittests/Utility/ProcessInfoTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ProcessInfoTest.cpp?rev=355342&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ProcessInfoTest.cpp?rev=355342&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/unittests/Utility/ProcessInfoTest.cpp (added)<br>
+++ lldb/trunk/unittests/Utility/ProcessInfoTest.cpp Mon Mar 4 13:51:03 2019<br>
@@ -0,0 +1,19 @@<br>
+//===-- ProcessInfoTest.cpp -------------------------------------*- C++ -*-===//<br>
+//<br>
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
+// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "lldb/Utility/ProcessInfo.h"<br>
+#include "gtest/gtest.h"<br>
+<br>
+using namespace lldb_private;<br>
+<br>
+TEST(ProcessInfoTest, Constructor) {<br>
+ ProcessInfo Info("foo", ArchSpec("x86_64-pc-linux"), 47);<br>
+ EXPECT_STREQ("foo", Info.GetName());<br>
+ EXPECT_EQ(ArchSpec("x86_64-pc-linux"), Info.GetArchitecture());<br>
+ EXPECT_EQ(47u, Info.GetProcessID());<br>
+}<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>