[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBProcessInfo.cpp
blobbe242ec5872d95d7137aa5bbceb0e716d8ca5880
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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBProcessInfo.h"
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/Utility/ProcessInfo.h"
15 using namespace lldb;
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 &),
33 rhs);
35 if (this != &rhs)
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());
44 return *m_opaque_up;
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;
65 if (m_opaque_up) {
66 name = m_opaque_up->GetName();
68 return name;
71 SBFileSpec SBProcessInfo::GetExecutableFile() {
72 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBProcessInfo,
73 GetExecutableFile);
75 SBFileSpec file_spec;
76 if (m_opaque_up) {
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;
86 if (m_opaque_up) {
87 proc_id = m_opaque_up->GetProcessID();
89 return proc_id;
92 uint32_t SBProcessInfo::GetUserID() {
93 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetUserID);
95 uint32_t user_id = UINT32_MAX;
96 if (m_opaque_up) {
97 user_id = m_opaque_up->GetUserID();
99 return user_id;
102 uint32_t SBProcessInfo::GetGroupID() {
103 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetGroupID);
105 uint32_t group_id = UINT32_MAX;
106 if (m_opaque_up) {
107 group_id = m_opaque_up->GetGroupID();
109 return group_id;
112 bool SBProcessInfo::UserIDIsValid() {
113 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, UserIDIsValid);
115 bool is_valid = false;
116 if (m_opaque_up) {
117 is_valid = m_opaque_up->UserIDIsValid();
119 return is_valid;
122 bool SBProcessInfo::GroupIDIsValid() {
123 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, GroupIDIsValid);
125 bool is_valid = false;
126 if (m_opaque_up) {
127 is_valid = m_opaque_up->GroupIDIsValid();
129 return is_valid;
132 uint32_t SBProcessInfo::GetEffectiveUserID() {
133 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveUserID);
135 uint32_t user_id = UINT32_MAX;
136 if (m_opaque_up) {
137 user_id = m_opaque_up->GetEffectiveUserID();
139 return user_id;
142 uint32_t SBProcessInfo::GetEffectiveGroupID() {
143 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveGroupID);
145 uint32_t group_id = UINT32_MAX;
146 if (m_opaque_up) {
147 group_id = m_opaque_up->GetEffectiveGroupID();
149 return group_id;
152 bool SBProcessInfo::EffectiveUserIDIsValid() {
153 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveUserIDIsValid);
155 bool is_valid = false;
156 if (m_opaque_up) {
157 is_valid = m_opaque_up->EffectiveUserIDIsValid();
159 return is_valid;
162 bool SBProcessInfo::EffectiveGroupIDIsValid() {
163 LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveGroupIDIsValid);
165 bool is_valid = false;
166 if (m_opaque_up) {
167 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
169 return is_valid;
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;
176 if (m_opaque_up) {
177 proc_id = m_opaque_up->GetParentProcessID();
179 return proc_id;
182 namespace lldb_private {
183 namespace repro {
185 template <>
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,
196 ());
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, ());