LLDB mainline
SBAttachInfo.cpp
Go to the documentation of this file.
1//===-- SBAttachInfo.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"
12#include "lldb/API/SBListener.h"
14#include "lldb/Target/Process.h"
18
19using namespace lldb;
20using namespace lldb_private;
21
25
28 LLDB_INSTRUMENT_VA(this, pid);
29
30 m_opaque_sp->SetProcessID(pid);
31}
32
33SBAttachInfo::SBAttachInfo(const char *path, bool wait_for)
35 LLDB_INSTRUMENT_VA(this, path, wait_for);
36
37 if (path && path[0])
38 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
39 m_opaque_sp->SetWaitForLaunch(wait_for);
40}
41
42SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async)
44 LLDB_INSTRUMENT_VA(this, path, wait_for, async);
45
46 if (path && path[0])
47 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
48 m_opaque_sp->SetWaitForLaunch(wait_for);
49 m_opaque_sp->SetAsync(async);
50}
51
58
60
62
64 LLDB_INSTRUMENT_VA(this, rhs);
65
66 if (this != &rhs)
68 return *this;
69}
70
73
74 return m_opaque_sp->GetProcessID();
75}
76
78 LLDB_INSTRUMENT_VA(this, pid);
79
80 m_opaque_sp->SetProcessID(pid);
81}
82
85
86 return m_opaque_sp->GetResumeCount();
87}
88
90 LLDB_INSTRUMENT_VA(this, c);
91
92 m_opaque_sp->SetResumeCount(c);
93}
94
97
99 m_opaque_sp->GetProcessPluginName());
100}
101
102void SBAttachInfo::SetProcessPluginName(const char *plugin_name) {
103 LLDB_INSTRUMENT_VA(this, plugin_name);
104
105 return m_opaque_sp->SetProcessPluginName(plugin_name);
106}
107
108void SBAttachInfo::SetExecutable(const char *path) {
109 LLDB_INSTRUMENT_VA(this, path);
110
111 if (path && path[0])
112 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
113 else
114 m_opaque_sp->GetExecutableFile().Clear();
115}
116
118 LLDB_INSTRUMENT_VA(this, exe_file);
119
120 if (exe_file.IsValid())
121 m_opaque_sp->GetExecutableFile() = exe_file.ref();
122 else
123 m_opaque_sp->GetExecutableFile().Clear();
124}
125
127 LLDB_INSTRUMENT_VA(this);
128
129 return m_opaque_sp->GetWaitForLaunch();
130}
131
133 LLDB_INSTRUMENT_VA(this, b);
134
135 m_opaque_sp->SetWaitForLaunch(b);
136}
137
138void SBAttachInfo::SetWaitForLaunch(bool b, bool async) {
139 LLDB_INSTRUMENT_VA(this, b, async);
140
141 m_opaque_sp->SetWaitForLaunch(b);
142 m_opaque_sp->SetAsync(async);
143}
144
146 LLDB_INSTRUMENT_VA(this);
147
148 return m_opaque_sp->GetIgnoreExisting();
149}
150
152 LLDB_INSTRUMENT_VA(this, b);
153
154 m_opaque_sp->SetIgnoreExisting(b);
155}
156
158 LLDB_INSTRUMENT_VA(this);
159
160 return m_opaque_sp->GetUserID();
161}
162
164 LLDB_INSTRUMENT_VA(this);
165
166 return m_opaque_sp->GetGroupID();
167}
168
170 LLDB_INSTRUMENT_VA(this);
171
172 return m_opaque_sp->UserIDIsValid();
173}
174
176 LLDB_INSTRUMENT_VA(this);
177
178 return m_opaque_sp->GroupIDIsValid();
179}
180
181void SBAttachInfo::SetUserID(uint32_t uid) {
182 LLDB_INSTRUMENT_VA(this, uid);
183
184 m_opaque_sp->SetUserID(uid);
185}
186
187void SBAttachInfo::SetGroupID(uint32_t gid) {
188 LLDB_INSTRUMENT_VA(this, gid);
189
190 m_opaque_sp->SetGroupID(gid);
191}
192
194 LLDB_INSTRUMENT_VA(this);
195
196 return m_opaque_sp->GetEffectiveUserID();
197}
198
200 LLDB_INSTRUMENT_VA(this);
201
202 return m_opaque_sp->GetEffectiveGroupID();
203}
204
206 LLDB_INSTRUMENT_VA(this);
207
208 return m_opaque_sp->EffectiveUserIDIsValid();
209}
210
212 LLDB_INSTRUMENT_VA(this);
213
214 return m_opaque_sp->EffectiveGroupIDIsValid();
215}
216
218 LLDB_INSTRUMENT_VA(this, uid);
219
220 m_opaque_sp->SetEffectiveUserID(uid);
221}
222
224 LLDB_INSTRUMENT_VA(this, gid);
225
226 m_opaque_sp->SetEffectiveGroupID(gid);
227}
228
230 LLDB_INSTRUMENT_VA(this);
231
232 return m_opaque_sp->GetParentProcessID();
233}
234
236 LLDB_INSTRUMENT_VA(this, pid);
237
238 m_opaque_sp->SetParentProcessID(pid);
239}
240
242 LLDB_INSTRUMENT_VA(this);
243
244 return m_opaque_sp->ParentProcessIDIsValid();
245}
246
248 LLDB_INSTRUMENT_VA(this);
249
250 return SBListener(m_opaque_sp->GetListener());
251}
252
254 LLDB_INSTRUMENT_VA(this, listener);
255
256 m_opaque_sp->SetListener(listener.GetSP());
257}
258
260 LLDB_INSTRUMENT_VA(this);
261
262 lldb::ListenerSP shadow_sp = m_opaque_sp->GetShadowListener();
263 if (!shadow_sp)
264 return SBListener();
265 return SBListener(shadow_sp);
266}
267
269 LLDB_INSTRUMENT_VA(this, listener);
270
271 m_opaque_sp->SetShadowListener(listener.GetSP());
272}
273
275 LLDB_INSTRUMENT_VA(this);
276
277 ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata();
278
279 if (!metadata_sp || !*metadata_sp)
280 return nullptr;
281
283 metadata_sp->GetClassName());
284}
285
286void SBAttachInfo::SetScriptedProcessClassName(const char *class_name) {
287 LLDB_INSTRUMENT_VA(this, class_name);
288
289 ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata();
290
291 if (!metadata_sp)
292 metadata_sp = std::make_shared<ScriptedMetadata>(class_name, nullptr);
293 else
294 metadata_sp = std::make_shared<ScriptedMetadata>(class_name,
295 metadata_sp->GetArgsSP());
296
297 m_opaque_sp->SetScriptedMetadata(metadata_sp);
298}
299
301 LLDB_INSTRUMENT_VA(this);
302
303 ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata();
304
305 SBStructuredData data;
306 if (!metadata_sp)
307 return data;
308
309 lldb_private::StructuredData::DictionarySP dict_sp = metadata_sp->GetArgsSP();
310 data.m_impl_up->SetObjectSP(dict_sp);
311
312 return data;
313}
314
316 LLDB_INSTRUMENT_VA(this, dict);
317
318 if (!dict.IsValid() || !dict.m_impl_up)
319 return;
320
321 StructuredData::ObjectSP obj_sp = dict.m_impl_up->GetObjectSP();
322
323 if (!obj_sp)
324 return;
325
327 std::make_shared<StructuredData::Dictionary>(obj_sp);
328 if (!dict_sp || dict_sp->GetType() == lldb::eStructuredDataTypeInvalid)
329 return;
330
331 ScriptedMetadataSP metadata_sp = m_opaque_sp->GetScriptedMetadata();
332
333 if (!metadata_sp)
334 metadata_sp = std::make_shared<ScriptedMetadata>("", dict_sp);
335 else
336 metadata_sp = std::make_shared<ScriptedMetadata>(
337 metadata_sp->GetClassName(), dict_sp);
338
339 m_opaque_sp->SetScriptedMetadata(metadata_sp);
340}
#define LLDB_INSTRUMENT_VA(...)
uint32_t GetEffectiveUserID()
ProcessAttachInfoSP m_opaque_sp
SBListener GetListener()
Get the listener that will be used to receive process events.
lldb::SBStructuredData GetScriptedProcessDictionary() const
void SetShadowListener(SBListener &listener)
Set the shadow listener that will receive public process events, additionally to the default process ...
void SetProcessPluginName(const char *plugin_name)
uint32_t GetResumeCount()
void SetGroupID(uint32_t gid)
void SetIgnoreExisting(bool b)
void SetEffectiveUserID(uint32_t uid)
void SetParentProcessID(lldb::pid_t pid)
lldb_private::ProcessAttachInfo & ref()
void SetListener(SBListener &listener)
Set the listener that will be used to receive process events.
lldb::pid_t GetParentProcessID()
void SetScriptedProcessDictionary(lldb::SBStructuredData dict)
const char * GetProcessPluginName()
void SetEffectiveGroupID(uint32_t gid)
void SetProcessID(lldb::pid_t pid)
void SetScriptedProcessClassName(const char *class_name)
void SetResumeCount(uint32_t c)
SBAttachInfo & operator=(const SBAttachInfo &rhs)
SBListener GetShadowListener()
Get the shadow listener that receive public process events, additionally to the default process event...
uint32_t GetEffectiveGroupID()
const char * GetScriptedProcessClassName() const
lldb::pid_t GetProcessID()
void SetWaitForLaunch(bool b)
Set attach by process name settings.
void SetUserID(uint32_t uid)
void SetExecutable(const char *path)
bool IsValid() const
const lldb_private::FileSpec & ref() const
lldb::ListenerSP GetSP()
StructuredDataImplUP m_impl_up
const char * Intern(llvm::StringRef str) const
Definition StringPool.h:78
const char * InternNonEmpty(llvm::StringRef str) const
Like Intern, but an empty string yields nullptr.
Definition StringPool.h:81
static StringPoolRef GetSystemPool()
The system pool. Only valid between Initialize and Terminate.
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
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:25
std::shared_ptr< lldb_private::ScriptedMetadata > ScriptedMetadataSP
uint64_t pid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::Listener > ListenerSP
@ eStructuredDataTypeInvalid
class LLDB_API SBListener
Definition SBDefines.h:89