LLDB mainline
SBProcessInfo.cpp
Go to the documentation of this file.
1//===-- SBProcessInfo.cpp -------------------------------------------------===//
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
10#include "Utils.h"
11#include "lldb/API/SBFileSpec.h"
14
15using namespace lldb;
16using namespace lldb_private;
17
19
21 LLDB_INSTRUMENT_VA(this, rhs);
22
24}
25
27
29 LLDB_INSTRUMENT_VA(this, rhs);
30
31 if (this != &rhs)
33 return *this;
34}
35
37 if (m_opaque_up == nullptr) {
38 m_opaque_up = std::make_unique<ProcessInstanceInfo>();
39 }
40 return *m_opaque_up;
41}
42
44 ref() = proc_info_ref;
45}
46
49 return this->operator bool();
50}
51SBProcessInfo::operator bool() const {
53
54 return m_opaque_up != nullptr;
55}
56
59
60 if (!m_opaque_up)
61 return nullptr;
62
63 return ConstString(m_opaque_up->GetName()).GetCString();
64}
65
68
69 SBFileSpec file_spec;
70 if (m_opaque_up) {
71 file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
72 }
73 return file_spec;
74}
75
78
80 if (m_opaque_up) {
81 proc_id = m_opaque_up->GetProcessID();
82 }
83 return proc_id;
84}
85
88
89 uint32_t user_id = UINT32_MAX;
90 if (m_opaque_up) {
91 user_id = m_opaque_up->GetUserID();
92 }
93 return user_id;
94}
95
98
99 uint32_t group_id = UINT32_MAX;
100 if (m_opaque_up) {
101 group_id = m_opaque_up->GetGroupID();
102 }
103 return group_id;
104}
105
107 LLDB_INSTRUMENT_VA(this);
108
109 bool is_valid = false;
110 if (m_opaque_up) {
111 is_valid = m_opaque_up->UserIDIsValid();
112 }
113 return is_valid;
114}
115
117 LLDB_INSTRUMENT_VA(this);
118
119 bool is_valid = false;
120 if (m_opaque_up) {
121 is_valid = m_opaque_up->GroupIDIsValid();
122 }
123 return is_valid;
124}
125
127 LLDB_INSTRUMENT_VA(this);
128
129 uint32_t user_id = UINT32_MAX;
130 if (m_opaque_up) {
131 user_id = m_opaque_up->GetEffectiveUserID();
132 }
133 return user_id;
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
139 uint32_t group_id = UINT32_MAX;
140 if (m_opaque_up) {
141 group_id = m_opaque_up->GetEffectiveGroupID();
142 }
143 return group_id;
144}
145
147 LLDB_INSTRUMENT_VA(this);
148
149 bool is_valid = false;
150 if (m_opaque_up) {
151 is_valid = m_opaque_up->EffectiveUserIDIsValid();
152 }
153 return is_valid;
154}
155
157 LLDB_INSTRUMENT_VA(this);
158
159 bool is_valid = false;
160 if (m_opaque_up) {
161 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
162 }
163 return is_valid;
164}
165
167 LLDB_INSTRUMENT_VA(this);
168
170 if (m_opaque_up) {
171 proc_id = m_opaque_up->GetParentProcessID();
172 }
173 return proc_id;
174}
175
177 LLDB_INSTRUMENT_VA(this);
178
179 if (!m_opaque_up)
180 return nullptr;
181
182 const auto &arch = m_opaque_up->GetArchitecture();
183 if (!arch.IsValid())
184 return nullptr;
185
186 return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
187}
#define LLDB_INSTRUMENT_VA(...)
void SetFileSpec(const lldb_private::FileSpec &fspec)
Definition: SBFileSpec.cpp:164
uint32_t GetEffectiveGroupID()
lldb::pid_t GetParentProcessID()
uint32_t GetEffectiveUserID()
SBProcessInfo & operator=(const SBProcessInfo &rhs)
std::unique_ptr< lldb_private::ProcessInstanceInfo > m_opaque_up
Definition: SBProcessInfo.h:64
lldb_private::ProcessInstanceInfo & ref()
void SetProcessInfo(const lldb_private::ProcessInstanceInfo &proc_info_ref)
const char * GetName()
lldb::pid_t GetProcessID()
bool IsValid() const
const char * GetTriple()
Return the target triple (arch-vendor-os) for the described process.
SBFileSpec GetExecutableFile()
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
#define UINT32_MAX
Definition: lldb-defines.h:19
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:89
A class that represents a running process on the host machine.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Definition: SBAddress.h:15
uint64_t pid_t
Definition: lldb-types.h:83