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"
13 #include "lldb/Target/Process.h"
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
20  LLDB_INSTRUMENT_VA(this);
21 }
22 
24  : m_opaque_sp(new ProcessAttachInfo()) {
25  LLDB_INSTRUMENT_VA(this, pid);
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_INSTRUMENT_VA(this, 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_INSTRUMENT_VA(this, path, wait_for, async);
42 
43  if (path && path[0])
44  m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
45  m_opaque_sp->SetWaitForLaunch(wait_for);
46  m_opaque_sp->SetAsync(async);
47 }
48 
50  : m_opaque_sp(new ProcessAttachInfo()) {
51  LLDB_INSTRUMENT_VA(this, rhs);
52 
54 }
55 
56 SBAttachInfo::~SBAttachInfo() = default;
57 
59 
61  LLDB_INSTRUMENT_VA(this, rhs);
62 
63  if (this != &rhs)
65  return *this;
66 }
67 
69  LLDB_INSTRUMENT_VA(this);
70 
71  return m_opaque_sp->GetProcessID();
72 }
73 
75  LLDB_INSTRUMENT_VA(this, pid);
76 
77  m_opaque_sp->SetProcessID(pid);
78 }
79 
81  LLDB_INSTRUMENT_VA(this);
82 
83  return m_opaque_sp->GetResumeCount();
84 }
85 
87  LLDB_INSTRUMENT_VA(this, c);
88 
89  m_opaque_sp->SetResumeCount(c);
90 }
91 
93  LLDB_INSTRUMENT_VA(this);
94 
95  return m_opaque_sp->GetProcessPluginName();
96 }
97 
98 void SBAttachInfo::SetProcessPluginName(const char *plugin_name) {
99  LLDB_INSTRUMENT_VA(this, plugin_name);
100 
101  return m_opaque_sp->SetProcessPluginName(plugin_name);
102 }
103 
104 void SBAttachInfo::SetExecutable(const char *path) {
105  LLDB_INSTRUMENT_VA(this, path);
106 
107  if (path && path[0])
108  m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
109  else
110  m_opaque_sp->GetExecutableFile().Clear();
111 }
112 
114  LLDB_INSTRUMENT_VA(this, exe_file);
115 
116  if (exe_file.IsValid())
117  m_opaque_sp->GetExecutableFile() = exe_file.ref();
118  else
119  m_opaque_sp->GetExecutableFile().Clear();
120 }
121 
123  LLDB_INSTRUMENT_VA(this);
124 
125  return m_opaque_sp->GetWaitForLaunch();
126 }
127 
129  LLDB_INSTRUMENT_VA(this, b);
130 
131  m_opaque_sp->SetWaitForLaunch(b);
132 }
133 
134 void SBAttachInfo::SetWaitForLaunch(bool b, bool async) {
135  LLDB_INSTRUMENT_VA(this, b, async);
136 
137  m_opaque_sp->SetWaitForLaunch(b);
138  m_opaque_sp->SetAsync(async);
139 }
140 
142  LLDB_INSTRUMENT_VA(this);
143 
144  return m_opaque_sp->GetIgnoreExisting();
145 }
146 
148  LLDB_INSTRUMENT_VA(this, b);
149 
150  m_opaque_sp->SetIgnoreExisting(b);
151 }
152 
154  LLDB_INSTRUMENT_VA(this);
155 
156  return m_opaque_sp->GetUserID();
157 }
158 
160  LLDB_INSTRUMENT_VA(this);
161 
162  return m_opaque_sp->GetGroupID();
163 }
164 
166  LLDB_INSTRUMENT_VA(this);
167 
168  return m_opaque_sp->UserIDIsValid();
169 }
170 
172  LLDB_INSTRUMENT_VA(this);
173 
174  return m_opaque_sp->GroupIDIsValid();
175 }
176 
178  LLDB_INSTRUMENT_VA(this, uid);
179 
180  m_opaque_sp->SetUserID(uid);
181 }
182 
184  LLDB_INSTRUMENT_VA(this, gid);
185 
186  m_opaque_sp->SetGroupID(gid);
187 }
188 
190  LLDB_INSTRUMENT_VA(this);
191 
192  return m_opaque_sp->GetEffectiveUserID();
193 }
194 
196  LLDB_INSTRUMENT_VA(this);
197 
198  return m_opaque_sp->GetEffectiveGroupID();
199 }
200 
202  LLDB_INSTRUMENT_VA(this);
203 
204  return m_opaque_sp->EffectiveUserIDIsValid();
205 }
206 
208  LLDB_INSTRUMENT_VA(this);
209 
210  return m_opaque_sp->EffectiveGroupIDIsValid();
211 }
212 
214  LLDB_INSTRUMENT_VA(this, uid);
215 
216  m_opaque_sp->SetEffectiveUserID(uid);
217 }
218 
220  LLDB_INSTRUMENT_VA(this, gid);
221 
222  m_opaque_sp->SetEffectiveGroupID(gid);
223 }
224 
226  LLDB_INSTRUMENT_VA(this);
227 
228  return m_opaque_sp->GetParentProcessID();
229 }
230 
232  LLDB_INSTRUMENT_VA(this, pid);
233 
234  m_opaque_sp->SetParentProcessID(pid);
235 }
236 
238  LLDB_INSTRUMENT_VA(this);
239 
240  return m_opaque_sp->ParentProcessIDIsValid();
241 }
242 
244  LLDB_INSTRUMENT_VA(this);
245 
246  return SBListener(m_opaque_sp->GetListener());
247 }
248 
250  LLDB_INSTRUMENT_VA(this, listener);
251 
252  m_opaque_sp->SetListener(listener.GetSP());
253 }
Instrumentation.h
lldb::SBAttachInfo::operator=
SBAttachInfo & operator=(const SBAttachInfo &rhs)
Definition: SBAttachInfo.cpp:60
lldb::SBAttachInfo::SetParentProcessID
void SetParentProcessID(lldb::pid_t pid)
Definition: SBAttachInfo.cpp:231
lldb::SBAttachInfo::GetResumeCount
uint32_t GetResumeCount()
Definition: SBAttachInfo.cpp:80
lldb::SBListener
class LLDB_API SBListener
Definition: SBDefines.h:68
lldb::SBListener::GetSP
lldb::ListenerSP GetSP()
Definition: SBListener.cpp:287
lldb::SBAttachInfo::ParentProcessIDIsValid
bool ParentProcessIDIsValid()
Definition: SBAttachInfo.cpp:237
SBListener.h
lldb::SBAttachInfo::SetWaitForLaunch
void SetWaitForLaunch(bool b)
Set attach by process name settings.
Definition: SBAttachInfo.cpp:128
Process.h
lldb::SBAttachInfo::EffectiveGroupIDIsValid
bool EffectiveGroupIDIsValid()
Definition: SBAttachInfo.cpp:207
lldb::SBAttachInfo::GetEffectiveGroupID
uint32_t GetEffectiveGroupID()
Definition: SBAttachInfo.cpp:195
lldb::SBAttachInfo::GetGroupID
uint32_t GetGroupID()
Definition: SBAttachInfo.cpp:159
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:104
lldb::SBAttachInfo::GetUserID
uint32_t GetUserID()
Definition: SBAttachInfo.cpp:153
lldb::SBAttachInfo::GetListener
SBListener GetListener()
Get the listener that will be used to receive process events.
Definition: SBAttachInfo.cpp:243
lldb::SBAttachInfo::SetUserID
void SetUserID(uint32_t uid)
Definition: SBAttachInfo.cpp:177
lldb::SBAttachInfo::~SBAttachInfo
~SBAttachInfo()
lldb::SBAttachInfo::SetProcessPluginName
void SetProcessPluginName(const char *plugin_name)
Definition: SBAttachInfo.cpp:98
SBAttachInfo.h
lldb::SBFileSpec::ref
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:162
lldb::SBFileSpec::IsValid
bool IsValid() const
Definition: SBFileSpec.cpp:76
lldb::SBAttachInfo::GetEffectiveUserID
uint32_t GetEffectiveUserID()
Definition: SBAttachInfo.cpp:189
lldb::SBAttachInfo::SetIgnoreExisting
void SetIgnoreExisting(bool b)
Definition: SBAttachInfo.cpp:147
lldb::SBAttachInfo::ref
lldb_private::ProcessAttachInfo & ref()
Definition: SBAttachInfo.cpp:58
lldb::SBAttachInfo::SBAttachInfo
SBAttachInfo()
Definition: SBAttachInfo.cpp:19
lldb::SBAttachInfo::GetParentProcessID
lldb::pid_t GetParentProcessID()
Definition: SBAttachInfo.cpp:225
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb::SBAttachInfo::EffectiveUserIDIsValid
bool EffectiveUserIDIsValid()
Definition: SBAttachInfo.cpp:201
lldb::SBAttachInfo::GetIgnoreExisting
bool GetIgnoreExisting()
Definition: SBAttachInfo.cpp:141
lldb::SBListener
Definition: SBListener.h:16
uint32_t
lldb::SBAttachInfo::GetProcessID
lldb::pid_t GetProcessID()
Definition: SBAttachInfo.cpp:68
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb::SBAttachInfo::GetWaitForLaunch
bool GetWaitForLaunch()
Definition: SBAttachInfo.cpp:122
lldb::SBAttachInfo::SetListener
void SetListener(SBListener &listener)
Set the listener that will be used to receive process events.
Definition: SBAttachInfo.cpp:249
lldb::SBAttachInfo::SetResumeCount
void SetResumeCount(uint32_t c)
Definition: SBAttachInfo.cpp:86
lldb::SBFileSpec
Definition: SBFileSpec.h:16
lldb::SBAttachInfo::GroupIDIsValid
bool GroupIDIsValid()
Definition: SBAttachInfo.cpp:171
lldb::SBAttachInfo::GetProcessPluginName
const char * GetProcessPluginName()
Definition: SBAttachInfo.cpp:92
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:213
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:100
lldb::SBAttachInfo::UserIDIsValid
bool UserIDIsValid()
Definition: SBAttachInfo.cpp:165
lldb::SBAttachInfo::SetEffectiveGroupID
void SetEffectiveGroupID(uint32_t gid)
Definition: SBAttachInfo.cpp:219
lldb::SBAttachInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: SBAttachInfo.cpp:74
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:183