1 //===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "lldb/API/SBProcessInfo.h" 10 #include "Utils.h" 11 #include "lldb/API/SBFileSpec.h" 12 #include "lldb/Utility/ProcessInfo.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 SBProcessInfo::SBProcessInfo() : m_opaque_up() {} 18 19 SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() { 20 m_opaque_up = clone(rhs.m_opaque_up); 21 } 22 23 SBProcessInfo::~SBProcessInfo() {} 24 25 SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { 26 if (this != &rhs) 27 m_opaque_up = clone(rhs.m_opaque_up); 28 return *this; 29 } 30 31 ProcessInstanceInfo &SBProcessInfo::ref() { 32 if (m_opaque_up == nullptr) { 33 m_opaque_up.reset(new ProcessInstanceInfo()); 34 } 35 return *m_opaque_up; 36 } 37 38 void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) { 39 ref() = proc_info_ref; 40 } 41 42 bool SBProcessInfo::IsValid() const { return m_opaque_up != nullptr; } 43 44 const char *SBProcessInfo::GetName() { 45 const char *name = nullptr; 46 if (m_opaque_up) { 47 name = m_opaque_up->GetName(); 48 } 49 return name; 50 } 51 52 SBFileSpec SBProcessInfo::GetExecutableFile() { 53 SBFileSpec file_spec; 54 if (m_opaque_up) { 55 file_spec.SetFileSpec(m_opaque_up->GetExecutableFile()); 56 } 57 return file_spec; 58 } 59 60 lldb::pid_t SBProcessInfo::GetProcessID() { 61 lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID; 62 if (m_opaque_up) { 63 proc_id = m_opaque_up->GetProcessID(); 64 } 65 return proc_id; 66 } 67 68 uint32_t SBProcessInfo::GetUserID() { 69 uint32_t user_id = UINT32_MAX; 70 if (m_opaque_up) { 71 user_id = m_opaque_up->GetUserID(); 72 } 73 return user_id; 74 } 75 76 uint32_t SBProcessInfo::GetGroupID() { 77 uint32_t group_id = UINT32_MAX; 78 if (m_opaque_up) { 79 group_id = m_opaque_up->GetGroupID(); 80 } 81 return group_id; 82 } 83 84 bool SBProcessInfo::UserIDIsValid() { 85 bool is_valid = false; 86 if (m_opaque_up) { 87 is_valid = m_opaque_up->UserIDIsValid(); 88 } 89 return is_valid; 90 } 91 92 bool SBProcessInfo::GroupIDIsValid() { 93 bool is_valid = false; 94 if (m_opaque_up) { 95 is_valid = m_opaque_up->GroupIDIsValid(); 96 } 97 return is_valid; 98 } 99 100 uint32_t SBProcessInfo::GetEffectiveUserID() { 101 uint32_t user_id = UINT32_MAX; 102 if (m_opaque_up) { 103 user_id = m_opaque_up->GetEffectiveUserID(); 104 } 105 return user_id; 106 } 107 108 uint32_t SBProcessInfo::GetEffectiveGroupID() { 109 uint32_t group_id = UINT32_MAX; 110 if (m_opaque_up) { 111 group_id = m_opaque_up->GetEffectiveGroupID(); 112 } 113 return group_id; 114 } 115 116 bool SBProcessInfo::EffectiveUserIDIsValid() { 117 bool is_valid = false; 118 if (m_opaque_up) { 119 is_valid = m_opaque_up->EffectiveUserIDIsValid(); 120 } 121 return is_valid; 122 } 123 124 bool SBProcessInfo::EffectiveGroupIDIsValid() { 125 bool is_valid = false; 126 if (m_opaque_up) { 127 is_valid = m_opaque_up->EffectiveGroupIDIsValid(); 128 } 129 return is_valid; 130 } 131 132 lldb::pid_t SBProcessInfo::GetParentProcessID() { 133 lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID; 134 if (m_opaque_up) { 135 proc_id = m_opaque_up->GetParentProcessID(); 136 } 137 return proc_id; 138 } 139