blob: 681f5fe0ebf33515797d08f2a904bf2ac23286b1 [file] [log] [blame]
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +00001//===-- SBLaunchInfo.cpp ----------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/lldb-python.h"
11
12#include "lldb/API/SBLaunchInfo.h"
13
14#include "lldb/API/SBFileSpec.h"
15#include "lldb/API/SBListener.h"
16#include "lldb/Target/ProcessLaunchInfo.h"
17
18using namespace lldb;
19using namespace lldb_private;
20
21SBLaunchInfo::SBLaunchInfo (const char **argv) :
22 m_opaque_sp(new ProcessLaunchInfo())
23{
24 m_opaque_sp->GetFlags().Reset (eLaunchFlagDebug | eLaunchFlagDisableASLR);
25 if (argv && argv[0])
26 m_opaque_sp->GetArguments().SetArguments(argv);
27}
28
29SBLaunchInfo::~SBLaunchInfo()
30{
31}
32
33lldb_private::ProcessLaunchInfo &
34SBLaunchInfo::ref ()
35{
36 return *m_opaque_sp;
37}
38
Ilia K8f37ca52015-02-13 14:31:06 +000039const lldb_private::ProcessLaunchInfo &
40SBLaunchInfo::ref () const
41{
42 return *m_opaque_sp;
43}
44
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +000045lldb::pid_t
46SBLaunchInfo::GetProcessID()
47{
48 return m_opaque_sp->GetProcessID();
49}
50
51uint32_t
52SBLaunchInfo::GetUserID()
53{
54 return m_opaque_sp->GetUserID();
55}
56
57uint32_t
58SBLaunchInfo::GetGroupID()
59{
60 return m_opaque_sp->GetGroupID();
61}
62
63bool
64SBLaunchInfo::UserIDIsValid ()
65{
66 return m_opaque_sp->UserIDIsValid();
67}
68
69bool
70SBLaunchInfo::GroupIDIsValid ()
71{
72 return m_opaque_sp->GroupIDIsValid();
73}
74
75void
76SBLaunchInfo::SetUserID (uint32_t uid)
77{
78 m_opaque_sp->SetUserID (uid);
79}
80
81void
82SBLaunchInfo::SetGroupID (uint32_t gid)
83{
84 m_opaque_sp->SetGroupID (gid);
85}
86
87SBFileSpec
88SBLaunchInfo::GetExecutableFile ()
89{
90 return SBFileSpec (m_opaque_sp->GetExecutableFile());
91}
92
93void
94SBLaunchInfo::SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg)
95{
96 m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg);
97}
98
99SBListener
100SBLaunchInfo::GetListener ()
101{
102 return SBListener(m_opaque_sp->GetListener());
103}
104
105void
106SBLaunchInfo::SetListener (SBListener &listener)
107{
108 m_opaque_sp->SetListener(listener.GetSP());
109}
110
111uint32_t
112SBLaunchInfo::GetNumArguments ()
113{
114 return m_opaque_sp->GetArguments().GetArgumentCount();
115}
116
117const char *
118SBLaunchInfo::GetArgumentAtIndex (uint32_t idx)
119{
120 return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx);
121}
122
123void
124SBLaunchInfo::SetArguments (const char **argv, bool append)
125{
126 if (append)
127 {
128 if (argv)
129 m_opaque_sp->GetArguments().AppendArguments(argv);
130 }
131 else
132 {
133 if (argv)
134 m_opaque_sp->GetArguments().SetArguments(argv);
135 else
136 m_opaque_sp->GetArguments().Clear();
137 }
138}
139
140uint32_t
141SBLaunchInfo::GetNumEnvironmentEntries ()
142{
143 return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount();
144}
145
146const char *
147SBLaunchInfo::GetEnvironmentEntryAtIndex (uint32_t idx)
148{
149 return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx);
150}
151
152void
153SBLaunchInfo::SetEnvironmentEntries (const char **envp, bool append)
154{
155 if (append)
156 {
157 if (envp)
158 m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp);
159 }
160 else
161 {
162 if (envp)
163 m_opaque_sp->GetEnvironmentEntries().SetArguments(envp);
164 else
165 m_opaque_sp->GetEnvironmentEntries().Clear();
166 }
167}
168
169void
170SBLaunchInfo::Clear ()
171{
172 m_opaque_sp->Clear();
173}
174
175const char *
176SBLaunchInfo::GetWorkingDirectory () const
177{
178 return m_opaque_sp->GetWorkingDirectory();
179}
180
181void
182SBLaunchInfo::SetWorkingDirectory (const char *working_dir)
183{
184 m_opaque_sp->SetWorkingDirectory(working_dir);
185}
186
187uint32_t
188SBLaunchInfo::GetLaunchFlags ()
189{
190 return m_opaque_sp->GetFlags().Get();
191}
192
193void
194SBLaunchInfo::SetLaunchFlags (uint32_t flags)
195{
196 m_opaque_sp->GetFlags().Reset(flags);
197}
198
199const char *
200SBLaunchInfo::GetProcessPluginName ()
201{
202 return m_opaque_sp->GetProcessPluginName();
203}
204
205void
206SBLaunchInfo::SetProcessPluginName (const char *plugin_name)
207{
208 return m_opaque_sp->SetProcessPluginName (plugin_name);
209}
210
211const char *
212SBLaunchInfo::GetShell ()
213{
214 // Constify this string so that it is saved in the string pool. Otherwise
215 // it would be freed when this function goes out of scope.
216 ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
217 return shell.AsCString();
218}
219
220void
221SBLaunchInfo::SetShell (const char * path)
222{
223 m_opaque_sp->SetShell (FileSpec(path, false));
224}
225
Enrico Granatac11b1012015-02-10 03:16:55 +0000226bool
227SBLaunchInfo::GetGlobArguments ()
228{
229 return m_opaque_sp->GetGlobArguments();
230}
231
232void
233SBLaunchInfo::SetGlobArguments (bool glob)
234{
235 m_opaque_sp->SetGlobArguments(glob);
236}
237
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +0000238uint32_t
239SBLaunchInfo::GetResumeCount ()
240{
241 return m_opaque_sp->GetResumeCount();
242}
243
244void
245SBLaunchInfo::SetResumeCount (uint32_t c)
246{
247 m_opaque_sp->SetResumeCount (c);
248}
249
250bool
251SBLaunchInfo::AddCloseFileAction (int fd)
252{
253 return m_opaque_sp->AppendCloseFileAction(fd);
254}
255
256bool
257SBLaunchInfo::AddDuplicateFileAction (int fd, int dup_fd)
258{
259 return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd);
260}
261
262bool
263SBLaunchInfo::AddOpenFileAction (int fd, const char *path, bool read, bool write)
264{
265 return m_opaque_sp->AppendOpenFileAction(fd, path, read, write);
266}
267
268bool
269SBLaunchInfo::AddSuppressFileAction (int fd, bool read, bool write)
270{
271 return m_opaque_sp->AppendSuppressFileAction(fd, read, write);
272}
273
274void
275SBLaunchInfo::SetLaunchEventData (const char *data)
276{
277 m_opaque_sp->SetLaunchEventData (data);
278}
279
280const char *
281SBLaunchInfo::GetLaunchEventData () const
282{
283 return m_opaque_sp->GetLaunchEventData ();
284}
285
286void
287SBLaunchInfo::SetDetachOnError (bool enable)
288{
289 m_opaque_sp->SetDetachOnError (enable);
290}
291
292bool
293SBLaunchInfo::GetDetachOnError () const
294{
295 return m_opaque_sp->GetDetachOnError ();
296}