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
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
79 if (!m_opaque_up)
80 return nullptr;
81
82 return ConstString(m_opaque_up->GetArg0()).GetCString();
83}
84
87
89 if (m_opaque_up) {
90 proc_id = m_opaque_up->GetProcessID();
91 }
92 return proc_id;
93}
94
97
98 uint32_t user_id = UINT32_MAX;
99 if (m_opaque_up) {
100 user_id = m_opaque_up->GetUserID();
101 }
102 return user_id;
103}
104
106 LLDB_INSTRUMENT_VA(this);
107
108 uint32_t group_id = UINT32_MAX;
109 if (m_opaque_up) {
110 group_id = m_opaque_up->GetGroupID();
111 }
112 return group_id;
113}
114
116 LLDB_INSTRUMENT_VA(this);
117
118 bool is_valid = false;
119 if (m_opaque_up) {
120 is_valid = m_opaque_up->UserIDIsValid();
121 }
122 return is_valid;
123}
124
126 LLDB_INSTRUMENT_VA(this);
127
128 bool is_valid = false;
129 if (m_opaque_up) {
130 is_valid = m_opaque_up->GroupIDIsValid();
131 }
132 return is_valid;
133}
134
136 LLDB_INSTRUMENT_VA(this);
137
138 uint32_t user_id = UINT32_MAX;
139 if (m_opaque_up) {
140 user_id = m_opaque_up->GetEffectiveUserID();
141 }
142 return user_id;
143}
144
146 LLDB_INSTRUMENT_VA(this);
147
148 uint32_t group_id = UINT32_MAX;
149 if (m_opaque_up) {
150 group_id = m_opaque_up->GetEffectiveGroupID();
151 }
152 return group_id;
153}
154
156 LLDB_INSTRUMENT_VA(this);
157
158 bool is_valid = false;
159 if (m_opaque_up) {
160 is_valid = m_opaque_up->EffectiveUserIDIsValid();
161 }
162 return is_valid;
163}
164
166 LLDB_INSTRUMENT_VA(this);
167
168 bool is_valid = false;
169 if (m_opaque_up) {
170 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
171 }
172 return is_valid;
173}
174
176 LLDB_INSTRUMENT_VA(this);
177
179 if (m_opaque_up) {
180 proc_id = m_opaque_up->GetParentProcessID();
181 }
182 return proc_id;
183}
184
186 LLDB_INSTRUMENT_VA(this);
187
188 if (!m_opaque_up)
189 return nullptr;
190
191 const auto &arch = m_opaque_up->GetArchitecture();
192 if (!arch.IsValid())
193 return nullptr;
194
195 return ConstString(arch.GetTriple().getTriple()).GetCString();
196}
197
199 LLDB_INSTRUMENT_VA(this);
200
201 if (!m_opaque_up)
202 return 0;
203
204 const Args &args = m_opaque_up->GetArguments();
205 return args.GetArgumentCount();
206}
207
208const char *SBProcessInfo::GetArgumentAtIndex(uint32_t idx) const {
209 LLDB_INSTRUMENT_VA(this, idx);
210
211 if (!m_opaque_up)
212 return nullptr;
213
214 const Args &args = m_opaque_up->GetArguments();
215 return ConstString(args.GetArgumentAtIndex(idx)).GetCString();
216}
#define LLDB_INSTRUMENT_VA(...)
void SetFileSpec(const lldb_private::FileSpec &fspec)
uint32_t GetNumArguments() const
Returns the number of command line arguments for the described process.
uint32_t GetEffectiveGroupID()
const char * GetArgumentAtIndex(uint32_t idx) const
Returns the command line argument at the given index, or nullptr if the index is out of range or if t...
lldb::pid_t GetParentProcessID()
uint32_t GetEffectiveUserID()
SBProcessInfo & operator=(const SBProcessInfo &rhs)
std::unique_ptr< lldb_private::ProcessInstanceInfo > m_opaque_up
lldb_private::ProcessInstanceInfo & ref()
void SetProcessInfo(const lldb_private::ProcessInstanceInfo &proc_info_ref)
const char * GetName()
lldb::pid_t GetProcessID()
const char * GetTriple()
Return the target triple (arch-vendor-os) for the described process.
SBFileSpec GetExecutableFile()
const char * GetArg0()
If the process was laumched with a first argument that doesn't match the executable file or name,...
A command line argument class.
Definition Args.h:33
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition Args.h:120
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition Args.cpp:273
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
#define UINT32_MAX
#define LLDB_INVALID_PROCESS_ID
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
uint64_t pid_t
Definition lldb-types.h:83