1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
use std::ffi::{CStr, CString};
use std::ptr;
use super::filespec::SBFileSpec;
use super::listener::SBListener;
use super::{LaunchFlags, lldb_pid_t};
use sys;
#[derive(Debug)]
pub struct SBLaunchInfo {
pub raw: sys::SBLaunchInfoRef,
}
impl SBLaunchInfo {
pub fn new() -> SBLaunchInfo {
SBLaunchInfo::wrap(unsafe { sys::CreateSBLaunchInfo(ptr::null_mut()) })
}
pub fn wrap(raw: sys::SBLaunchInfoRef) -> SBLaunchInfo {
SBLaunchInfo { raw: raw }
}
#[allow(missing_docs)]
pub fn process_id(&self) -> lldb_pid_t {
unsafe { sys::SBLaunchInfoGetProcessID(self.raw) }
}
#[allow(missing_docs)]
pub fn user_id(&self) -> u32 {
unsafe { sys::SBLaunchInfoGetUserID(self.raw) }
}
#[allow(missing_docs)]
pub fn set_user_id(&self, user_id: u32) {
unsafe { sys::SBLaunchInfoSetUserID(self.raw, user_id) };
}
#[allow(missing_docs)]
pub fn user_id_is_valid(&self) -> bool {
unsafe { sys::SBLaunchInfoUserIDIsValid(self.raw) != 0 }
}
#[allow(missing_docs)]
pub fn group_id(&self) -> u32 {
unsafe { sys::SBLaunchInfoGetGroupID(self.raw) }
}
#[allow(missing_docs)]
pub fn set_group_id(&self, group_id: u32) {
unsafe { sys::SBLaunchInfoSetGroupID(self.raw, group_id) };
}
#[allow(missing_docs)]
pub fn group_id_is_valid(&self) -> bool {
unsafe { sys::SBLaunchInfoGroupIDIsValid(self.raw) != 0 }
}
#[allow(missing_docs)]
pub fn executable_file(&self) -> Option<SBFileSpec> {
SBFileSpec::maybe_wrap(unsafe { sys::SBLaunchInfoGetExecutableFile(self.raw) })
}
pub fn set_executable_file(&self, filespec: &SBFileSpec, add_as_first_arg: bool) {
unsafe {
sys::SBLaunchInfoSetExecutableFile(self.raw, filespec.raw, add_as_first_arg as u8)
};
}
pub fn listener(&self) -> Option<SBListener> {
SBListener::maybe_wrap(unsafe { sys::SBLaunchInfoGetListener(self.raw) })
}
pub fn set_listener(&self, listener: &SBListener) {
unsafe { sys::SBLaunchInfoSetListener(self.raw, listener.raw) };
}
#[allow(missing_docs)]
pub fn launch_flags(&self) -> LaunchFlags {
LaunchFlags::from_bits_truncate(unsafe { sys::SBLaunchInfoGetLaunchFlags(self.raw) })
}
#[allow(missing_docs)]
pub fn set_launch_flags(&self, launch_flags: LaunchFlags) {
unsafe { sys::SBLaunchInfoSetLaunchFlags(self.raw, launch_flags.bits()) }
}
#[allow(missing_docs)]
pub fn process_plugin_name(&self) -> Option<&str> {
unsafe {
match CStr::from_ptr(sys::SBLaunchInfoGetProcessPluginName(self.raw)).to_str() {
Ok(s) => Some(s),
_ => None,
}
}
}
#[allow(missing_docs)]
pub fn set_process_plugin_name(&self, plugin: &str) {
let plugin = CString::new(plugin).unwrap();
unsafe { sys::SBLaunchInfoSetProcessPluginName(self.raw, plugin.as_ptr()) };
}
#[allow(missing_docs)]
pub fn shell(&self) -> Option<&str> {
unsafe {
match CStr::from_ptr(sys::SBLaunchInfoGetShell(self.raw)).to_str() {
Ok(s) => Some(s),
_ => None,
}
}
}
#[allow(missing_docs)]
pub fn set_shell(&self, shell: &str) {
let shell = CString::new(shell).unwrap();
unsafe { sys::SBLaunchInfoSetShell(self.raw, shell.as_ptr()) };
}
#[allow(missing_docs)]
pub fn shell_expand_arguments(&self) -> bool {
unsafe { sys::SBLaunchInfoGetShellExpandArguments(self.raw) != 0 }
}
#[allow(missing_docs)]
pub fn set_shell_expand_arguments(&self, expand: bool) {
unsafe { sys::SBLaunchInfoSetShellExpandArguments(self.raw, expand as u8) };
}
#[allow(missing_docs)]
pub fn resume_count(&self) -> u32 {
unsafe { sys::SBLaunchInfoGetResumeCount(self.raw) }
}
#[allow(missing_docs)]
pub fn set_resume_count(&self, resume_count: u32) {
unsafe { sys::SBLaunchInfoSetResumeCount(self.raw, resume_count) };
}
#[allow(missing_docs)]
pub fn add_close_file_action(&self, fd: i32) -> bool {
unsafe { sys::SBLaunchInfoAddCloseFileAction(self.raw, fd) != 0 }
}
#[allow(missing_docs)]
pub fn add_duplicate_file_action(&self, fd: i32, dup_fd: i32) -> bool {
unsafe { sys::SBLaunchInfoAddDuplicateFileAction(self.raw, fd, dup_fd) != 0 }
}
#[allow(missing_docs)]
pub fn add_open_file_action(&self, fd: i32, path: &str, read: bool, write: bool) -> bool {
let path = CString::new(path).unwrap();
unsafe {
sys::SBLaunchInfoAddOpenFileAction(
self.raw,
fd,
path.as_ptr(),
read as u8,
write as u8,
) != 0
}
}
#[allow(missing_docs)]
pub fn add_suppress_file_action(&self, fd: i32, read: bool, write: bool) -> bool {
unsafe {
sys::SBLaunchInfoAddSuppressFileAction(self.raw, fd, read as u8, write as u8) != 0
}
}
#[allow(missing_docs)]
pub fn launch_event_data(&self) -> Option<&str> {
unsafe {
match CStr::from_ptr(sys::SBLaunchInfoGetLaunchEventData(self.raw)).to_str() {
Ok(s) => Some(s),
_ => None,
}
}
}
#[allow(missing_docs)]
pub fn set_launch_event_data(&self, data: &str) {
let data = CString::new(data).unwrap();
unsafe { sys::SBLaunchInfoSetLaunchEventData(self.raw, data.as_ptr()) };
}
#[allow(missing_docs)]
pub fn detach_on_error(&self) -> bool {
unsafe { sys::SBLaunchInfoGetDetachOnError(self.raw) != 0 }
}
#[allow(missing_docs)]
pub fn set_detach_on_error(&self, detach: bool) {
unsafe { sys::SBLaunchInfoSetDetachOnError(self.raw, detach as u8) };
}
}
impl Default for SBLaunchInfo {
fn default() -> SBLaunchInfo {
SBLaunchInfo::new()
}
}
impl Drop for SBLaunchInfo {
fn drop(&mut self) {
unsafe { sys::DisposeSBLaunchInfo(self.raw) };
}
}