zturner created this revision. zturner added reviewers: jingham, labath, JDevlieghere. Herald added subscribers: jdoerfert, mgorny, emaste.
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 this class 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 are only 2 remaining references to Target from Host, neither of which is terribly difficult to fix on its own and which I'll address in followups. https://reviews.llvm.org/D58842 Files: lldb/include/lldb/Host/Host.h lldb/include/lldb/Host/ProcessInfo.h lldb/include/lldb/Host/ProcessLaunchInfo.h lldb/include/lldb/Target/Platform.h lldb/include/lldb/Target/Process.h lldb/include/lldb/Utility/ProcessInfo.h lldb/include/lldb/module.modulemap lldb/source/API/SBProcess.cpp lldb/source/API/SBProcessInfo.cpp lldb/source/API/SBTarget.cpp lldb/source/Commands/CommandObjectPlatform.cpp lldb/source/Host/CMakeLists.txt lldb/source/Host/common/ProcessInfo.cpp lldb/source/Host/freebsd/Host.cpp lldb/source/Host/linux/Host.cpp lldb/source/Host/netbsd/Host.cpp lldb/source/Host/openbsd/Host.cpp lldb/source/Host/windows/Host.cpp lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/source/Target/Process.cpp lldb/source/Utility/CMakeLists.txt lldb/source/Utility/ProcessInfo.cpp lldb/unittests/Host/CMakeLists.txt lldb/unittests/Host/ProcessInfoTest.cpp lldb/unittests/Utility/CMakeLists.txt lldb/unittests/Utility/ProcessInfoTest.cpp
Index: lldb/unittests/Utility/ProcessInfoTest.cpp =================================================================== --- lldb/unittests/Utility/ProcessInfoTest.cpp +++ lldb/unittests/Utility/ProcessInfoTest.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Host/ProcessInfo.h" +#include "lldb/Utility/ProcessInfo.h" #include "gtest/gtest.h" using namespace lldb_private; Index: lldb/unittests/Utility/CMakeLists.txt =================================================================== --- lldb/unittests/Utility/CMakeLists.txt +++ lldb/unittests/Utility/CMakeLists.txt @@ -18,6 +18,7 @@ LogTest.cpp NameMatchesTest.cpp PredicateTest.cpp + ProcessInfoTest.cpp RegisterValueTest.cpp ReproducerTest.cpp ReproducerInstrumentationTest.cpp Index: lldb/unittests/Host/CMakeLists.txt =================================================================== --- lldb/unittests/Host/CMakeLists.txt +++ lldb/unittests/Host/CMakeLists.txt @@ -5,7 +5,6 @@ HostTest.cpp MainLoopTest.cpp NativeProcessProtocolTest.cpp - ProcessInfoTest.cpp ProcessLaunchInfoTest.cpp SocketAddressTest.cpp SocketTest.cpp Index: lldb/source/Utility/ProcessInfo.cpp =================================================================== --- lldb/source/Utility/ProcessInfo.cpp +++ lldb/source/Utility/ProcessInfo.cpp @@ -1,4 +1,4 @@ -//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===// +//===-- 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. @@ -6,15 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Host/ProcessInfo.h" +#include "lldb/Utility/ProcessInfo.h" -#include <climits> - -#include "lldb/Host/PosixApi.h" +#include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Stream.h" - #include "llvm/ADT/SmallString.h" +#include <climits> + using namespace lldb; using namespace lldb_private; @@ -72,13 +71,9 @@ } } -llvm::StringRef ProcessInfo::GetArg0() const { - return m_arg0; -} +llvm::StringRef ProcessInfo::GetArg0() const { return m_arg0; } -void ProcessInfo::SetArg0(llvm::StringRef arg) { - m_arg0 = arg; -} +void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = arg; } void ProcessInfo::SetArguments(char const **argv, bool first_arg_is_executable) { @@ -111,3 +106,86 @@ } } } + +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; +} Index: lldb/source/Utility/CMakeLists.txt =================================================================== --- lldb/source/Utility/CMakeLists.txt +++ lldb/source/Utility/CMakeLists.txt @@ -64,6 +64,7 @@ Log.cpp Logging.cpp NameMatches.cpp + ProcessInfo.cpp RegisterValue.cpp RegularExpression.cpp Reproducer.cpp Index: lldb/source/Target/Process.cpp =================================================================== --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -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,24 +279,27 @@ nullptr, idx, g_properties[idx].default_uint_value != 0); } -void ProcessInstanceInfo::Dump(Stream &s, Platform *platform) const { +void lldb_private::DumpProcessInstance(Stream &s, + const ProcessInstanceInfo &proc, + Platform *platform) { const char *cstr; - if (m_pid != LLDB_INVALID_PROCESS_ID) - s.Printf(" pid = %" PRIu64 "\n", m_pid); + if (proc.GetProcessID() != LLDB_INVALID_PROCESS_ID) + s.Printf(" pid = %" PRIu64 "\n", proc.GetProcessID()); - if (m_parent_pid != LLDB_INVALID_PROCESS_ID) - s.Printf(" parent = %" PRIu64 "\n", m_parent_pid); + if (proc.GetParentProcessID() != LLDB_INVALID_PROCESS_ID) + s.Printf(" parent = %" PRIu64 "\n", proc.GetParentProcessID()); - if (m_executable) { - s.Printf(" name = %s\n", m_executable.GetFilename().GetCString()); + if (proc.GetExecutableFile()) { + s.Printf(" name = %s\n", + proc.GetExecutableFile().GetFilename().GetCString()); s.PutCString(" file = "); - m_executable.Dump(&s); + proc.GetExecutableFile().Dump(&s); s.EOL(); } - const uint32_t argc = m_arguments.GetArgumentCount(); + const uint32_t argc = proc.GetArguments().GetArgumentCount(); if (argc > 0) { for (uint32_t i = 0; i < argc; i++) { - const char *arg = m_arguments.GetArgumentAtIndex(i); + const char *arg = proc.GetArguments().GetArgumentAtIndex(i); if (i < 10) s.Printf(" arg[%u] = %s\n", i, arg); else @@ -303,34 +307,37 @@ } } - s.Format("{0}", m_environment); + s.Format("{0}", proc.GetEnvironment()); - if (m_arch.IsValid()) { + if (proc.GetArchitecture().IsValid()) { s.Printf(" arch = "); - m_arch.DumpTriple(s); + proc.GetArchitecture().DumpTriple(s); s.EOL(); } - if (m_uid != UINT32_MAX) { - cstr = platform->GetUserName(m_uid); - s.Printf(" uid = %-5u (%s)\n", m_uid, cstr ? cstr : ""); + if (proc.GetUserID() != UINT32_MAX) { + cstr = platform->GetUserName(proc.GetUserID()); + s.Printf(" uid = %-5u (%s)\n", proc.GetUserID(), cstr ? cstr : ""); } - if (m_gid != UINT32_MAX) { - cstr = platform->GetGroupName(m_gid); - s.Printf(" gid = %-5u (%s)\n", m_gid, cstr ? cstr : ""); + if (proc.GetGroupID() != UINT32_MAX) { + cstr = platform->GetGroupName(proc.GetGroupID()); + s.Printf(" gid = %-5u (%s)\n", proc.GetGroupID(), cstr ? cstr : ""); } - if (m_euid != UINT32_MAX) { - cstr = platform->GetUserName(m_euid); - s.Printf(" euid = %-5u (%s)\n", m_euid, cstr ? cstr : ""); + if (proc.GetEffectiveUserID() != UINT32_MAX) { + cstr = platform->GetUserName(proc.GetEffectiveUserID()); + s.Printf(" euid = %-5u (%s)\n", proc.GetEffectiveUserID(), + cstr ? cstr : ""); } - if (m_egid != UINT32_MAX) { - cstr = platform->GetGroupName(m_egid); - s.Printf(" egid = %-5u (%s)\n", m_egid, cstr ? cstr : ""); + if (proc.GetEffectiveGroupID() != UINT32_MAX) { + cstr = platform->GetGroupName(proc.GetEffectiveGroupID()); + s.Printf(" egid = %-5u (%s)\n", proc.GetEffectiveGroupID(), + cstr ? cstr : ""); } } -void ProcessInstanceInfo::DumpTableHeader(Stream &s, Platform *platform, - bool show_args, bool verbose) { +void lldb_private::DumpProcessInstanceTableHeader(Stream &s, Platform *platform, + bool show_args, + bool verbose) { const char *label; if (show_args || verbose) label = "ARGUMENTS"; @@ -350,62 +357,64 @@ } } -void ProcessInstanceInfo::DumpAsTableRow(Stream &s, Platform *platform, - bool show_args, bool verbose) const { - if (m_pid != LLDB_INVALID_PROCESS_ID) { +void lldb_private::DumpProcessInstanceAsTableRow( + Stream &s, const ProcessInstanceInfo &proc, Platform *platform, + bool show_args, bool verbose) { + if (proc.GetProcessID() != LLDB_INVALID_PROCESS_ID) { const char *cstr; - s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", m_pid, m_parent_pid); + s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", proc.GetProcessID(), + proc.GetParentProcessID()); StreamString arch_strm; - if (m_arch.IsValid()) - m_arch.DumpTriple(arch_strm); + if (proc.GetArchitecture().IsValid()) + proc.GetArchitecture().DumpTriple(arch_strm); if (verbose) { - cstr = platform->GetUserName(m_uid); + cstr = platform->GetUserName(proc.GetUserID()); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf("%-10s ", cstr); else - s.Printf("%-10u ", m_uid); + s.Printf("%-10u ", proc.GetUserID()); - cstr = platform->GetGroupName(m_gid); + cstr = platform->GetGroupName(proc.GetGroupID()); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf("%-10s ", cstr); else - s.Printf("%-10u ", m_gid); + s.Printf("%-10u ", proc.GetGroupID()); - cstr = platform->GetUserName(m_euid); + cstr = platform->GetUserName(proc.GetEffectiveUserID()); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf("%-10s ", cstr); else - s.Printf("%-10u ", m_euid); + s.Printf("%-10u ", proc.GetEffectiveUserID()); - cstr = platform->GetGroupName(m_egid); + cstr = platform->GetGroupName(proc.GetEffectiveGroupID()); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf("%-10s ", cstr); else - s.Printf("%-10u ", m_egid); + s.Printf("%-10u ", proc.GetEffectiveGroupID()); s.Printf("%-24s ", arch_strm.GetData()); } else { - s.Printf("%-10s %-24s ", platform->GetUserName(m_euid), + s.Printf("%-10s %-24s ", platform->GetUserName(proc.GetEffectiveUserID()), arch_strm.GetData()); } if (verbose || show_args) { - const uint32_t argc = m_arguments.GetArgumentCount(); + const uint32_t argc = proc.GetArguments().GetArgumentCount(); if (argc > 0) { for (uint32_t i = 0; i < argc; i++) { if (i > 0) s.PutChar(' '); - s.PutCString(m_arguments.GetArgumentAtIndex(i)); + s.PutCString(proc.GetArguments().GetArgumentAtIndex(i)); } } } else { - s.PutCString(GetName()); + s.PutCString(proc.GetName()); } s.EOL(); @@ -581,89 +590,6 @@ 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, @@ -3045,11 +2971,11 @@ process_name, sizeof(process_name)); if (num_matches > 1) { StreamString s; - ProcessInstanceInfo::DumpTableHeader(s, platform_sp.get(), true, - false); + DumpProcessInstanceTableHeader(s, platform_sp.get(), true, false); for (size_t i = 0; i < num_matches; i++) { - process_infos.GetProcessInfoAtIndex(i).DumpAsTableRow( - s, platform_sp.get(), true, false); + DumpProcessInstanceAsTableRow( + s, process_infos.GetProcessInfoAtIndex(i), + platform_sp.get(), true, false); } error.SetErrorStringWithFormat( "more than one process named %s:\n%s", process_name, Index: lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp =================================================================== --- lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -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" Index: lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -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 //------------------------------------------------------------------ Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -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" Index: lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -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 //------------------------------------------------------------------ Index: lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -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 //------------------------------------------------------------------ Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -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> Index: lldb/source/Host/windows/Host.cpp =================================================================== --- lldb/source/Host/windows/Host.cpp +++ lldb/source/Host/windows/Host.cpp @@ -17,6 +17,7 @@ #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/StructuredData.h" Index: lldb/source/Host/openbsd/Host.cpp =================================================================== --- lldb/source/Host/openbsd/Host.cpp +++ lldb/source/Host/openbsd/Host.cpp @@ -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 @@ using namespace lldb; using namespace lldb_private; +namespace lldb_private { +class ProcessLaunchInfo; +} + Environment Host::GetEnvironment() { Environment env; char *v; Index: lldb/source/Host/netbsd/Host.cpp =================================================================== --- lldb/source/Host/netbsd/Host.cpp +++ lldb/source/Host/netbsd/Host.cpp @@ -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 @@ 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, Index: lldb/source/Host/linux/Host.cpp =================================================================== --- lldb/source/Host/linux/Host.cpp +++ lldb/source/Host/linux/Host.cpp @@ -44,6 +44,10 @@ }; } +namespace lldb_private { +class ProcessLaunchInfo; +} + static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo, ProcessState &State, ::pid_t &TracerPid) { auto BufferOrError = getProcFile(Pid, "status"); Index: lldb/source/Host/freebsd/Host.cpp =================================================================== --- lldb/source/Host/freebsd/Host.cpp +++ lldb/source/Host/freebsd/Host.cpp @@ -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 char **environ; } +namespace lldb_private { +class ProcessLaunchInfo; +} + using namespace lldb; using namespace lldb_private; Index: lldb/source/Host/CMakeLists.txt =================================================================== --- lldb/source/Host/CMakeLists.txt +++ lldb/source/Host/CMakeLists.txt @@ -37,7 +37,6 @@ common/NativeWatchpointList.cpp common/OptionParser.cpp common/PipeBase.cpp - common/ProcessInfo.cpp common/ProcessLaunchInfo.cpp common/ProcessRunLock.cpp common/PseudoTerminal.cpp Index: lldb/source/Commands/CommandObjectPlatform.cpp =================================================================== --- lldb/source/Commands/CommandObjectPlatform.cpp +++ lldb/source/Commands/CommandObjectPlatform.cpp @@ -1151,11 +1151,12 @@ if (pid != LLDB_INVALID_PROCESS_ID) { ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo(pid, proc_info)) { - ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(), - m_options.show_args, - m_options.verbose); - proc_info.DumpAsTableRow(ostrm, platform_sp.get(), - m_options.show_args, m_options.verbose); + DumpProcessInstanceTableHeader(ostrm, platform_sp.get(), + m_options.show_args, + m_options.verbose); + DumpProcessInstanceAsTableRow(ostrm, proc_info, platform_sp.get(), + m_options.show_args, + m_options.verbose); result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendErrorWithFormat( @@ -1212,13 +1213,13 @@ result.AppendMessageWithFormat(" whose name %s \"%s\"", match_desc, match_name); result.AppendMessageWithFormat("\n"); - ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(), - m_options.show_args, - m_options.verbose); + DumpProcessInstanceTableHeader(ostrm, platform_sp.get(), + m_options.show_args, + m_options.verbose); for (uint32_t i = 0; i < matches; ++i) { - proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow( - ostrm, platform_sp.get(), m_options.show_args, - m_options.verbose); + DumpProcessInstanceAsTableRow( + ostrm, proc_infos.GetProcessInfoAtIndex(i), + platform_sp.get(), m_options.show_args, m_options.verbose); } } } Index: lldb/source/API/SBTarget.cpp =================================================================== --- lldb/source/API/SBTarget.cpp +++ lldb/source/API/SBTarget.cpp @@ -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" Index: lldb/source/API/SBProcessInfo.cpp =================================================================== --- lldb/source/API/SBProcessInfo.cpp +++ lldb/source/API/SBProcessInfo.cpp @@ -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; Index: lldb/source/API/SBProcess.cpp =================================================================== --- lldb/source/API/SBProcess.cpp +++ lldb/source/API/SBProcess.cpp @@ -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" Index: lldb/include/lldb/module.modulemap =================================================================== --- lldb/include/lldb/module.modulemap +++ lldb/include/lldb/module.modulemap @@ -39,7 +39,6 @@ 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 * } Index: lldb/include/lldb/Utility/ProcessInfo.h =================================================================== --- /dev/null +++ lldb/include/lldb/Utility/ProcessInfo.h @@ -0,0 +1,241 @@ +//===-- 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 { +//---------------------------------------------------------------------- +// 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; + } + +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 Index: lldb/include/lldb/Target/Process.h =================================================================== --- lldb/include/lldb/Target/Process.h +++ lldb/include/lldb/Target/Process.h @@ -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" @@ -107,62 +107,16 @@ 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; } +void DumpProcessInstance(Stream &s, const ProcessInstanceInfo &process, + Platform *platform); - bool ParentProcessIDIsValid() const { - return m_parent_pid != LLDB_INVALID_PROCESS_ID; - } - - void Dump(Stream &s, Platform *platform) const; - - static void DumpTableHeader(Stream &s, Platform *platform, bool show_args, - bool verbose); - - void DumpAsTableRow(Stream &s, Platform *platform, bool show_args, - bool verbose) const; +void DumpProcessInstanceTableHeader(Stream &s, Platform *platform, + bool show_args, bool verbose); -protected: - uint32_t m_euid; - uint32_t m_egid; - lldb::pid_t m_parent_pid; -}; +void DumpProcessInstanceAsTableRow(Stream &s, + const ProcessInstanceInfo &process, + Platform *platform, bool show_args, + bool verbose); //---------------------------------------------------------------------- // ProcessAttachInfo @@ -298,94 +252,6 @@ 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.) Index: lldb/include/lldb/Target/Platform.h =================================================================== --- lldb/include/lldb/Target/Platform.h +++ lldb/include/lldb/Target/Platform.h @@ -29,6 +29,10 @@ namespace lldb_private { +class ProcessInstanceInfo; +class ProcessInstanceInfoList; +class ProcessInstanceInfoMatch; + class ModuleCache; enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 }; Index: lldb/include/lldb/Host/ProcessLaunchInfo.h =================================================================== --- lldb/include/lldb/Host/ProcessLaunchInfo.h +++ lldb/include/lldb/Host/ProcessLaunchInfo.h @@ -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 { Index: lldb/include/lldb/Host/ProcessInfo.h =================================================================== --- lldb/include/lldb/Host/ProcessInfo.h +++ /dev/null @@ -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_ Index: lldb/include/lldb/Host/Host.h =================================================================== --- lldb/include/lldb/Host/Host.h +++ lldb/include/lldb/Host/Host.h @@ -26,6 +26,9 @@ class FileAction; class ProcessLaunchInfo; +class ProcessInstanceInfo; +class ProcessInstanceInfoList; +class ProcessInstanceInfoMatch; //---------------------------------------------------------------------- // Exit Type for inferior processes
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits