1 //===-- SBProcessInfo.cpp -------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBProcessInfo.h"
11 #include "lldb/API/SBFileSpec.h"
12 #include "lldb/Utility/Instrumentation.h"
13 #include "lldb/Utility/ProcessInfo.h"
16 using namespace lldb_private
;
18 SBProcessInfo::SBProcessInfo() { LLDB_INSTRUMENT_VA(this); }
20 SBProcessInfo::SBProcessInfo(const SBProcessInfo
&rhs
) {
21 LLDB_INSTRUMENT_VA(this, rhs
);
23 m_opaque_up
= clone(rhs
.m_opaque_up
);
26 SBProcessInfo::~SBProcessInfo() = default;
28 SBProcessInfo
&SBProcessInfo::operator=(const SBProcessInfo
&rhs
) {
29 LLDB_INSTRUMENT_VA(this, rhs
);
32 m_opaque_up
= clone(rhs
.m_opaque_up
);
36 ProcessInstanceInfo
&SBProcessInfo::ref() {
37 if (m_opaque_up
== nullptr) {
38 m_opaque_up
= std::make_unique
<ProcessInstanceInfo
>();
43 void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo
&proc_info_ref
) {
44 ref() = proc_info_ref
;
47 bool SBProcessInfo::IsValid() const {
48 LLDB_INSTRUMENT_VA(this);
49 return this->operator bool();
51 SBProcessInfo::operator bool() const {
52 LLDB_INSTRUMENT_VA(this);
54 return m_opaque_up
!= nullptr;
57 const char *SBProcessInfo::GetName() {
58 LLDB_INSTRUMENT_VA(this);
63 return ConstString(m_opaque_up
->GetName()).GetCString();
66 SBFileSpec
SBProcessInfo::GetExecutableFile() {
67 LLDB_INSTRUMENT_VA(this);
71 file_spec
.SetFileSpec(m_opaque_up
->GetExecutableFile());
76 lldb::pid_t
SBProcessInfo::GetProcessID() {
77 LLDB_INSTRUMENT_VA(this);
79 lldb::pid_t proc_id
= LLDB_INVALID_PROCESS_ID
;
81 proc_id
= m_opaque_up
->GetProcessID();
86 uint32_t SBProcessInfo::GetUserID() {
87 LLDB_INSTRUMENT_VA(this);
89 uint32_t user_id
= UINT32_MAX
;
91 user_id
= m_opaque_up
->GetUserID();
96 uint32_t SBProcessInfo::GetGroupID() {
97 LLDB_INSTRUMENT_VA(this);
99 uint32_t group_id
= UINT32_MAX
;
101 group_id
= m_opaque_up
->GetGroupID();
106 bool SBProcessInfo::UserIDIsValid() {
107 LLDB_INSTRUMENT_VA(this);
109 bool is_valid
= false;
111 is_valid
= m_opaque_up
->UserIDIsValid();
116 bool SBProcessInfo::GroupIDIsValid() {
117 LLDB_INSTRUMENT_VA(this);
119 bool is_valid
= false;
121 is_valid
= m_opaque_up
->GroupIDIsValid();
126 uint32_t SBProcessInfo::GetEffectiveUserID() {
127 LLDB_INSTRUMENT_VA(this);
129 uint32_t user_id
= UINT32_MAX
;
131 user_id
= m_opaque_up
->GetEffectiveUserID();
136 uint32_t SBProcessInfo::GetEffectiveGroupID() {
137 LLDB_INSTRUMENT_VA(this);
139 uint32_t group_id
= UINT32_MAX
;
141 group_id
= m_opaque_up
->GetEffectiveGroupID();
146 bool SBProcessInfo::EffectiveUserIDIsValid() {
147 LLDB_INSTRUMENT_VA(this);
149 bool is_valid
= false;
151 is_valid
= m_opaque_up
->EffectiveUserIDIsValid();
156 bool SBProcessInfo::EffectiveGroupIDIsValid() {
157 LLDB_INSTRUMENT_VA(this);
159 bool is_valid
= false;
161 is_valid
= m_opaque_up
->EffectiveGroupIDIsValid();
166 lldb::pid_t
SBProcessInfo::GetParentProcessID() {
167 LLDB_INSTRUMENT_VA(this);
169 lldb::pid_t proc_id
= LLDB_INVALID_PROCESS_ID
;
171 proc_id
= m_opaque_up
->GetParentProcessID();
176 const char *SBProcessInfo::GetTriple() {
177 LLDB_INSTRUMENT_VA(this);
182 const auto &arch
= m_opaque_up
->GetArchitecture();
186 return ConstString(arch
.GetTriple().getTriple().c_str()).GetCString();