summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp203
1 files changed, 2 insertions, 201 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2723b698517..d74aaf1e4e7 100644
--- a/lldb/source/Target/Process.cpp
+++ b/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,123 +279,6 @@ bool ProcessProperties::GetStopOnExec() const {
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> ProcessLaunchCommandOptions::GetDefinitions() {
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::DoOnRemoval(Event *event_ptr) {
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());
OpenPOWER on IntegriCloud