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"
16
17using namespace lldb;
18using namespace lldb_private;
19
21
27
29
31 LLDB_INSTRUMENT_VA(this, rhs);
32
33 if (this != &rhs)
35 return *this;
36}
37
39 if (m_opaque_up == nullptr) {
40 m_opaque_up = std::make_unique<ProcessInstanceInfo>();
41 }
42 return *m_opaque_up;
43}
44
46 ref() = proc_info_ref;
47}
48
51 return this->operator bool();
52}
53SBProcessInfo::operator bool() const {
55
56 return m_opaque_up != nullptr;
57}
58
61
62 if (!m_opaque_up)
63 return nullptr;
64
65 return StringPool::GetSystemPool().Intern(m_opaque_up->GetName());
66}
67
70
71 SBFileSpec file_spec;
72 if (m_opaque_up) {
73 file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
74 }
75 return file_spec;
76}
77
80
81 if (!m_opaque_up)
82 return nullptr;
83
84 return StringPool::GetSystemPool().Intern(m_opaque_up->GetArg0());
85}
86
89
91 if (m_opaque_up) {
92 proc_id = m_opaque_up->GetProcessID();
93 }
94 return proc_id;
95}
96
99
100 uint32_t user_id = UINT32_MAX;
101 if (m_opaque_up) {
102 user_id = m_opaque_up->GetUserID();
103 }
104 return user_id;
105}
106
108 LLDB_INSTRUMENT_VA(this);
109
110 uint32_t group_id = UINT32_MAX;
111 if (m_opaque_up) {
112 group_id = m_opaque_up->GetGroupID();
113 }
114 return group_id;
115}
116
118 LLDB_INSTRUMENT_VA(this);
119
120 bool is_valid = false;
121 if (m_opaque_up) {
122 is_valid = m_opaque_up->UserIDIsValid();
123 }
124 return is_valid;
125}
126
128 LLDB_INSTRUMENT_VA(this);
129
130 bool is_valid = false;
131 if (m_opaque_up) {
132 is_valid = m_opaque_up->GroupIDIsValid();
133 }
134 return is_valid;
135}
136
138 LLDB_INSTRUMENT_VA(this);
139
140 uint32_t user_id = UINT32_MAX;
141 if (m_opaque_up) {
142 user_id = m_opaque_up->GetEffectiveUserID();
143 }
144 return user_id;
145}
146
148 LLDB_INSTRUMENT_VA(this);
149
150 uint32_t group_id = UINT32_MAX;
151 if (m_opaque_up) {
152 group_id = m_opaque_up->GetEffectiveGroupID();
153 }
154 return group_id;
155}
156
158 LLDB_INSTRUMENT_VA(this);
159
160 bool is_valid = false;
161 if (m_opaque_up) {
162 is_valid = m_opaque_up->EffectiveUserIDIsValid();
163 }
164 return is_valid;
165}
166
168 LLDB_INSTRUMENT_VA(this);
169
170 bool is_valid = false;
171 if (m_opaque_up) {
172 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
173 }
174 return is_valid;
175}
176
178 LLDB_INSTRUMENT_VA(this);
179
181 if (m_opaque_up) {
182 proc_id = m_opaque_up->GetParentProcessID();
183 }
184 return proc_id;
185}
186
188 LLDB_INSTRUMENT_VA(this);
189
190 if (!m_opaque_up)
191 return nullptr;
192
193 const auto &arch = m_opaque_up->GetArchitecture();
194 if (!arch.IsValid())
195 return nullptr;
196
197 return StringPool::GetSystemPool().Intern(arch.GetTriple().getTriple());
198}
199
201 LLDB_INSTRUMENT_VA(this);
202
203 if (!m_opaque_up)
204 return 0;
205
206 const Args &args = m_opaque_up->GetArguments();
207 return args.GetArgumentCount();
208}
209
210const char *SBProcessInfo::GetArgumentAtIndex(uint32_t idx) const {
211 LLDB_INSTRUMENT_VA(this, idx);
212
213 if (!m_opaque_up)
214 return nullptr;
215
216 const Args &args = m_opaque_up->GetArguments();
218}
#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
const char * Intern(llvm::StringRef str) const
Definition StringPool.h:78
static StringPoolRef GetSystemPool()
The system pool. Only valid between Initialize and Terminate.
#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