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 const char *name = nullptr;
61 if (m_opaque_up) {
62 name = m_opaque_up->GetName();
63 }
64 return name;
65}
66
69
70 SBFileSpec file_spec;
71 if (m_opaque_up) {
72 file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
73 }
74 return file_spec;
75}
76
79
81 if (m_opaque_up) {
82 proc_id = m_opaque_up->GetProcessID();
83 }
84 return proc_id;
85}
86
89
90 uint32_t user_id = UINT32_MAX;
91 if (m_opaque_up) {
92 user_id = m_opaque_up->GetUserID();
93 }
94 return user_id;
95}
96
99
100 uint32_t group_id = UINT32_MAX;
101 if (m_opaque_up) {
102 group_id = m_opaque_up->GetGroupID();
103 }
104 return group_id;
105}
106
108 LLDB_INSTRUMENT_VA(this);
109
110 bool is_valid = false;
111 if (m_opaque_up) {
112 is_valid = m_opaque_up->UserIDIsValid();
113 }
114 return is_valid;
115}
116
118 LLDB_INSTRUMENT_VA(this);
119
120 bool is_valid = false;
121 if (m_opaque_up) {
122 is_valid = m_opaque_up->GroupIDIsValid();
123 }
124 return is_valid;
125}
126
128 LLDB_INSTRUMENT_VA(this);
129
130 uint32_t user_id = UINT32_MAX;
131 if (m_opaque_up) {
132 user_id = m_opaque_up->GetEffectiveUserID();
133 }
134 return user_id;
135}
136
138 LLDB_INSTRUMENT_VA(this);
139
140 uint32_t group_id = UINT32_MAX;
141 if (m_opaque_up) {
142 group_id = m_opaque_up->GetEffectiveGroupID();
143 }
144 return group_id;
145}
146
148 LLDB_INSTRUMENT_VA(this);
149
150 bool is_valid = false;
151 if (m_opaque_up) {
152 is_valid = m_opaque_up->EffectiveUserIDIsValid();
153 }
154 return is_valid;
155}
156
158 LLDB_INSTRUMENT_VA(this);
159
160 bool is_valid = false;
161 if (m_opaque_up) {
162 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
163 }
164 return is_valid;
165}
166
168 LLDB_INSTRUMENT_VA(this);
169
171 if (m_opaque_up) {
172 proc_id = m_opaque_up->GetParentProcessID();
173 }
174 return proc_id;
175}
176
178 LLDB_INSTRUMENT_VA(this);
179
180 const char *triple = nullptr;
181 if (m_opaque_up) {
182 const auto &arch = m_opaque_up->GetArchitecture();
183 if (arch.IsValid()) {
184 // Const-ify the string so we don't need to worry about the lifetime of
185 // the string
186 triple = ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
187 }
188 }
189 return triple;
190}
#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:63
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:39
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
#define UINT32_MAX
Definition: lldb-defines.h:19
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:81
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
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:81