[Go to site: main page, start]

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"
15
16using namespace lldb;
17using namespace lldb_private;
18
20
26
28
30 LLDB_INSTRUMENT_VA(this, rhs);
31
32 if (this != &rhs)
34 return *this;
35}
36
38 if (m_opaque_up == nullptr) {
39 m_opaque_up = std::make_unique<ProcessInstanceInfo>();
40 }
41 return *m_opaque_up;
42}
43
45 ref() = proc_info_ref;
46}
47
50 return this->operator bool();
51}
52SBProcessInfo::operator bool() const {
54
55 return m_opaque_up != nullptr;
56}
57
60
61 if (!m_opaque_up)
62 return nullptr;
63
64 return ConstString(m_opaque_up->GetName()).GetCString();
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
80 if (!m_opaque_up)
81 return nullptr;
82
83 return ConstString(m_opaque_up->GetArg0()).GetCString();
84}
85
88
90 if (m_opaque_up) {
91 proc_id = m_opaque_up->GetProcessID();
92 }
93 return proc_id;
94}
95
98
99 uint32_t user_id = UINT32_MAX;
100 if (m_opaque_up) {
101 user_id = m_opaque_up->GetUserID();
102 }
103 return user_id;
104}
105
107 LLDB_INSTRUMENT_VA(this);
108
109 uint32_t group_id = UINT32_MAX;
110 if (m_opaque_up) {
111 group_id = m_opaque_up->GetGroupID();
112 }
113 return group_id;
114}
115
117 LLDB_INSTRUMENT_VA(this);
118
119 bool is_valid = false;
120 if (m_opaque_up) {
121 is_valid = m_opaque_up->UserIDIsValid();
122 }
123 return is_valid;
124}
125
127 LLDB_INSTRUMENT_VA(this);
128
129 bool is_valid = false;
130 if (m_opaque_up) {
131 is_valid = m_opaque_up->GroupIDIsValid();
132 }
133 return is_valid;
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
139 uint32_t user_id = UINT32_MAX;
140 if (m_opaque_up) {
141 user_id = m_opaque_up->GetEffectiveUserID();
142 }
143 return user_id;
144}
145
147 LLDB_INSTRUMENT_VA(this);
148
149 uint32_t group_id = UINT32_MAX;
150 if (m_opaque_up) {
151 group_id = m_opaque_up->GetEffectiveGroupID();
152 }
153 return group_id;
154}
155
157 LLDB_INSTRUMENT_VA(this);
158
159 bool is_valid = false;
160 if (m_opaque_up) {
161 is_valid = m_opaque_up->EffectiveUserIDIsValid();
162 }
163 return is_valid;
164}
165
167 LLDB_INSTRUMENT_VA(this);
168
169 bool is_valid = false;
170 if (m_opaque_up) {
171 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
172 }
173 return is_valid;
174}
175
177 LLDB_INSTRUMENT_VA(this);
178
180 if (m_opaque_up) {
181 proc_id = m_opaque_up->GetParentProcessID();
182 }
183 return proc_id;
184}
185
187 LLDB_INSTRUMENT_VA(this);
188
189 if (!m_opaque_up)
190 return nullptr;
191
192 const auto &arch = m_opaque_up->GetArchitecture();
193 if (!arch.IsValid())
194 return nullptr;
195
196 return ConstString(arch.GetTriple().getTriple()).GetCString();
197}
198
200 LLDB_INSTRUMENT_VA(this);
201
202 if (!m_opaque_up)
203 return 0;
204
205 const Args &args = m_opaque_up->GetArguments();
206 return args.GetArgumentCount();
207}
208
209const char *SBProcessInfo::GetArgumentAtIndex(uint32_t idx) const {
210 LLDB_INSTRUMENT_VA(this, idx);
211
212 if (!m_opaque_up)
213 return nullptr;
214
215 const Args &args = m_opaque_up->GetArguments();
216 return ConstString(args.GetArgumentAtIndex(idx)).GetCString();
217}
#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:84