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 "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/API/SBListener.h"
14 #include "lldb/Target/Process.h"
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
21 }
22 
24  : m_opaque_sp(new ProcessAttachInfo()) {
26 
27  m_opaque_sp->SetProcessID(pid);
28 }
29 
30 SBAttachInfo::SBAttachInfo(const char *path, bool wait_for)
31  : m_opaque_sp(new ProcessAttachInfo()) {
32  LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool), path, wait_for);
33 
34  if (path && path[0])
35  m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
36  m_opaque_sp->SetWaitForLaunch(wait_for);
37 }
38 
39 SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async)
40  : m_opaque_sp(new ProcessAttachInfo()) {
41  LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool), path,
42  wait_for, async);
43 
44  if (path && path[0])
45  m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
46  m_opaque_sp->SetWaitForLaunch(wait_for);
47  m_opaque_sp->SetAsync(async);
48 }
49 
51  : m_opaque_sp(new ProcessAttachInfo()) {
53 
55 }
56 
57 SBAttachInfo::~SBAttachInfo() = default;
58 
60 
63  SBAttachInfo, operator=,(const lldb::SBAttachInfo &), rhs);
64 
65  if (this != &rhs)
67  return LLDB_RECORD_RESULT(*this);
68 }
69 
72 
73  return m_opaque_sp->GetProcessID();
74 }
75 
78 
79  m_opaque_sp->SetProcessID(pid);
80 }
81 
84 
85  return m_opaque_sp->GetResumeCount();
86 }
87 
90 
91  m_opaque_sp->SetResumeCount(c);
92 }
93 
96 
97  return m_opaque_sp->GetProcessPluginName();
98 }
99 
100 void SBAttachInfo::SetProcessPluginName(const char *plugin_name) {
102  plugin_name);
103 
104  return m_opaque_sp->SetProcessPluginName(plugin_name);
105 }
106 
107 void SBAttachInfo::SetExecutable(const char *path) {
108  LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (const char *), path);
109 
110  if (path && path[0])
111  m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
112  else
113  m_opaque_sp->GetExecutableFile().Clear();
114 }
115 
118  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 
128 
129  return m_opaque_sp->GetWaitForLaunch();
130 }
131 
134 
135  m_opaque_sp->SetWaitForLaunch(b);
136 }
137 
138 void SBAttachInfo::SetWaitForLaunch(bool b, bool async) {
139  LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool), b,
140  async);
141 
142  m_opaque_sp->SetWaitForLaunch(b);
143  m_opaque_sp->SetAsync(async);
144 }
145 
148 
149  return m_opaque_sp->GetIgnoreExisting();
150 }
151 
154 
155  m_opaque_sp->SetIgnoreExisting(b);
156 }
157 
160 
161  return m_opaque_sp->GetUserID();
162 }
163 
166 
167  return m_opaque_sp->GetGroupID();
168 }
169 
172 
173  return m_opaque_sp->UserIDIsValid();
174 }
175 
178 
179  return m_opaque_sp->GroupIDIsValid();
180 }
181 
184 
185  m_opaque_sp->SetUserID(uid);
186 }
187 
190 
191  m_opaque_sp->SetGroupID(gid);
192 }
193 
196 
197  return m_opaque_sp->GetEffectiveUserID();
198 }
199 
202 
203  return m_opaque_sp->GetEffectiveGroupID();
204 }
205 
208 
209  return m_opaque_sp->EffectiveUserIDIsValid();
210 }
211 
214 
215  return m_opaque_sp->EffectiveGroupIDIsValid();
216 }
217 
220 
221  m_opaque_sp->SetEffectiveUserID(uid);
222 }
223 
226 
227  m_opaque_sp->SetEffectiveGroupID(gid);
228 }
229 
232 
233  return m_opaque_sp->GetParentProcessID();
234 }
235 
238  pid);
239 
240  m_opaque_sp->SetParentProcessID(pid);
241 }
242 
245 
246  return m_opaque_sp->ParentProcessIDIsValid();
247 }
248 
251 
252  return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener()));
253 }
254 
257  listener);
258 
259  m_opaque_sp->SetListener(listener.GetSP());
260 }
261 
262 namespace lldb_private {
263 namespace repro {
264 
265 template <>
269  LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool));
270  LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool));
273  SBAttachInfo, operator=,(const lldb::SBAttachInfo &));
274  LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetProcessID, ());
275  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t));
276  LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetResumeCount, ());
277  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t));
278  LLDB_REGISTER_METHOD(const char *, SBAttachInfo, GetProcessPluginName, ());
279  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessPluginName,
280  (const char *));
281  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (const char *));
282  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec));
283  LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetWaitForLaunch, ());
284  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool));
285  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool));
286  LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetIgnoreExisting, ());
287  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool));
288  LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetUserID, ());
289  LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetGroupID, ());
290  LLDB_REGISTER_METHOD(bool, SBAttachInfo, UserIDIsValid, ());
291  LLDB_REGISTER_METHOD(bool, SBAttachInfo, GroupIDIsValid, ());
292  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetUserID, (uint32_t));
293  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t));
294  LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveUserID, ());
295  LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveGroupID, ());
296  LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveUserIDIsValid, ());
297  LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveGroupIDIsValid, ());
298  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t));
299  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t));
300  LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetParentProcessID, ());
301  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t));
302  LLDB_REGISTER_METHOD(bool, SBAttachInfo, ParentProcessIDIsValid, ());
304  LLDB_REGISTER_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &));
305 }
306 
307 }
308 }
lldb::SBAttachInfo::operator=
SBAttachInfo & operator=(const SBAttachInfo &rhs)
Definition: SBAttachInfo.cpp:61
lldb::SBAttachInfo::SetParentProcessID
void SetParentProcessID(lldb::pid_t pid)
Definition: SBAttachInfo.cpp:236
LLDB_RECORD_RESULT
#define LLDB_RECORD_RESULT(Result)
Definition: ReproducerInstrumentation.h:211
lldb::SBAttachInfo::GetResumeCount
uint32_t GetResumeCount()
Definition: SBAttachInfo.cpp:82
LLDB_RECORD_METHOD_NO_ARGS
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:165
lldb::SBListener
class LLDB_API SBListener
Definition: SBDefines.h:56
LLDB_RECORD_CONSTRUCTOR_NO_ARGS
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
Definition: ReproducerInstrumentation.h:136
lldb::SBListener::GetSP
lldb::ListenerSP GetSP()
Definition: SBListener.cpp:315
lldb::SBAttachInfo::ParentProcessIDIsValid
bool ParentProcessIDIsValid()
Definition: SBAttachInfo.cpp:243
SBReproducerPrivate.h
LLDB_REGISTER_CONSTRUCTOR
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
Definition: ReproducerInstrumentation.h:89
SBListener.h
lldb::SBAttachInfo::SetWaitForLaunch
void SetWaitForLaunch(bool b)
Set attach by process name settings.
Definition: SBAttachInfo.cpp:132
Process.h
lldb::SBAttachInfo::EffectiveGroupIDIsValid
bool EffectiveGroupIDIsValid()
Definition: SBAttachInfo.cpp:212
lldb::SBAttachInfo::GetEffectiveGroupID
uint32_t GetEffectiveGroupID()
Definition: SBAttachInfo.cpp:200
lldb_private::repro::RegisterMethods< SBAttachInfo >
void RegisterMethods< SBAttachInfo >(Registry &R)
Definition: SBAttachInfo.cpp:266
R
#define R(base)
lldb::SBAttachInfo::GetGroupID
uint32_t GetGroupID()
Definition: SBAttachInfo.cpp:164
LLDB_RECORD_METHOD
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:158
lldb_private::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Utils.h
SBFileSpec.h
lldb::SBAttachInfo::SetExecutable
void SetExecutable(const char *path)
Definition: SBAttachInfo.cpp:107
lldb::SBAttachInfo::GetUserID
uint32_t GetUserID()
Definition: SBAttachInfo.cpp:158
lldb::SBAttachInfo::GetListener
SBListener GetListener()
Get the listener that will be used to receive process events.
Definition: SBAttachInfo.cpp:249
lldb::SBAttachInfo::SetUserID
void SetUserID(uint32_t uid)
Definition: SBAttachInfo.cpp:182
lldb::SBAttachInfo::~SBAttachInfo
~SBAttachInfo()
lldb::SBAttachInfo::SetProcessPluginName
void SetProcessPluginName(const char *plugin_name)
Definition: SBAttachInfo.cpp:100
SBAttachInfo.h
lldb::SBFileSpec::ref
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:168
lldb::SBFileSpec::IsValid
bool IsValid() const
Definition: SBFileSpec.cpp:79
lldb::SBAttachInfo::GetEffectiveUserID
uint32_t GetEffectiveUserID()
Definition: SBAttachInfo.cpp:194
lldb::SBAttachInfo::SetIgnoreExisting
void SetIgnoreExisting(bool b)
Definition: SBAttachInfo.cpp:152
lldb::SBAttachInfo::ref
lldb_private::ProcessAttachInfo & ref()
Definition: SBAttachInfo.cpp:59
lldb::SBAttachInfo::SBAttachInfo
SBAttachInfo()
Definition: SBAttachInfo.cpp:19
lldb::SBAttachInfo::GetParentProcessID
lldb::pid_t GetParentProcessID()
Definition: SBAttachInfo.cpp:230
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb::SBAttachInfo::EffectiveUserIDIsValid
bool EffectiveUserIDIsValid()
Definition: SBAttachInfo.cpp:206
LLDB_RECORD_CONSTRUCTOR
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
Definition: ReproducerInstrumentation.h:133
lldb::SBAttachInfo::GetIgnoreExisting
bool GetIgnoreExisting()
Definition: SBAttachInfo.cpp:146
lldb_private::repro::Registry
The registry contains a unique mapping between functions and their ID.
Definition: ReproducerInstrumentation.h:517
lldb::SBListener
Definition: SBListener.h:16
uint32_t
lldb::SBAttachInfo::GetProcessID
lldb::pid_t GetProcessID()
Definition: SBAttachInfo.cpp:70
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb::SBAttachInfo::GetWaitForLaunch
bool GetWaitForLaunch()
Definition: SBAttachInfo.cpp:126
lldb::SBAttachInfo::SetListener
void SetListener(SBListener &listener)
Set the listener that will be used to receive process events.
Definition: SBAttachInfo.cpp:255
lldb::SBAttachInfo::SetResumeCount
void SetResumeCount(uint32_t c)
Definition: SBAttachInfo.cpp:88
lldb::SBFileSpec
Definition: SBFileSpec.h:16
lldb::SBAttachInfo::GroupIDIsValid
bool GroupIDIsValid()
Definition: SBAttachInfo.cpp:176
lldb::SBAttachInfo::GetProcessPluginName
const char * GetProcessPluginName()
Definition: SBAttachInfo.cpp:94
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::SBAttachInfo::SetEffectiveUserID
void SetEffectiveUserID(uint32_t uid)
Definition: SBAttachInfo.cpp:218
lldb::SBAttachInfo::UserIDIsValid
bool UserIDIsValid()
Definition: SBAttachInfo.cpp:170
lldb::SBAttachInfo::SetEffectiveGroupID
void SetEffectiveGroupID(uint32_t gid)
Definition: SBAttachInfo.cpp:224
lldb::SBAttachInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: SBAttachInfo.cpp:76
lldb::SBAttachInfo
Definition: SBAttachInfo.h:18
lldb
Definition: SBAddress.h:15
lldb::SBAttachInfo::m_opaque_sp
ProcessAttachInfoSP m_opaque_sp
Definition: SBAttachInfo.h:172
lldb::SBAttachInfo::SetGroupID
void SetGroupID(uint32_t gid)
Definition: SBAttachInfo.cpp:188
LLDB_REGISTER_METHOD
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:93