1 //===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===//
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"
10 #include "SBReproducerPrivate.h"
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/Utility/ProcessInfo.h"
16 using namespace lldb_private
;
18 SBProcessInfo::SBProcessInfo() : m_opaque_up() {
19 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcessInfo
);
22 SBProcessInfo::SBProcessInfo(const SBProcessInfo
&rhs
) : m_opaque_up() {
23 LLDB_RECORD_CONSTRUCTOR(SBProcessInfo
, (const lldb::SBProcessInfo
&), rhs
);
25 m_opaque_up
= clone(rhs
.m_opaque_up
);
28 SBProcessInfo::~SBProcessInfo() {}
30 SBProcessInfo
&SBProcessInfo::operator=(const SBProcessInfo
&rhs
) {
31 LLDB_RECORD_METHOD(lldb::SBProcessInfo
&,
32 SBProcessInfo
, operator=,(const lldb::SBProcessInfo
&),
36 m_opaque_up
= clone(rhs
.m_opaque_up
);
37 return LLDB_RECORD_RESULT(*this);
40 ProcessInstanceInfo
&SBProcessInfo::ref() {
41 if (m_opaque_up
== nullptr) {
42 m_opaque_up
.reset(new ProcessInstanceInfo());
47 void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo
&proc_info_ref
) {
48 ref() = proc_info_ref
;
51 bool SBProcessInfo::IsValid() const {
52 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo
, IsValid
);
53 return this->operator bool();
55 SBProcessInfo::operator bool() const {
56 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo
, operator bool);
58 return m_opaque_up
!= nullptr;
61 const char *SBProcessInfo::GetName() {
62 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo
, GetName
);
64 const char *name
= nullptr;
66 name
= m_opaque_up
->GetName();
71 SBFileSpec
SBProcessInfo::GetExecutableFile() {
72 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec
, SBProcessInfo
,
77 file_spec
.SetFileSpec(m_opaque_up
->GetExecutableFile());
79 return LLDB_RECORD_RESULT(file_spec
);
82 lldb::pid_t
SBProcessInfo::GetProcessID() {
83 LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t
, SBProcessInfo
, GetProcessID
);
85 lldb::pid_t proc_id
= LLDB_INVALID_PROCESS_ID
;
87 proc_id
= m_opaque_up
->GetProcessID();
92 uint32_t SBProcessInfo::GetUserID() {
93 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo
, GetUserID
);
95 uint32_t user_id
= UINT32_MAX
;
97 user_id
= m_opaque_up
->GetUserID();
102 uint32_t SBProcessInfo::GetGroupID() {
103 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo
, GetGroupID
);
105 uint32_t group_id
= UINT32_MAX
;
107 group_id
= m_opaque_up
->GetGroupID();
112 bool SBProcessInfo::UserIDIsValid() {
113 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo
, UserIDIsValid
);
115 bool is_valid
= false;
117 is_valid
= m_opaque_up
->UserIDIsValid();
122 bool SBProcessInfo::GroupIDIsValid() {
123 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo
, GroupIDIsValid
);
125 bool is_valid
= false;
127 is_valid
= m_opaque_up
->GroupIDIsValid();
132 uint32_t SBProcessInfo::GetEffectiveUserID() {
133 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo
, GetEffectiveUserID
);
135 uint32_t user_id
= UINT32_MAX
;
137 user_id
= m_opaque_up
->GetEffectiveUserID();
142 uint32_t SBProcessInfo::GetEffectiveGroupID() {
143 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo
, GetEffectiveGroupID
);
145 uint32_t group_id
= UINT32_MAX
;
147 group_id
= m_opaque_up
->GetEffectiveGroupID();
152 bool SBProcessInfo::EffectiveUserIDIsValid() {
153 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo
, EffectiveUserIDIsValid
);
155 bool is_valid
= false;
157 is_valid
= m_opaque_up
->EffectiveUserIDIsValid();
162 bool SBProcessInfo::EffectiveGroupIDIsValid() {
163 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo
, EffectiveGroupIDIsValid
);
165 bool is_valid
= false;
167 is_valid
= m_opaque_up
->EffectiveGroupIDIsValid();
172 lldb::pid_t
SBProcessInfo::GetParentProcessID() {
173 LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t
, SBProcessInfo
, GetParentProcessID
);
175 lldb::pid_t proc_id
= LLDB_INVALID_PROCESS_ID
;
177 proc_id
= m_opaque_up
->GetParentProcessID();
182 namespace lldb_private
{
186 void RegisterMethods
<SBProcessInfo
>(Registry
&R
) {
187 LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo
, ());
188 LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo
, (const lldb::SBProcessInfo
&));
189 LLDB_REGISTER_METHOD(
190 lldb::SBProcessInfo
&,
191 SBProcessInfo
, operator=,(const lldb::SBProcessInfo
&));
192 LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo
, IsValid
, ());
193 LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo
, operator bool, ());
194 LLDB_REGISTER_METHOD(const char *, SBProcessInfo
, GetName
, ());
195 LLDB_REGISTER_METHOD(lldb::SBFileSpec
, SBProcessInfo
, GetExecutableFile
,
197 LLDB_REGISTER_METHOD(lldb::pid_t
, SBProcessInfo
, GetProcessID
, ());
198 LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo
, GetUserID
, ());
199 LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo
, GetGroupID
, ());
200 LLDB_REGISTER_METHOD(bool, SBProcessInfo
, UserIDIsValid
, ());
201 LLDB_REGISTER_METHOD(bool, SBProcessInfo
, GroupIDIsValid
, ());
202 LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo
, GetEffectiveUserID
, ());
203 LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo
, GetEffectiveGroupID
, ());
204 LLDB_REGISTER_METHOD(bool, SBProcessInfo
, EffectiveUserIDIsValid
, ());
205 LLDB_REGISTER_METHOD(bool, SBProcessInfo
, EffectiveGroupIDIsValid
, ());
206 LLDB_REGISTER_METHOD(lldb::pid_t
, SBProcessInfo
, GetParentProcessID
, ());