[Lldb-commits] [lldb] r355342 - Move ProcessInfo from Host to Utility.

Alexander Kornienko via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 5 04:04:51 PST 2019


FYI, this commit has broken host build on Linux:
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/35862
.
Trying to fix with r355392.

On Mon, Mar 4, 2019 at 10:50 PM Zachary Turner via lldb-commits <
lldb-commits at lists.llvm.org> wrote:

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


More information about the lldb-commits mailing list