lldb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE-APACHE +190 -0
- data/LICENSE-MIT +21 -0
- data/README.md +240 -0
- data/Rakefile +80 -0
- data/Steepfile +11 -0
- data/examples/basic_debug.rb +111 -0
- data/examples/breakpoints.rb +72 -0
- data/examples/expression_eval.rb +84 -0
- data/examples/test_program.c +14 -0
- data/ext/lldb/Makefile +24 -0
- data/ext/lldb/extconf.rb +160 -0
- data/ext/lldb/liblldb_wrapper.dylib +0 -0
- data/ext/lldb/lldb_wrapper.cpp +2051 -0
- data/ext/lldb/lldb_wrapper.h +424 -0
- data/ext/lldb/lldb_wrapper.o +0 -0
- data/ext/lldb/mkmf.log +24 -0
- data/lib/lldb/breakpoint.rb +233 -0
- data/lib/lldb/breakpoint_location.rb +117 -0
- data/lib/lldb/command_interpreter.rb +62 -0
- data/lib/lldb/command_return_object.rb +71 -0
- data/lib/lldb/debugger.rb +179 -0
- data/lib/lldb/error.rb +70 -0
- data/lib/lldb/ffi_bindings.rb +394 -0
- data/lib/lldb/frame.rb +226 -0
- data/lib/lldb/launch_info.rb +85 -0
- data/lib/lldb/module.rb +61 -0
- data/lib/lldb/process.rb +317 -0
- data/lib/lldb/symbol_context.rb +52 -0
- data/lib/lldb/target.rb +427 -0
- data/lib/lldb/thread.rb +226 -0
- data/lib/lldb/type.rb +215 -0
- data/lib/lldb/types.rb +190 -0
- data/lib/lldb/value.rb +334 -0
- data/lib/lldb/value_list.rb +88 -0
- data/lib/lldb/version.rb +7 -0
- data/lib/lldb/watchpoint.rb +145 -0
- data/lib/lldb.rb +64 -0
- data/lldb.gemspec +33 -0
- data/rbs_collection.lock.yaml +220 -0
- data/rbs_collection.yaml +19 -0
- data/sig/lldb/ffi_bindings.rbs +312 -0
- metadata +102 -0
|
@@ -0,0 +1,2051 @@
|
|
|
1
|
+
#include "lldb_wrapper.h"
|
|
2
|
+
#include <lldb/API/LLDB.h>
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <cstring>
|
|
6
|
+
|
|
7
|
+
// LLDB version detection
|
|
8
|
+
// LLDB_VERSION_MAJOR is defined in lldb/lldb-defines.h (part of LLDB.h)
|
|
9
|
+
#ifndef LLDB_VERSION_MAJOR
|
|
10
|
+
#define LLDB_VERSION_MAJOR 0
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
// Thread-local storage for temporary strings
|
|
14
|
+
static thread_local std::string g_temp_string;
|
|
15
|
+
static thread_local std::string g_temp_string2;
|
|
16
|
+
|
|
17
|
+
extern "C" {
|
|
18
|
+
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Initialization
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
void lldb_initialize(void) {
|
|
24
|
+
lldb::SBDebugger::Initialize();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void lldb_terminate(void) {
|
|
28
|
+
lldb::SBDebugger::Terminate();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// SBDebugger
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
lldb_debugger_t lldb_debugger_create(void) {
|
|
36
|
+
lldb::SBDebugger* dbg = new lldb::SBDebugger(lldb::SBDebugger::Create(false));
|
|
37
|
+
return static_cast<lldb_debugger_t>(dbg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void lldb_debugger_destroy(lldb_debugger_t dbg) {
|
|
41
|
+
if (dbg) {
|
|
42
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
43
|
+
if (debugger->IsValid()) {
|
|
44
|
+
lldb::SBDebugger::Destroy(*debugger);
|
|
45
|
+
}
|
|
46
|
+
delete debugger;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
int lldb_debugger_is_valid(lldb_debugger_t dbg) {
|
|
51
|
+
if (!dbg) return 0;
|
|
52
|
+
return static_cast<lldb::SBDebugger*>(dbg)->IsValid() ? 1 : 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
lldb_target_t lldb_debugger_create_target(lldb_debugger_t dbg,
|
|
56
|
+
const char* filename,
|
|
57
|
+
const char* arch,
|
|
58
|
+
const char* platform,
|
|
59
|
+
int add_dependent_modules,
|
|
60
|
+
lldb_error_t error) {
|
|
61
|
+
if (!dbg) return nullptr;
|
|
62
|
+
|
|
63
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
64
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
65
|
+
lldb::SBError local_error;
|
|
66
|
+
|
|
67
|
+
lldb::SBTarget target = debugger->CreateTarget(
|
|
68
|
+
filename,
|
|
69
|
+
arch ? arch : "",
|
|
70
|
+
platform ? platform : "",
|
|
71
|
+
add_dependent_modules != 0,
|
|
72
|
+
err ? *err : local_error
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (!target.IsValid()) return nullptr;
|
|
76
|
+
|
|
77
|
+
return static_cast<lldb_target_t>(new lldb::SBTarget(target));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
lldb_target_t lldb_debugger_create_target_simple(lldb_debugger_t dbg,
|
|
81
|
+
const char* filename) {
|
|
82
|
+
if (!dbg) return nullptr;
|
|
83
|
+
|
|
84
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
85
|
+
lldb::SBTarget target = debugger->CreateTarget(filename);
|
|
86
|
+
|
|
87
|
+
if (!target.IsValid()) return nullptr;
|
|
88
|
+
|
|
89
|
+
return static_cast<lldb_target_t>(new lldb::SBTarget(target));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
uint32_t lldb_debugger_get_num_targets(lldb_debugger_t dbg) {
|
|
93
|
+
if (!dbg) return 0;
|
|
94
|
+
return static_cast<lldb::SBDebugger*>(dbg)->GetNumTargets();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
lldb_target_t lldb_debugger_get_target_at_index(lldb_debugger_t dbg, uint32_t index) {
|
|
98
|
+
if (!dbg) return nullptr;
|
|
99
|
+
|
|
100
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
101
|
+
lldb::SBTarget target = debugger->GetTargetAtIndex(index);
|
|
102
|
+
|
|
103
|
+
if (!target.IsValid()) return nullptr;
|
|
104
|
+
|
|
105
|
+
return static_cast<lldb_target_t>(new lldb::SBTarget(target));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
lldb_target_t lldb_debugger_get_selected_target(lldb_debugger_t dbg) {
|
|
109
|
+
if (!dbg) return nullptr;
|
|
110
|
+
|
|
111
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
112
|
+
lldb::SBTarget target = debugger->GetSelectedTarget();
|
|
113
|
+
|
|
114
|
+
if (!target.IsValid()) return nullptr;
|
|
115
|
+
|
|
116
|
+
return static_cast<lldb_target_t>(new lldb::SBTarget(target));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void lldb_debugger_set_async(lldb_debugger_t dbg, int async) {
|
|
120
|
+
if (!dbg) return;
|
|
121
|
+
static_cast<lldb::SBDebugger*>(dbg)->SetAsync(async != 0);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
int lldb_debugger_get_async(lldb_debugger_t dbg) {
|
|
125
|
+
if (!dbg) return 0;
|
|
126
|
+
return static_cast<lldb::SBDebugger*>(dbg)->GetAsync() ? 1 : 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void lldb_debugger_set_selected_target(lldb_debugger_t dbg, lldb_target_t target) {
|
|
130
|
+
if (!dbg || !target) return;
|
|
131
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
132
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
133
|
+
debugger->SetSelectedTarget(*t);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
int lldb_debugger_delete_target(lldb_debugger_t dbg, lldb_target_t target) {
|
|
137
|
+
if (!dbg || !target) return 0;
|
|
138
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
139
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
140
|
+
return debugger->DeleteTarget(*t) ? 1 : 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
lldb_target_t lldb_debugger_find_target_with_process_id(lldb_debugger_t dbg, uint64_t pid) {
|
|
144
|
+
if (!dbg) return nullptr;
|
|
145
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
146
|
+
lldb::SBTarget target = debugger->FindTargetWithProcessID(pid);
|
|
147
|
+
if (!target.IsValid()) return nullptr;
|
|
148
|
+
return static_cast<lldb_target_t>(new lldb::SBTarget(target));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const char* lldb_debugger_get_version_string(void) {
|
|
152
|
+
return lldb::SBDebugger::GetVersionString();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
lldb_command_interpreter_t lldb_debugger_get_command_interpreter(lldb_debugger_t dbg) {
|
|
156
|
+
if (!dbg) return nullptr;
|
|
157
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
158
|
+
lldb::SBCommandInterpreter interp = debugger->GetCommandInterpreter();
|
|
159
|
+
if (!interp.IsValid()) return nullptr;
|
|
160
|
+
return static_cast<lldb_command_interpreter_t>(new lldb::SBCommandInterpreter(interp));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
void lldb_debugger_handle_command(lldb_debugger_t dbg, const char* command) {
|
|
164
|
+
if (!dbg || !command) return;
|
|
165
|
+
lldb::SBDebugger* debugger = static_cast<lldb::SBDebugger*>(dbg);
|
|
166
|
+
debugger->HandleCommand(command);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ============================================================================
|
|
170
|
+
// SBTarget
|
|
171
|
+
// ============================================================================
|
|
172
|
+
|
|
173
|
+
void lldb_target_destroy(lldb_target_t target) {
|
|
174
|
+
if (target) {
|
|
175
|
+
delete static_cast<lldb::SBTarget*>(target);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
int lldb_target_is_valid(lldb_target_t target) {
|
|
180
|
+
if (!target) return 0;
|
|
181
|
+
return static_cast<lldb::SBTarget*>(target)->IsValid() ? 1 : 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
lldb_process_t lldb_target_launch_simple(lldb_target_t target,
|
|
185
|
+
const char** argv,
|
|
186
|
+
const char** envp,
|
|
187
|
+
const char* working_dir) {
|
|
188
|
+
if (!target) return nullptr;
|
|
189
|
+
|
|
190
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
191
|
+
lldb::SBProcess process = t->LaunchSimple(argv, envp, working_dir);
|
|
192
|
+
|
|
193
|
+
if (!process.IsValid()) return nullptr;
|
|
194
|
+
|
|
195
|
+
return static_cast<lldb_process_t>(new lldb::SBProcess(process));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
lldb_process_t lldb_target_launch(lldb_target_t target,
|
|
199
|
+
lldb_launch_info_t launch_info,
|
|
200
|
+
lldb_error_t error) {
|
|
201
|
+
if (!target || !launch_info) return nullptr;
|
|
202
|
+
|
|
203
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
204
|
+
lldb::SBLaunchInfo* info = static_cast<lldb::SBLaunchInfo*>(launch_info);
|
|
205
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
206
|
+
lldb::SBError local_error;
|
|
207
|
+
|
|
208
|
+
lldb::SBProcess process = t->Launch(*info, err ? *err : local_error);
|
|
209
|
+
|
|
210
|
+
if (!process.IsValid()) return nullptr;
|
|
211
|
+
|
|
212
|
+
return static_cast<lldb_process_t>(new lldb::SBProcess(process));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
lldb_process_t lldb_target_attach_to_process_with_id(lldb_target_t target,
|
|
216
|
+
uint64_t pid,
|
|
217
|
+
lldb_error_t error) {
|
|
218
|
+
if (!target) return nullptr;
|
|
219
|
+
|
|
220
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
221
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
222
|
+
lldb::SBError local_error;
|
|
223
|
+
lldb::SBListener listener;
|
|
224
|
+
|
|
225
|
+
lldb::SBProcess process = t->AttachToProcessWithID(
|
|
226
|
+
listener,
|
|
227
|
+
pid,
|
|
228
|
+
err ? *err : local_error
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
if (!process.IsValid()) return nullptr;
|
|
232
|
+
|
|
233
|
+
return static_cast<lldb_process_t>(new lldb::SBProcess(process));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
lldb_process_t lldb_target_attach_to_process_with_name(lldb_target_t target,
|
|
237
|
+
const char* name,
|
|
238
|
+
int wait_for,
|
|
239
|
+
lldb_error_t error) {
|
|
240
|
+
if (!target || !name) return nullptr;
|
|
241
|
+
|
|
242
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
243
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
244
|
+
lldb::SBError local_error;
|
|
245
|
+
lldb::SBListener listener;
|
|
246
|
+
|
|
247
|
+
lldb::SBProcess process = t->AttachToProcessWithName(
|
|
248
|
+
listener,
|
|
249
|
+
name,
|
|
250
|
+
wait_for != 0,
|
|
251
|
+
err ? *err : local_error
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
if (!process.IsValid()) return nullptr;
|
|
255
|
+
|
|
256
|
+
return static_cast<lldb_process_t>(new lldb::SBProcess(process));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
lldb_breakpoint_t lldb_target_breakpoint_create_by_name(lldb_target_t target,
|
|
260
|
+
const char* symbol_name,
|
|
261
|
+
const char* module_name) {
|
|
262
|
+
if (!target || !symbol_name) return nullptr;
|
|
263
|
+
|
|
264
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
265
|
+
lldb::SBBreakpoint bp = t->BreakpointCreateByName(symbol_name, module_name);
|
|
266
|
+
|
|
267
|
+
if (!bp.IsValid()) return nullptr;
|
|
268
|
+
|
|
269
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
lldb_breakpoint_t lldb_target_breakpoint_create_by_location(lldb_target_t target,
|
|
273
|
+
const char* file,
|
|
274
|
+
uint32_t line) {
|
|
275
|
+
if (!target || !file) return nullptr;
|
|
276
|
+
|
|
277
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
278
|
+
lldb::SBBreakpoint bp = t->BreakpointCreateByLocation(file, line);
|
|
279
|
+
|
|
280
|
+
if (!bp.IsValid()) return nullptr;
|
|
281
|
+
|
|
282
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
lldb_breakpoint_t lldb_target_breakpoint_create_by_address(lldb_target_t target,
|
|
286
|
+
uint64_t address) {
|
|
287
|
+
if (!target) return nullptr;
|
|
288
|
+
|
|
289
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
290
|
+
lldb::SBBreakpoint bp = t->BreakpointCreateByAddress(address);
|
|
291
|
+
|
|
292
|
+
if (!bp.IsValid()) return nullptr;
|
|
293
|
+
|
|
294
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
lldb_breakpoint_t lldb_target_breakpoint_create_by_regex(lldb_target_t target,
|
|
298
|
+
const char* symbol_regex,
|
|
299
|
+
const char* module_name) {
|
|
300
|
+
if (!target || !symbol_regex) return nullptr;
|
|
301
|
+
|
|
302
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
303
|
+
lldb::SBBreakpoint bp = t->BreakpointCreateByRegex(symbol_regex, module_name);
|
|
304
|
+
|
|
305
|
+
if (!bp.IsValid()) return nullptr;
|
|
306
|
+
|
|
307
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
lldb_breakpoint_t lldb_target_breakpoint_create_by_source_regex(lldb_target_t target,
|
|
311
|
+
const char* source_regex,
|
|
312
|
+
const char* source_file) {
|
|
313
|
+
if (!target || !source_regex) return nullptr;
|
|
314
|
+
|
|
315
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
316
|
+
lldb::SBFileSpecList module_list;
|
|
317
|
+
lldb::SBFileSpecList source_list;
|
|
318
|
+
if (source_file) {
|
|
319
|
+
source_list.Append(lldb::SBFileSpec(source_file));
|
|
320
|
+
}
|
|
321
|
+
lldb::SBBreakpoint bp = t->BreakpointCreateBySourceRegex(source_regex, module_list, source_list);
|
|
322
|
+
|
|
323
|
+
if (!bp.IsValid()) return nullptr;
|
|
324
|
+
|
|
325
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
int lldb_target_delete_breakpoint(lldb_target_t target, int32_t breakpoint_id) {
|
|
329
|
+
if (!target) return 0;
|
|
330
|
+
return static_cast<lldb::SBTarget*>(target)->BreakpointDelete(breakpoint_id) ? 1 : 0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
int lldb_target_delete_all_breakpoints(lldb_target_t target) {
|
|
334
|
+
if (!target) return 0;
|
|
335
|
+
return static_cast<lldb::SBTarget*>(target)->DeleteAllBreakpoints() ? 1 : 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
int lldb_target_enable_all_breakpoints(lldb_target_t target) {
|
|
339
|
+
if (!target) return 0;
|
|
340
|
+
return static_cast<lldb::SBTarget*>(target)->EnableAllBreakpoints() ? 1 : 0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
int lldb_target_disable_all_breakpoints(lldb_target_t target) {
|
|
344
|
+
if (!target) return 0;
|
|
345
|
+
return static_cast<lldb::SBTarget*>(target)->DisableAllBreakpoints() ? 1 : 0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
lldb_breakpoint_t lldb_target_find_breakpoint_by_id(lldb_target_t target, int32_t id) {
|
|
349
|
+
if (!target) return nullptr;
|
|
350
|
+
|
|
351
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
352
|
+
lldb::SBBreakpoint bp = t->FindBreakpointByID(id);
|
|
353
|
+
|
|
354
|
+
if (!bp.IsValid()) return nullptr;
|
|
355
|
+
|
|
356
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
uint32_t lldb_target_get_num_breakpoints(lldb_target_t target) {
|
|
360
|
+
if (!target) return 0;
|
|
361
|
+
return static_cast<lldb::SBTarget*>(target)->GetNumBreakpoints();
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
lldb_breakpoint_t lldb_target_get_breakpoint_at_index(lldb_target_t target, uint32_t index) {
|
|
365
|
+
if (!target) return nullptr;
|
|
366
|
+
|
|
367
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
368
|
+
lldb::SBBreakpoint bp = t->GetBreakpointAtIndex(index);
|
|
369
|
+
|
|
370
|
+
if (!bp.IsValid()) return nullptr;
|
|
371
|
+
|
|
372
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
lldb_process_t lldb_target_get_process(lldb_target_t target) {
|
|
376
|
+
if (!target) return nullptr;
|
|
377
|
+
|
|
378
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
379
|
+
lldb::SBProcess process = t->GetProcess();
|
|
380
|
+
|
|
381
|
+
if (!process.IsValid()) return nullptr;
|
|
382
|
+
|
|
383
|
+
return static_cast<lldb_process_t>(new lldb::SBProcess(process));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const char* lldb_target_get_executable_path(lldb_target_t target) {
|
|
387
|
+
if (!target) return nullptr;
|
|
388
|
+
|
|
389
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
390
|
+
lldb::SBFileSpec spec = t->GetExecutable();
|
|
391
|
+
|
|
392
|
+
if (!spec.IsValid()) return nullptr;
|
|
393
|
+
|
|
394
|
+
char path[4096];
|
|
395
|
+
if (spec.GetPath(path, sizeof(path)) > 0) {
|
|
396
|
+
g_temp_string = path;
|
|
397
|
+
return g_temp_string.c_str();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return nullptr;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
uint32_t lldb_target_get_num_modules(lldb_target_t target) {
|
|
404
|
+
if (!target) return 0;
|
|
405
|
+
return static_cast<lldb::SBTarget*>(target)->GetNumModules();
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
lldb_module_t lldb_target_get_module_at_index(lldb_target_t target, uint32_t index) {
|
|
409
|
+
if (!target) return nullptr;
|
|
410
|
+
|
|
411
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
412
|
+
lldb::SBModule module = t->GetModuleAtIndex(index);
|
|
413
|
+
|
|
414
|
+
if (!module.IsValid()) return nullptr;
|
|
415
|
+
|
|
416
|
+
return static_cast<lldb_module_t>(new lldb::SBModule(module));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
lldb_value_t lldb_target_evaluate_expression(lldb_target_t target, const char* expr) {
|
|
420
|
+
if (!target || !expr) return nullptr;
|
|
421
|
+
|
|
422
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
423
|
+
lldb::SBValue value = t->EvaluateExpression(expr);
|
|
424
|
+
|
|
425
|
+
if (!value.IsValid()) return nullptr;
|
|
426
|
+
|
|
427
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(value));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
size_t lldb_target_read_memory(lldb_target_t target, uint64_t addr, void* buf, size_t size, lldb_error_t error) {
|
|
431
|
+
if (!target || !buf) return 0;
|
|
432
|
+
|
|
433
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
434
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
435
|
+
lldb::SBError local_error;
|
|
436
|
+
lldb::SBAddress sb_addr(addr, *t);
|
|
437
|
+
|
|
438
|
+
return t->ReadMemory(sb_addr, buf, size, err ? *err : local_error);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
uint32_t lldb_target_get_address_byte_size(lldb_target_t target) {
|
|
442
|
+
if (!target) return 0;
|
|
443
|
+
return static_cast<lldb::SBTarget*>(target)->GetAddressByteSize();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const char* lldb_target_get_triple(lldb_target_t target) {
|
|
447
|
+
if (!target) return nullptr;
|
|
448
|
+
return static_cast<lldb::SBTarget*>(target)->GetTriple();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
lldb_watchpoint_t lldb_target_watch_address(lldb_target_t target, uint64_t addr, size_t size, int read, int write, lldb_error_t error) {
|
|
452
|
+
if (!target) return nullptr;
|
|
453
|
+
|
|
454
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
455
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
456
|
+
lldb::SBError local_error;
|
|
457
|
+
|
|
458
|
+
lldb::SBWatchpoint wp = t->WatchAddress(addr, size, read != 0, write != 0, err ? *err : local_error);
|
|
459
|
+
|
|
460
|
+
if (!wp.IsValid()) return nullptr;
|
|
461
|
+
|
|
462
|
+
return static_cast<lldb_watchpoint_t>(new lldb::SBWatchpoint(wp));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
int lldb_target_delete_watchpoint(lldb_target_t target, int32_t watchpoint_id) {
|
|
466
|
+
if (!target) return 0;
|
|
467
|
+
return static_cast<lldb::SBTarget*>(target)->DeleteWatchpoint(watchpoint_id) ? 1 : 0;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
int lldb_target_delete_all_watchpoints(lldb_target_t target) {
|
|
471
|
+
if (!target) return 0;
|
|
472
|
+
return static_cast<lldb::SBTarget*>(target)->DeleteAllWatchpoints() ? 1 : 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
lldb_watchpoint_t lldb_target_find_watchpoint_by_id(lldb_target_t target, int32_t id) {
|
|
476
|
+
if (!target) return nullptr;
|
|
477
|
+
|
|
478
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
479
|
+
lldb::SBWatchpoint wp = t->FindWatchpointByID(id);
|
|
480
|
+
|
|
481
|
+
if (!wp.IsValid()) return nullptr;
|
|
482
|
+
|
|
483
|
+
return static_cast<lldb_watchpoint_t>(new lldb::SBWatchpoint(wp));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
uint32_t lldb_target_get_num_watchpoints(lldb_target_t target) {
|
|
487
|
+
if (!target) return 0;
|
|
488
|
+
return static_cast<lldb::SBTarget*>(target)->GetNumWatchpoints();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
lldb_watchpoint_t lldb_target_get_watchpoint_at_index(lldb_target_t target, uint32_t index) {
|
|
492
|
+
if (!target) return nullptr;
|
|
493
|
+
|
|
494
|
+
lldb::SBTarget* t = static_cast<lldb::SBTarget*>(target);
|
|
495
|
+
lldb::SBWatchpoint wp = t->GetWatchpointAtIndex(index);
|
|
496
|
+
|
|
497
|
+
if (!wp.IsValid()) return nullptr;
|
|
498
|
+
|
|
499
|
+
return static_cast<lldb_watchpoint_t>(new lldb::SBWatchpoint(wp));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// ============================================================================
|
|
503
|
+
// SBLaunchInfo
|
|
504
|
+
// ============================================================================
|
|
505
|
+
|
|
506
|
+
lldb_launch_info_t lldb_launch_info_create(const char** argv) {
|
|
507
|
+
return static_cast<lldb_launch_info_t>(new lldb::SBLaunchInfo(argv));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
void lldb_launch_info_destroy(lldb_launch_info_t info) {
|
|
511
|
+
if (info) {
|
|
512
|
+
delete static_cast<lldb::SBLaunchInfo*>(info);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
void lldb_launch_info_set_working_directory(lldb_launch_info_t info, const char* dir) {
|
|
517
|
+
if (!info) return;
|
|
518
|
+
static_cast<lldb::SBLaunchInfo*>(info)->SetWorkingDirectory(dir);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
void lldb_launch_info_set_environment_entries(lldb_launch_info_t info,
|
|
522
|
+
const char** envp,
|
|
523
|
+
int append) {
|
|
524
|
+
if (!info) return;
|
|
525
|
+
lldb::SBEnvironment env;
|
|
526
|
+
if (envp) {
|
|
527
|
+
for (const char** e = envp; *e != nullptr; ++e) {
|
|
528
|
+
std::string entry(*e);
|
|
529
|
+
size_t pos = entry.find('=');
|
|
530
|
+
if (pos != std::string::npos) {
|
|
531
|
+
env.Set(entry.substr(0, pos).c_str(),
|
|
532
|
+
entry.substr(pos + 1).c_str(),
|
|
533
|
+
true);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
static_cast<lldb::SBLaunchInfo*>(info)->SetEnvironment(env, append != 0);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
uint32_t lldb_launch_info_get_launch_flags(lldb_launch_info_t info) {
|
|
541
|
+
if (!info) return 0;
|
|
542
|
+
return static_cast<lldb::SBLaunchInfo*>(info)->GetLaunchFlags();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
void lldb_launch_info_set_launch_flags(lldb_launch_info_t info, uint32_t flags) {
|
|
546
|
+
if (!info) return;
|
|
547
|
+
static_cast<lldb::SBLaunchInfo*>(info)->SetLaunchFlags(flags);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// ============================================================================
|
|
551
|
+
// SBProcess
|
|
552
|
+
// ============================================================================
|
|
553
|
+
|
|
554
|
+
void lldb_process_destroy(lldb_process_t process) {
|
|
555
|
+
if (process) {
|
|
556
|
+
delete static_cast<lldb::SBProcess*>(process);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
int lldb_process_is_valid(lldb_process_t process) {
|
|
561
|
+
if (!process) return 0;
|
|
562
|
+
return static_cast<lldb::SBProcess*>(process)->IsValid() ? 1 : 0;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
int lldb_process_continue(lldb_process_t process) {
|
|
566
|
+
if (!process) return 0;
|
|
567
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->Continue();
|
|
568
|
+
return error.Success() ? 1 : 0;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
int lldb_process_stop(lldb_process_t process) {
|
|
572
|
+
if (!process) return 0;
|
|
573
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->Stop();
|
|
574
|
+
return error.Success() ? 1 : 0;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
int lldb_process_kill(lldb_process_t process) {
|
|
578
|
+
if (!process) return 0;
|
|
579
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->Kill();
|
|
580
|
+
return error.Success() ? 1 : 0;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
int lldb_process_detach(lldb_process_t process) {
|
|
584
|
+
if (!process) return 0;
|
|
585
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->Detach();
|
|
586
|
+
return error.Success() ? 1 : 0;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
int lldb_process_destroy_process(lldb_process_t process) {
|
|
590
|
+
if (!process) return 0;
|
|
591
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->Destroy();
|
|
592
|
+
return error.Success() ? 1 : 0;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
int lldb_process_signal(lldb_process_t process, int signal) {
|
|
596
|
+
if (!process) return 0;
|
|
597
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->Signal(signal);
|
|
598
|
+
return error.Success() ? 1 : 0;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
int lldb_process_get_state(lldb_process_t process) {
|
|
602
|
+
if (!process) return LLDB_STATE_INVALID;
|
|
603
|
+
return static_cast<int>(static_cast<lldb::SBProcess*>(process)->GetState());
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
uint32_t lldb_process_get_num_threads(lldb_process_t process) {
|
|
607
|
+
if (!process) return 0;
|
|
608
|
+
return static_cast<lldb::SBProcess*>(process)->GetNumThreads();
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
lldb_thread_t lldb_process_get_thread_at_index(lldb_process_t process, uint32_t index) {
|
|
612
|
+
if (!process) return nullptr;
|
|
613
|
+
|
|
614
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
615
|
+
lldb::SBThread thread = p->GetThreadAtIndex(index);
|
|
616
|
+
|
|
617
|
+
if (!thread.IsValid()) return nullptr;
|
|
618
|
+
|
|
619
|
+
return static_cast<lldb_thread_t>(new lldb::SBThread(thread));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
lldb_thread_t lldb_process_get_thread_by_id(lldb_process_t process, uint64_t tid) {
|
|
623
|
+
if (!process) return nullptr;
|
|
624
|
+
|
|
625
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
626
|
+
lldb::SBThread thread = p->GetThreadByID(tid);
|
|
627
|
+
|
|
628
|
+
if (!thread.IsValid()) return nullptr;
|
|
629
|
+
|
|
630
|
+
return static_cast<lldb_thread_t>(new lldb::SBThread(thread));
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
lldb_thread_t lldb_process_get_thread_by_index_id(lldb_process_t process, uint32_t index_id) {
|
|
634
|
+
if (!process) return nullptr;
|
|
635
|
+
|
|
636
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
637
|
+
lldb::SBThread thread = p->GetThreadByIndexID(index_id);
|
|
638
|
+
|
|
639
|
+
if (!thread.IsValid()) return nullptr;
|
|
640
|
+
|
|
641
|
+
return static_cast<lldb_thread_t>(new lldb::SBThread(thread));
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
lldb_thread_t lldb_process_get_selected_thread(lldb_process_t process) {
|
|
645
|
+
if (!process) return nullptr;
|
|
646
|
+
|
|
647
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
648
|
+
lldb::SBThread thread = p->GetSelectedThread();
|
|
649
|
+
|
|
650
|
+
if (!thread.IsValid()) return nullptr;
|
|
651
|
+
|
|
652
|
+
return static_cast<lldb_thread_t>(new lldb::SBThread(thread));
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
int lldb_process_set_selected_thread_by_id(lldb_process_t process, uint64_t tid) {
|
|
656
|
+
if (!process) return 0;
|
|
657
|
+
return static_cast<lldb::SBProcess*>(process)->SetSelectedThreadByID(tid) ? 1 : 0;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
int lldb_process_set_selected_thread_by_index_id(lldb_process_t process, uint32_t index_id) {
|
|
661
|
+
if (!process) return 0;
|
|
662
|
+
return static_cast<lldb::SBProcess*>(process)->SetSelectedThreadByIndexID(index_id) ? 1 : 0;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
uint64_t lldb_process_get_process_id(lldb_process_t process) {
|
|
666
|
+
if (!process) return 0;
|
|
667
|
+
return static_cast<lldb::SBProcess*>(process)->GetProcessID();
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
int lldb_process_get_exit_status(lldb_process_t process) {
|
|
671
|
+
if (!process) return -1;
|
|
672
|
+
return static_cast<lldb::SBProcess*>(process)->GetExitStatus();
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const char* lldb_process_get_exit_description(lldb_process_t process) {
|
|
676
|
+
if (!process) return nullptr;
|
|
677
|
+
return static_cast<lldb::SBProcess*>(process)->GetExitDescription();
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
size_t lldb_process_read_memory(lldb_process_t process, uint64_t addr, void* buf, size_t size, lldb_error_t error) {
|
|
681
|
+
if (!process || !buf) return 0;
|
|
682
|
+
|
|
683
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
684
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
685
|
+
lldb::SBError local_error;
|
|
686
|
+
|
|
687
|
+
return p->ReadMemory(addr, buf, size, err ? *err : local_error);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
size_t lldb_process_write_memory(lldb_process_t process, uint64_t addr, const void* buf, size_t size, lldb_error_t error) {
|
|
691
|
+
if (!process || !buf) return 0;
|
|
692
|
+
|
|
693
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
694
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
695
|
+
lldb::SBError local_error;
|
|
696
|
+
|
|
697
|
+
return p->WriteMemory(addr, buf, size, err ? *err : local_error);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
uint64_t lldb_process_allocate_memory(lldb_process_t process, size_t size, uint32_t permissions, lldb_error_t error) {
|
|
701
|
+
if (!process) return LLDB_INVALID_ADDRESS;
|
|
702
|
+
|
|
703
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
704
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
705
|
+
lldb::SBError local_error;
|
|
706
|
+
|
|
707
|
+
return p->AllocateMemory(size, permissions, err ? *err : local_error);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
int lldb_process_deallocate_memory(lldb_process_t process, uint64_t addr) {
|
|
711
|
+
if (!process) return 0;
|
|
712
|
+
lldb::SBError error = static_cast<lldb::SBProcess*>(process)->DeallocateMemory(addr);
|
|
713
|
+
return error.Success() ? 1 : 0;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
size_t lldb_process_read_cstring_from_memory(lldb_process_t process, uint64_t addr, void* buf, size_t size, lldb_error_t error) {
|
|
717
|
+
if (!process || !buf) return 0;
|
|
718
|
+
|
|
719
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
720
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
721
|
+
lldb::SBError local_error;
|
|
722
|
+
|
|
723
|
+
return p->ReadCStringFromMemory(addr, buf, size, err ? *err : local_error);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
size_t lldb_process_get_stdout(lldb_process_t process, char* buf, size_t size) {
|
|
727
|
+
if (!process || !buf) return 0;
|
|
728
|
+
return static_cast<lldb::SBProcess*>(process)->GetSTDOUT(buf, size);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
size_t lldb_process_get_stderr(lldb_process_t process, char* buf, size_t size) {
|
|
732
|
+
if (!process || !buf) return 0;
|
|
733
|
+
return static_cast<lldb::SBProcess*>(process)->GetSTDERR(buf, size);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
size_t lldb_process_put_stdin(lldb_process_t process, const char* buf, size_t size) {
|
|
737
|
+
if (!process || !buf) return 0;
|
|
738
|
+
return static_cast<lldb::SBProcess*>(process)->PutSTDIN(buf, size);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
int lldb_process_send_async_interrupt(lldb_process_t process) {
|
|
742
|
+
if (!process) return 0;
|
|
743
|
+
static_cast<lldb::SBProcess*>(process)->SendAsyncInterrupt();
|
|
744
|
+
return 1;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
uint32_t lldb_process_get_num_supported_hardware_watchpoints(lldb_process_t process, lldb_error_t error) {
|
|
748
|
+
if (!process) return 0;
|
|
749
|
+
|
|
750
|
+
lldb::SBProcess* p = static_cast<lldb::SBProcess*>(process);
|
|
751
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
752
|
+
lldb::SBError local_error;
|
|
753
|
+
|
|
754
|
+
return p->GetNumSupportedHardwareWatchpoints(err ? *err : local_error);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
uint32_t lldb_process_get_unique_id(lldb_process_t process) {
|
|
758
|
+
if (!process) return 0;
|
|
759
|
+
return static_cast<lldb::SBProcess*>(process)->GetUniqueID();
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// ============================================================================
|
|
763
|
+
// SBThread
|
|
764
|
+
// ============================================================================
|
|
765
|
+
|
|
766
|
+
void lldb_thread_destroy(lldb_thread_t thread) {
|
|
767
|
+
if (thread) {
|
|
768
|
+
delete static_cast<lldb::SBThread*>(thread);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
int lldb_thread_is_valid(lldb_thread_t thread) {
|
|
773
|
+
if (!thread) return 0;
|
|
774
|
+
return static_cast<lldb::SBThread*>(thread)->IsValid() ? 1 : 0;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
int lldb_thread_step_over(lldb_thread_t thread) {
|
|
778
|
+
if (!thread) return 0;
|
|
779
|
+
static_cast<lldb::SBThread*>(thread)->StepOver();
|
|
780
|
+
return 1;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
int lldb_thread_step_into(lldb_thread_t thread) {
|
|
784
|
+
if (!thread) return 0;
|
|
785
|
+
static_cast<lldb::SBThread*>(thread)->StepInto();
|
|
786
|
+
return 1;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
int lldb_thread_step_out(lldb_thread_t thread) {
|
|
790
|
+
if (!thread) return 0;
|
|
791
|
+
static_cast<lldb::SBThread*>(thread)->StepOut();
|
|
792
|
+
return 1;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
int lldb_thread_step_instruction(lldb_thread_t thread, int step_over) {
|
|
796
|
+
if (!thread) return 0;
|
|
797
|
+
static_cast<lldb::SBThread*>(thread)->StepInstruction(step_over != 0);
|
|
798
|
+
return 1;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
int lldb_thread_run_to_address(lldb_thread_t thread, uint64_t addr) {
|
|
802
|
+
if (!thread) return 0;
|
|
803
|
+
static_cast<lldb::SBThread*>(thread)->RunToAddress(addr);
|
|
804
|
+
return 1;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
uint32_t lldb_thread_get_num_frames(lldb_thread_t thread) {
|
|
808
|
+
if (!thread) return 0;
|
|
809
|
+
return static_cast<lldb::SBThread*>(thread)->GetNumFrames();
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
lldb_frame_t lldb_thread_get_frame_at_index(lldb_thread_t thread, uint32_t index) {
|
|
813
|
+
if (!thread) return nullptr;
|
|
814
|
+
|
|
815
|
+
lldb::SBThread* t = static_cast<lldb::SBThread*>(thread);
|
|
816
|
+
lldb::SBFrame frame = t->GetFrameAtIndex(index);
|
|
817
|
+
|
|
818
|
+
if (!frame.IsValid()) return nullptr;
|
|
819
|
+
|
|
820
|
+
return static_cast<lldb_frame_t>(new lldb::SBFrame(frame));
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
lldb_frame_t lldb_thread_get_selected_frame(lldb_thread_t thread) {
|
|
824
|
+
if (!thread) return nullptr;
|
|
825
|
+
|
|
826
|
+
lldb::SBThread* t = static_cast<lldb::SBThread*>(thread);
|
|
827
|
+
lldb::SBFrame frame = t->GetSelectedFrame();
|
|
828
|
+
|
|
829
|
+
if (!frame.IsValid()) return nullptr;
|
|
830
|
+
|
|
831
|
+
return static_cast<lldb_frame_t>(new lldb::SBFrame(frame));
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
int lldb_thread_set_selected_frame(lldb_thread_t thread, uint32_t index) {
|
|
835
|
+
if (!thread) return 0;
|
|
836
|
+
lldb::SBFrame frame = static_cast<lldb::SBThread*>(thread)->SetSelectedFrame(index);
|
|
837
|
+
return frame.IsValid() ? 1 : 0;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
uint64_t lldb_thread_get_thread_id(lldb_thread_t thread) {
|
|
841
|
+
if (!thread) return 0;
|
|
842
|
+
return static_cast<lldb::SBThread*>(thread)->GetThreadID();
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
uint32_t lldb_thread_get_index_id(lldb_thread_t thread) {
|
|
846
|
+
if (!thread) return 0;
|
|
847
|
+
return static_cast<lldb::SBThread*>(thread)->GetIndexID();
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
const char* lldb_thread_get_name(lldb_thread_t thread) {
|
|
851
|
+
if (!thread) return nullptr;
|
|
852
|
+
return static_cast<lldb::SBThread*>(thread)->GetName();
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
const char* lldb_thread_get_queue_name(lldb_thread_t thread) {
|
|
856
|
+
if (!thread) return nullptr;
|
|
857
|
+
return static_cast<lldb::SBThread*>(thread)->GetQueueName();
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
int lldb_thread_get_stop_reason(lldb_thread_t thread) {
|
|
861
|
+
if (!thread) return LLDB_STOP_REASON_INVALID;
|
|
862
|
+
return static_cast<int>(static_cast<lldb::SBThread*>(thread)->GetStopReason());
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const char* lldb_thread_get_stop_description(lldb_thread_t thread, size_t max_size) {
|
|
866
|
+
if (!thread) return nullptr;
|
|
867
|
+
|
|
868
|
+
static thread_local std::string stop_desc;
|
|
869
|
+
stop_desc.resize(max_size);
|
|
870
|
+
size_t len = static_cast<lldb::SBThread*>(thread)->GetStopDescription(&stop_desc[0], max_size);
|
|
871
|
+
stop_desc.resize(len);
|
|
872
|
+
return stop_desc.c_str();
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
uint64_t lldb_thread_get_stop_reason_data_count(lldb_thread_t thread) {
|
|
876
|
+
if (!thread) return 0;
|
|
877
|
+
return static_cast<lldb::SBThread*>(thread)->GetStopReasonDataCount();
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
uint64_t lldb_thread_get_stop_reason_data_at_index(lldb_thread_t thread, uint32_t index) {
|
|
881
|
+
if (!thread) return 0;
|
|
882
|
+
return static_cast<lldb::SBThread*>(thread)->GetStopReasonDataAtIndex(index);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
int lldb_thread_is_stopped(lldb_thread_t thread) {
|
|
886
|
+
if (!thread) return 0;
|
|
887
|
+
return static_cast<lldb::SBThread*>(thread)->IsStopped() ? 1 : 0;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
int lldb_thread_is_suspended(lldb_thread_t thread) {
|
|
891
|
+
if (!thread) return 0;
|
|
892
|
+
return static_cast<lldb::SBThread*>(thread)->IsSuspended() ? 1 : 0;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
int lldb_thread_suspend(lldb_thread_t thread) {
|
|
896
|
+
if (!thread) return 0;
|
|
897
|
+
return static_cast<lldb::SBThread*>(thread)->Suspend() ? 1 : 0;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
int lldb_thread_resume(lldb_thread_t thread) {
|
|
901
|
+
if (!thread) return 0;
|
|
902
|
+
return static_cast<lldb::SBThread*>(thread)->Resume() ? 1 : 0;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
lldb_process_t lldb_thread_get_process(lldb_thread_t thread) {
|
|
906
|
+
if (!thread) return nullptr;
|
|
907
|
+
|
|
908
|
+
lldb::SBThread* t = static_cast<lldb::SBThread*>(thread);
|
|
909
|
+
lldb::SBProcess process = t->GetProcess();
|
|
910
|
+
|
|
911
|
+
if (!process.IsValid()) return nullptr;
|
|
912
|
+
|
|
913
|
+
return static_cast<lldb_process_t>(new lldb::SBProcess(process));
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// ============================================================================
|
|
917
|
+
// SBFrame
|
|
918
|
+
// ============================================================================
|
|
919
|
+
|
|
920
|
+
void lldb_frame_destroy(lldb_frame_t frame) {
|
|
921
|
+
if (frame) {
|
|
922
|
+
delete static_cast<lldb::SBFrame*>(frame);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
int lldb_frame_is_valid(lldb_frame_t frame) {
|
|
927
|
+
if (!frame) return 0;
|
|
928
|
+
return static_cast<lldb::SBFrame*>(frame)->IsValid() ? 1 : 0;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
const char* lldb_frame_get_function_name(lldb_frame_t frame) {
|
|
932
|
+
if (!frame) return nullptr;
|
|
933
|
+
return static_cast<lldb::SBFrame*>(frame)->GetFunctionName();
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
const char* lldb_frame_get_display_function_name(lldb_frame_t frame) {
|
|
937
|
+
if (!frame) return nullptr;
|
|
938
|
+
return static_cast<lldb::SBFrame*>(frame)->GetDisplayFunctionName();
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
uint32_t lldb_frame_get_line(lldb_frame_t frame) {
|
|
942
|
+
if (!frame) return 0;
|
|
943
|
+
lldb::SBLineEntry line_entry = static_cast<lldb::SBFrame*>(frame)->GetLineEntry();
|
|
944
|
+
return line_entry.GetLine();
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
const char* lldb_frame_get_file_path(lldb_frame_t frame) {
|
|
948
|
+
if (!frame) return nullptr;
|
|
949
|
+
|
|
950
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
951
|
+
lldb::SBLineEntry line_entry = f->GetLineEntry();
|
|
952
|
+
lldb::SBFileSpec file_spec = line_entry.GetFileSpec();
|
|
953
|
+
|
|
954
|
+
if (!file_spec.IsValid()) return nullptr;
|
|
955
|
+
|
|
956
|
+
char path[4096];
|
|
957
|
+
if (file_spec.GetPath(path, sizeof(path)) > 0) {
|
|
958
|
+
g_temp_string = path;
|
|
959
|
+
return g_temp_string.c_str();
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
return nullptr;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
uint32_t lldb_frame_get_column(lldb_frame_t frame) {
|
|
966
|
+
if (!frame) return 0;
|
|
967
|
+
lldb::SBLineEntry line_entry = static_cast<lldb::SBFrame*>(frame)->GetLineEntry();
|
|
968
|
+
return line_entry.GetColumn();
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
uint64_t lldb_frame_get_pc(lldb_frame_t frame) {
|
|
972
|
+
if (!frame) return 0;
|
|
973
|
+
return static_cast<lldb::SBFrame*>(frame)->GetPC();
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
int lldb_frame_set_pc(lldb_frame_t frame, uint64_t new_pc) {
|
|
977
|
+
if (!frame) return 0;
|
|
978
|
+
return static_cast<lldb::SBFrame*>(frame)->SetPC(new_pc) ? 1 : 0;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
uint64_t lldb_frame_get_sp(lldb_frame_t frame) {
|
|
982
|
+
if (!frame) return 0;
|
|
983
|
+
return static_cast<lldb::SBFrame*>(frame)->GetSP();
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
uint64_t lldb_frame_get_fp(lldb_frame_t frame) {
|
|
987
|
+
if (!frame) return 0;
|
|
988
|
+
return static_cast<lldb::SBFrame*>(frame)->GetFP();
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
lldb_value_t lldb_frame_find_variable(lldb_frame_t frame, const char* name) {
|
|
992
|
+
if (!frame || !name) return nullptr;
|
|
993
|
+
|
|
994
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
995
|
+
lldb::SBValue value = f->FindVariable(name);
|
|
996
|
+
|
|
997
|
+
if (!value.IsValid()) return nullptr;
|
|
998
|
+
|
|
999
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(value));
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
lldb_value_t lldb_frame_evaluate_expression(lldb_frame_t frame, const char* expr) {
|
|
1003
|
+
if (!frame || !expr) return nullptr;
|
|
1004
|
+
|
|
1005
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1006
|
+
lldb::SBValue value = f->EvaluateExpression(expr);
|
|
1007
|
+
|
|
1008
|
+
if (!value.IsValid()) return nullptr;
|
|
1009
|
+
|
|
1010
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(value));
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
lldb_value_t lldb_frame_get_value_for_variable_path(lldb_frame_t frame, const char* path) {
|
|
1014
|
+
if (!frame || !path) return nullptr;
|
|
1015
|
+
|
|
1016
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1017
|
+
lldb::SBValue value = f->GetValueForVariablePath(path);
|
|
1018
|
+
|
|
1019
|
+
if (!value.IsValid()) return nullptr;
|
|
1020
|
+
|
|
1021
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(value));
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
uint32_t lldb_frame_get_frame_id(lldb_frame_t frame) {
|
|
1025
|
+
if (!frame) return 0;
|
|
1026
|
+
return static_cast<lldb::SBFrame*>(frame)->GetFrameID();
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
lldb_thread_t lldb_frame_get_thread(lldb_frame_t frame) {
|
|
1030
|
+
if (!frame) return nullptr;
|
|
1031
|
+
|
|
1032
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1033
|
+
lldb::SBThread thread = f->GetThread();
|
|
1034
|
+
|
|
1035
|
+
if (!thread.IsValid()) return nullptr;
|
|
1036
|
+
|
|
1037
|
+
return static_cast<lldb_thread_t>(new lldb::SBThread(thread));
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
lldb_symbol_context_t lldb_frame_get_symbol_context(lldb_frame_t frame, uint32_t scope) {
|
|
1041
|
+
if (!frame) return nullptr;
|
|
1042
|
+
|
|
1043
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1044
|
+
lldb::SBSymbolContext ctx = f->GetSymbolContext(scope);
|
|
1045
|
+
|
|
1046
|
+
return static_cast<lldb_symbol_context_t>(new lldb::SBSymbolContext(ctx));
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
lldb_value_list_t lldb_frame_get_variables(lldb_frame_t frame, int arguments, int locals, int statics, int in_scope_only) {
|
|
1050
|
+
if (!frame) return nullptr;
|
|
1051
|
+
|
|
1052
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1053
|
+
lldb::SBValueList list = f->GetVariables(arguments != 0, locals != 0, statics != 0, in_scope_only != 0);
|
|
1054
|
+
|
|
1055
|
+
return static_cast<lldb_value_list_t>(new lldb::SBValueList(list));
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
lldb_value_list_t lldb_frame_get_registers(lldb_frame_t frame) {
|
|
1059
|
+
if (!frame) return nullptr;
|
|
1060
|
+
|
|
1061
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1062
|
+
lldb::SBValueList list = f->GetRegisters();
|
|
1063
|
+
|
|
1064
|
+
return static_cast<lldb_value_list_t>(new lldb::SBValueList(list));
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
int lldb_frame_is_inlined(lldb_frame_t frame) {
|
|
1068
|
+
if (!frame) return 0;
|
|
1069
|
+
return static_cast<lldb::SBFrame*>(frame)->IsInlined() ? 1 : 0;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
const char* lldb_frame_disassemble(lldb_frame_t frame) {
|
|
1073
|
+
if (!frame) return nullptr;
|
|
1074
|
+
return static_cast<lldb::SBFrame*>(frame)->Disassemble();
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
lldb_module_t lldb_frame_get_module(lldb_frame_t frame) {
|
|
1078
|
+
if (!frame) return nullptr;
|
|
1079
|
+
|
|
1080
|
+
lldb::SBFrame* f = static_cast<lldb::SBFrame*>(frame);
|
|
1081
|
+
lldb::SBModule module = f->GetModule();
|
|
1082
|
+
|
|
1083
|
+
if (!module.IsValid()) return nullptr;
|
|
1084
|
+
|
|
1085
|
+
return static_cast<lldb_module_t>(new lldb::SBModule(module));
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// ============================================================================
|
|
1089
|
+
// SBBreakpoint
|
|
1090
|
+
// ============================================================================
|
|
1091
|
+
|
|
1092
|
+
void lldb_breakpoint_destroy(lldb_breakpoint_t bp) {
|
|
1093
|
+
if (bp) {
|
|
1094
|
+
delete static_cast<lldb::SBBreakpoint*>(bp);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
int lldb_breakpoint_is_valid(lldb_breakpoint_t bp) {
|
|
1099
|
+
if (!bp) return 0;
|
|
1100
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->IsValid() ? 1 : 0;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
int32_t lldb_breakpoint_get_id(lldb_breakpoint_t bp) {
|
|
1104
|
+
if (!bp) return -1;
|
|
1105
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetID();
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
int lldb_breakpoint_is_enabled(lldb_breakpoint_t bp) {
|
|
1109
|
+
if (!bp) return 0;
|
|
1110
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->IsEnabled() ? 1 : 0;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
void lldb_breakpoint_set_enabled(lldb_breakpoint_t bp, int enabled) {
|
|
1114
|
+
if (!bp) return;
|
|
1115
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetEnabled(enabled != 0);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
int lldb_breakpoint_is_one_shot(lldb_breakpoint_t bp) {
|
|
1119
|
+
if (!bp) return 0;
|
|
1120
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->IsOneShot() ? 1 : 0;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
void lldb_breakpoint_set_one_shot(lldb_breakpoint_t bp, int one_shot) {
|
|
1124
|
+
if (!bp) return;
|
|
1125
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetOneShot(one_shot != 0);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
uint32_t lldb_breakpoint_get_hit_count(lldb_breakpoint_t bp) {
|
|
1129
|
+
if (!bp) return 0;
|
|
1130
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetHitCount();
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
uint32_t lldb_breakpoint_get_ignore_count(lldb_breakpoint_t bp) {
|
|
1134
|
+
if (!bp) return 0;
|
|
1135
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetIgnoreCount();
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
void lldb_breakpoint_set_ignore_count(lldb_breakpoint_t bp, uint32_t count) {
|
|
1139
|
+
if (!bp) return;
|
|
1140
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetIgnoreCount(count);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
const char* lldb_breakpoint_get_condition(lldb_breakpoint_t bp) {
|
|
1144
|
+
if (!bp) return nullptr;
|
|
1145
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetCondition();
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
void lldb_breakpoint_set_condition(lldb_breakpoint_t bp, const char* condition) {
|
|
1149
|
+
if (!bp) return;
|
|
1150
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetCondition(condition);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
uint32_t lldb_breakpoint_get_num_locations(lldb_breakpoint_t bp) {
|
|
1154
|
+
if (!bp) return 0;
|
|
1155
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetNumLocations();
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
lldb_breakpoint_location_t lldb_breakpoint_get_location_at_index(lldb_breakpoint_t bp, uint32_t index) {
|
|
1159
|
+
if (!bp) return nullptr;
|
|
1160
|
+
|
|
1161
|
+
lldb::SBBreakpoint* b = static_cast<lldb::SBBreakpoint*>(bp);
|
|
1162
|
+
lldb::SBBreakpointLocation loc = b->GetLocationAtIndex(index);
|
|
1163
|
+
|
|
1164
|
+
if (!loc.IsValid()) return nullptr;
|
|
1165
|
+
|
|
1166
|
+
return static_cast<lldb_breakpoint_location_t>(new lldb::SBBreakpointLocation(loc));
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
lldb_breakpoint_location_t lldb_breakpoint_find_location_by_id(lldb_breakpoint_t bp, int32_t id) {
|
|
1170
|
+
if (!bp) return nullptr;
|
|
1171
|
+
|
|
1172
|
+
lldb::SBBreakpoint* b = static_cast<lldb::SBBreakpoint*>(bp);
|
|
1173
|
+
lldb::SBBreakpointLocation loc = b->FindLocationByID(id);
|
|
1174
|
+
|
|
1175
|
+
if (!loc.IsValid()) return nullptr;
|
|
1176
|
+
|
|
1177
|
+
return static_cast<lldb_breakpoint_location_t>(new lldb::SBBreakpointLocation(loc));
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
int lldb_breakpoint_is_hardware(lldb_breakpoint_t bp) {
|
|
1181
|
+
if (!bp) return 0;
|
|
1182
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->IsHardware() ? 1 : 0;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
int lldb_breakpoint_get_auto_continue(lldb_breakpoint_t bp) {
|
|
1186
|
+
if (!bp) return 0;
|
|
1187
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetAutoContinue() ? 1 : 0;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
void lldb_breakpoint_set_auto_continue(lldb_breakpoint_t bp, int auto_continue) {
|
|
1191
|
+
if (!bp) return;
|
|
1192
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetAutoContinue(auto_continue != 0);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
uint64_t lldb_breakpoint_get_thread_id(lldb_breakpoint_t bp) {
|
|
1196
|
+
if (!bp) return 0;
|
|
1197
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetThreadID();
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
void lldb_breakpoint_set_thread_id(lldb_breakpoint_t bp, uint64_t tid) {
|
|
1201
|
+
if (!bp) return;
|
|
1202
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetThreadID(tid);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
const char* lldb_breakpoint_get_thread_name(lldb_breakpoint_t bp) {
|
|
1206
|
+
if (!bp) return nullptr;
|
|
1207
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetThreadName();
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
void lldb_breakpoint_set_thread_name(lldb_breakpoint_t bp, const char* name) {
|
|
1211
|
+
if (!bp) return;
|
|
1212
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetThreadName(name);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
uint32_t lldb_breakpoint_get_thread_index(lldb_breakpoint_t bp) {
|
|
1216
|
+
if (!bp) return 0;
|
|
1217
|
+
return static_cast<lldb::SBBreakpoint*>(bp)->GetThreadIndex();
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
void lldb_breakpoint_set_thread_index(lldb_breakpoint_t bp, uint32_t index) {
|
|
1221
|
+
if (!bp) return;
|
|
1222
|
+
static_cast<lldb::SBBreakpoint*>(bp)->SetThreadIndex(index);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// ============================================================================
|
|
1226
|
+
// SBBreakpointLocation
|
|
1227
|
+
// ============================================================================
|
|
1228
|
+
|
|
1229
|
+
void lldb_breakpoint_location_destroy(lldb_breakpoint_location_t loc) {
|
|
1230
|
+
if (loc) {
|
|
1231
|
+
delete static_cast<lldb::SBBreakpointLocation*>(loc);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
int lldb_breakpoint_location_is_valid(lldb_breakpoint_location_t loc) {
|
|
1236
|
+
if (!loc) return 0;
|
|
1237
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->IsValid() ? 1 : 0;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
int32_t lldb_breakpoint_location_get_id(lldb_breakpoint_location_t loc) {
|
|
1241
|
+
if (!loc) return -1;
|
|
1242
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->GetID();
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
uint64_t lldb_breakpoint_location_get_load_address(lldb_breakpoint_location_t loc) {
|
|
1246
|
+
if (!loc) return LLDB_INVALID_ADDRESS;
|
|
1247
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->GetLoadAddress();
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
int lldb_breakpoint_location_is_enabled(lldb_breakpoint_location_t loc) {
|
|
1251
|
+
if (!loc) return 0;
|
|
1252
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->IsEnabled() ? 1 : 0;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
void lldb_breakpoint_location_set_enabled(lldb_breakpoint_location_t loc, int enabled) {
|
|
1256
|
+
if (!loc) return;
|
|
1257
|
+
static_cast<lldb::SBBreakpointLocation*>(loc)->SetEnabled(enabled != 0);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
uint32_t lldb_breakpoint_location_get_hit_count(lldb_breakpoint_location_t loc) {
|
|
1261
|
+
if (!loc) return 0;
|
|
1262
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->GetHitCount();
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
uint32_t lldb_breakpoint_location_get_ignore_count(lldb_breakpoint_location_t loc) {
|
|
1266
|
+
if (!loc) return 0;
|
|
1267
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->GetIgnoreCount();
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
void lldb_breakpoint_location_set_ignore_count(lldb_breakpoint_location_t loc, uint32_t count) {
|
|
1271
|
+
if (!loc) return;
|
|
1272
|
+
static_cast<lldb::SBBreakpointLocation*>(loc)->SetIgnoreCount(count);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const char* lldb_breakpoint_location_get_condition(lldb_breakpoint_location_t loc) {
|
|
1276
|
+
if (!loc) return nullptr;
|
|
1277
|
+
return static_cast<lldb::SBBreakpointLocation*>(loc)->GetCondition();
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
void lldb_breakpoint_location_set_condition(lldb_breakpoint_location_t loc, const char* condition) {
|
|
1281
|
+
if (!loc) return;
|
|
1282
|
+
static_cast<lldb::SBBreakpointLocation*>(loc)->SetCondition(condition);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
lldb_breakpoint_t lldb_breakpoint_location_get_breakpoint(lldb_breakpoint_location_t loc) {
|
|
1286
|
+
if (!loc) return nullptr;
|
|
1287
|
+
|
|
1288
|
+
lldb::SBBreakpointLocation* l = static_cast<lldb::SBBreakpointLocation*>(loc);
|
|
1289
|
+
lldb::SBBreakpoint bp = l->GetBreakpoint();
|
|
1290
|
+
|
|
1291
|
+
if (!bp.IsValid()) return nullptr;
|
|
1292
|
+
|
|
1293
|
+
return static_cast<lldb_breakpoint_t>(new lldb::SBBreakpoint(bp));
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
// ============================================================================
|
|
1297
|
+
// SBValue
|
|
1298
|
+
// ============================================================================
|
|
1299
|
+
|
|
1300
|
+
void lldb_value_destroy(lldb_value_t value) {
|
|
1301
|
+
if (value) {
|
|
1302
|
+
delete static_cast<lldb::SBValue*>(value);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
int lldb_value_is_valid(lldb_value_t value) {
|
|
1307
|
+
if (!value) return 0;
|
|
1308
|
+
return static_cast<lldb::SBValue*>(value)->IsValid() ? 1 : 0;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
const char* lldb_value_get_name(lldb_value_t value) {
|
|
1312
|
+
if (!value) return nullptr;
|
|
1313
|
+
return static_cast<lldb::SBValue*>(value)->GetName();
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
const char* lldb_value_get_value(lldb_value_t value) {
|
|
1317
|
+
if (!value) return nullptr;
|
|
1318
|
+
return static_cast<lldb::SBValue*>(value)->GetValue();
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
const char* lldb_value_get_summary(lldb_value_t value) {
|
|
1322
|
+
if (!value) return nullptr;
|
|
1323
|
+
return static_cast<lldb::SBValue*>(value)->GetSummary();
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
const char* lldb_value_get_type_name(lldb_value_t value) {
|
|
1327
|
+
if (!value) return nullptr;
|
|
1328
|
+
return static_cast<lldb::SBValue*>(value)->GetTypeName();
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
lldb_type_t lldb_value_get_type(lldb_value_t value) {
|
|
1332
|
+
if (!value) return nullptr;
|
|
1333
|
+
|
|
1334
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1335
|
+
lldb::SBType type = v->GetType();
|
|
1336
|
+
|
|
1337
|
+
if (!type.IsValid()) return nullptr;
|
|
1338
|
+
|
|
1339
|
+
return static_cast<lldb_type_t>(new lldb::SBType(type));
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
uint32_t lldb_value_get_num_children(lldb_value_t value) {
|
|
1343
|
+
if (!value) return 0;
|
|
1344
|
+
return static_cast<lldb::SBValue*>(value)->GetNumChildren();
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
lldb_value_t lldb_value_get_child_at_index(lldb_value_t value, uint32_t index) {
|
|
1348
|
+
if (!value) return nullptr;
|
|
1349
|
+
|
|
1350
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1351
|
+
lldb::SBValue child = v->GetChildAtIndex(index);
|
|
1352
|
+
|
|
1353
|
+
if (!child.IsValid()) return nullptr;
|
|
1354
|
+
|
|
1355
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(child));
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
lldb_value_t lldb_value_get_child_member_with_name(lldb_value_t value, const char* name) {
|
|
1359
|
+
if (!value || !name) return nullptr;
|
|
1360
|
+
|
|
1361
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1362
|
+
lldb::SBValue child = v->GetChildMemberWithName(name);
|
|
1363
|
+
|
|
1364
|
+
if (!child.IsValid()) return nullptr;
|
|
1365
|
+
|
|
1366
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(child));
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
int64_t lldb_value_get_value_as_signed(lldb_value_t value) {
|
|
1370
|
+
if (!value) return 0;
|
|
1371
|
+
return static_cast<lldb::SBValue*>(value)->GetValueAsSigned();
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
uint64_t lldb_value_get_value_as_unsigned(lldb_value_t value) {
|
|
1375
|
+
if (!value) return 0;
|
|
1376
|
+
return static_cast<lldb::SBValue*>(value)->GetValueAsUnsigned();
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
uint64_t lldb_value_get_byte_size(lldb_value_t value) {
|
|
1380
|
+
if (!value) return 0;
|
|
1381
|
+
return static_cast<lldb::SBValue*>(value)->GetByteSize();
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
int lldb_value_might_have_children(lldb_value_t value) {
|
|
1385
|
+
if (!value) return 0;
|
|
1386
|
+
return static_cast<lldb::SBValue*>(value)->MightHaveChildren() ? 1 : 0;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
int lldb_value_get_error(lldb_value_t value, lldb_error_t error) {
|
|
1390
|
+
if (!value) return 0;
|
|
1391
|
+
lldb::SBError err = static_cast<lldb::SBValue*>(value)->GetError();
|
|
1392
|
+
if (error) {
|
|
1393
|
+
*static_cast<lldb::SBError*>(error) = err;
|
|
1394
|
+
}
|
|
1395
|
+
return err.Fail() ? 0 : 1;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
lldb_value_t lldb_value_dereference(lldb_value_t value) {
|
|
1399
|
+
if (!value) return nullptr;
|
|
1400
|
+
|
|
1401
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1402
|
+
lldb::SBValue deref = v->Dereference();
|
|
1403
|
+
|
|
1404
|
+
if (!deref.IsValid()) return nullptr;
|
|
1405
|
+
|
|
1406
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(deref));
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
lldb_value_t lldb_value_address_of(lldb_value_t value) {
|
|
1410
|
+
if (!value) return nullptr;
|
|
1411
|
+
|
|
1412
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1413
|
+
lldb::SBValue addr = v->AddressOf();
|
|
1414
|
+
|
|
1415
|
+
if (!addr.IsValid()) return nullptr;
|
|
1416
|
+
|
|
1417
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(addr));
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
lldb_value_t lldb_value_cast(lldb_value_t value, lldb_type_t type) {
|
|
1421
|
+
if (!value || !type) return nullptr;
|
|
1422
|
+
|
|
1423
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1424
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1425
|
+
lldb::SBValue casted = v->Cast(*t);
|
|
1426
|
+
|
|
1427
|
+
if (!casted.IsValid()) return nullptr;
|
|
1428
|
+
|
|
1429
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(casted));
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
uint64_t lldb_value_get_load_address(lldb_value_t value) {
|
|
1433
|
+
if (!value) return LLDB_INVALID_ADDRESS;
|
|
1434
|
+
return static_cast<lldb::SBValue*>(value)->GetLoadAddress();
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
int lldb_value_get_value_type(lldb_value_t value) {
|
|
1438
|
+
if (!value) return LLDB_VALUE_TYPE_INVALID;
|
|
1439
|
+
return static_cast<int>(static_cast<lldb::SBValue*>(value)->GetValueType());
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
int lldb_value_set_value_from_cstring(lldb_value_t value, const char* str, lldb_error_t error) {
|
|
1443
|
+
if (!value || !str) return 0;
|
|
1444
|
+
|
|
1445
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1446
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
1447
|
+
lldb::SBError local_error;
|
|
1448
|
+
|
|
1449
|
+
return v->SetValueFromCString(str, err ? *err : local_error) ? 1 : 0;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
lldb_value_t lldb_value_create_child_at_offset(lldb_value_t value, const char* name, lldb_type_t type, uint32_t offset) {
|
|
1453
|
+
if (!value || !type) return nullptr;
|
|
1454
|
+
|
|
1455
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1456
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1457
|
+
lldb::SBValue child = v->CreateChildAtOffset(name, offset, *t);
|
|
1458
|
+
|
|
1459
|
+
if (!child.IsValid()) return nullptr;
|
|
1460
|
+
|
|
1461
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(child));
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
lldb_value_t lldb_value_create_value_from_address(lldb_value_t value, const char* name, uint64_t addr, lldb_type_t type) {
|
|
1465
|
+
if (!value || !type) return nullptr;
|
|
1466
|
+
|
|
1467
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1468
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1469
|
+
lldb::SBValue created = v->CreateValueFromAddress(name, addr, *t);
|
|
1470
|
+
|
|
1471
|
+
if (!created.IsValid()) return nullptr;
|
|
1472
|
+
|
|
1473
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(created));
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
lldb_value_t lldb_value_create_value_from_expression(lldb_value_t value, const char* name, const char* expr) {
|
|
1477
|
+
if (!value || !name || !expr) return nullptr;
|
|
1478
|
+
|
|
1479
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1480
|
+
lldb::SBValue created = v->CreateValueFromExpression(name, expr);
|
|
1481
|
+
|
|
1482
|
+
if (!created.IsValid()) return nullptr;
|
|
1483
|
+
|
|
1484
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(created));
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
lldb_watchpoint_t lldb_value_watch(lldb_value_t value, int resolve_location, int read, int write, lldb_error_t error) {
|
|
1488
|
+
if (!value) return nullptr;
|
|
1489
|
+
|
|
1490
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1491
|
+
lldb::SBError* err = error ? static_cast<lldb::SBError*>(error) : nullptr;
|
|
1492
|
+
lldb::SBError local_error;
|
|
1493
|
+
|
|
1494
|
+
lldb::SBWatchpoint wp = v->Watch(resolve_location != 0, read != 0, write != 0, err ? *err : local_error);
|
|
1495
|
+
|
|
1496
|
+
if (!wp.IsValid()) return nullptr;
|
|
1497
|
+
|
|
1498
|
+
return static_cast<lldb_watchpoint_t>(new lldb::SBWatchpoint(wp));
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
const char* lldb_value_get_expression_path(lldb_value_t value) {
|
|
1502
|
+
if (!value) return nullptr;
|
|
1503
|
+
|
|
1504
|
+
static thread_local std::string expr_path;
|
|
1505
|
+
lldb::SBStream stream;
|
|
1506
|
+
static_cast<lldb::SBValue*>(value)->GetExpressionPath(stream);
|
|
1507
|
+
expr_path = stream.GetData();
|
|
1508
|
+
return expr_path.c_str();
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
int lldb_value_is_pointer_type(lldb_value_t value) {
|
|
1512
|
+
if (!value) return 0;
|
|
1513
|
+
return static_cast<lldb::SBValue*>(value)->TypeIsPointerType() ? 1 : 0;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
lldb_value_t lldb_value_get_non_synthetic_value(lldb_value_t value) {
|
|
1517
|
+
if (!value) return nullptr;
|
|
1518
|
+
|
|
1519
|
+
lldb::SBValue* v = static_cast<lldb::SBValue*>(value);
|
|
1520
|
+
lldb::SBValue non_synth = v->GetNonSyntheticValue();
|
|
1521
|
+
|
|
1522
|
+
if (!non_synth.IsValid()) return nullptr;
|
|
1523
|
+
|
|
1524
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(non_synth));
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// ============================================================================
|
|
1528
|
+
// SBValueList
|
|
1529
|
+
// ============================================================================
|
|
1530
|
+
|
|
1531
|
+
void lldb_value_list_destroy(lldb_value_list_t list) {
|
|
1532
|
+
if (list) {
|
|
1533
|
+
delete static_cast<lldb::SBValueList*>(list);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
int lldb_value_list_is_valid(lldb_value_list_t list) {
|
|
1538
|
+
if (!list) return 0;
|
|
1539
|
+
return static_cast<lldb::SBValueList*>(list)->IsValid() ? 1 : 0;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
uint32_t lldb_value_list_get_size(lldb_value_list_t list) {
|
|
1543
|
+
if (!list) return 0;
|
|
1544
|
+
return static_cast<lldb::SBValueList*>(list)->GetSize();
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
lldb_value_t lldb_value_list_get_value_at_index(lldb_value_list_t list, uint32_t index) {
|
|
1548
|
+
if (!list) return nullptr;
|
|
1549
|
+
|
|
1550
|
+
lldb::SBValueList* l = static_cast<lldb::SBValueList*>(list);
|
|
1551
|
+
lldb::SBValue value = l->GetValueAtIndex(index);
|
|
1552
|
+
|
|
1553
|
+
if (!value.IsValid()) return nullptr;
|
|
1554
|
+
|
|
1555
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(value));
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
lldb_value_t lldb_value_list_get_first_value_by_name(lldb_value_list_t list, const char* name) {
|
|
1559
|
+
if (!list || !name) return nullptr;
|
|
1560
|
+
|
|
1561
|
+
lldb::SBValueList* l = static_cast<lldb::SBValueList*>(list);
|
|
1562
|
+
lldb::SBValue value = l->GetFirstValueByName(name);
|
|
1563
|
+
|
|
1564
|
+
if (!value.IsValid()) return nullptr;
|
|
1565
|
+
|
|
1566
|
+
return static_cast<lldb_value_t>(new lldb::SBValue(value));
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// ============================================================================
|
|
1570
|
+
// SBError
|
|
1571
|
+
// ============================================================================
|
|
1572
|
+
|
|
1573
|
+
lldb_error_t lldb_error_create(void) {
|
|
1574
|
+
return static_cast<lldb_error_t>(new lldb::SBError());
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
void lldb_error_destroy(lldb_error_t error) {
|
|
1578
|
+
if (error) {
|
|
1579
|
+
delete static_cast<lldb::SBError*>(error);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
int lldb_error_success(lldb_error_t error) {
|
|
1584
|
+
if (!error) return 0;
|
|
1585
|
+
return static_cast<lldb::SBError*>(error)->Success() ? 1 : 0;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
int lldb_error_fail(lldb_error_t error) {
|
|
1589
|
+
if (!error) return 1;
|
|
1590
|
+
return static_cast<lldb::SBError*>(error)->Fail() ? 1 : 0;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
const char* lldb_error_get_cstring(lldb_error_t error) {
|
|
1594
|
+
if (!error) return nullptr;
|
|
1595
|
+
return static_cast<lldb::SBError*>(error)->GetCString();
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
uint32_t lldb_error_get_error(lldb_error_t error) {
|
|
1599
|
+
if (!error) return 0;
|
|
1600
|
+
return static_cast<lldb::SBError*>(error)->GetError();
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
void lldb_error_clear(lldb_error_t error) {
|
|
1604
|
+
if (!error) return;
|
|
1605
|
+
static_cast<lldb::SBError*>(error)->Clear();
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
void lldb_error_set_error_string(lldb_error_t error, const char* str) {
|
|
1609
|
+
if (!error) return;
|
|
1610
|
+
static_cast<lldb::SBError*>(error)->SetErrorString(str);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
// ============================================================================
|
|
1614
|
+
// SBModule
|
|
1615
|
+
// ============================================================================
|
|
1616
|
+
|
|
1617
|
+
void lldb_module_destroy(lldb_module_t module) {
|
|
1618
|
+
if (module) {
|
|
1619
|
+
delete static_cast<lldb::SBModule*>(module);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
int lldb_module_is_valid(lldb_module_t module) {
|
|
1624
|
+
if (!module) return 0;
|
|
1625
|
+
return static_cast<lldb::SBModule*>(module)->IsValid() ? 1 : 0;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
const char* lldb_module_get_file_path(lldb_module_t module) {
|
|
1629
|
+
if (!module) return nullptr;
|
|
1630
|
+
|
|
1631
|
+
lldb::SBModule* m = static_cast<lldb::SBModule*>(module);
|
|
1632
|
+
lldb::SBFileSpec spec = m->GetFileSpec();
|
|
1633
|
+
|
|
1634
|
+
if (!spec.IsValid()) return nullptr;
|
|
1635
|
+
|
|
1636
|
+
char path[4096];
|
|
1637
|
+
if (spec.GetPath(path, sizeof(path)) > 0) {
|
|
1638
|
+
g_temp_string = path;
|
|
1639
|
+
return g_temp_string.c_str();
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
return nullptr;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
const char* lldb_module_get_platform_file_path(lldb_module_t module) {
|
|
1646
|
+
if (!module) return nullptr;
|
|
1647
|
+
|
|
1648
|
+
lldb::SBModule* m = static_cast<lldb::SBModule*>(module);
|
|
1649
|
+
lldb::SBFileSpec spec = m->GetPlatformFileSpec();
|
|
1650
|
+
|
|
1651
|
+
if (!spec.IsValid()) return nullptr;
|
|
1652
|
+
|
|
1653
|
+
char path[4096];
|
|
1654
|
+
if (spec.GetPath(path, sizeof(path)) > 0) {
|
|
1655
|
+
g_temp_string2 = path;
|
|
1656
|
+
return g_temp_string2.c_str();
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
return nullptr;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
uint32_t lldb_module_get_num_symbols(lldb_module_t module) {
|
|
1663
|
+
if (!module) return 0;
|
|
1664
|
+
return static_cast<lldb::SBModule*>(module)->GetNumSymbols();
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
// ============================================================================
|
|
1668
|
+
// SBSymbolContext
|
|
1669
|
+
// ============================================================================
|
|
1670
|
+
|
|
1671
|
+
void lldb_symbol_context_destroy(lldb_symbol_context_t ctx) {
|
|
1672
|
+
if (ctx) {
|
|
1673
|
+
delete static_cast<lldb::SBSymbolContext*>(ctx);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
int lldb_symbol_context_is_valid(lldb_symbol_context_t ctx) {
|
|
1678
|
+
if (!ctx) return 0;
|
|
1679
|
+
lldb::SBSymbolContext* c = static_cast<lldb::SBSymbolContext*>(ctx);
|
|
1680
|
+
return (c->GetModule().IsValid() || c->GetFunction().IsValid()) ? 1 : 0;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
lldb_module_t lldb_symbol_context_get_module(lldb_symbol_context_t ctx) {
|
|
1684
|
+
if (!ctx) return nullptr;
|
|
1685
|
+
|
|
1686
|
+
lldb::SBSymbolContext* c = static_cast<lldb::SBSymbolContext*>(ctx);
|
|
1687
|
+
lldb::SBModule module = c->GetModule();
|
|
1688
|
+
|
|
1689
|
+
if (!module.IsValid()) return nullptr;
|
|
1690
|
+
|
|
1691
|
+
return static_cast<lldb_module_t>(new lldb::SBModule(module));
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
const char* lldb_symbol_context_get_function_name(lldb_symbol_context_t ctx) {
|
|
1695
|
+
if (!ctx) return nullptr;
|
|
1696
|
+
|
|
1697
|
+
lldb::SBSymbolContext* c = static_cast<lldb::SBSymbolContext*>(ctx);
|
|
1698
|
+
lldb::SBFunction func = c->GetFunction();
|
|
1699
|
+
|
|
1700
|
+
if (func.IsValid()) {
|
|
1701
|
+
return func.GetName();
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
lldb::SBSymbol sym = c->GetSymbol();
|
|
1705
|
+
if (sym.IsValid()) {
|
|
1706
|
+
return sym.GetName();
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
return nullptr;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
// ============================================================================
|
|
1713
|
+
// SBType
|
|
1714
|
+
// ============================================================================
|
|
1715
|
+
|
|
1716
|
+
void lldb_type_destroy(lldb_type_t type) {
|
|
1717
|
+
if (type) {
|
|
1718
|
+
delete static_cast<lldb::SBType*>(type);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
int lldb_type_is_valid(lldb_type_t type) {
|
|
1723
|
+
if (!type) return 0;
|
|
1724
|
+
return static_cast<lldb::SBType*>(type)->IsValid() ? 1 : 0;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
const char* lldb_type_get_name(lldb_type_t type) {
|
|
1728
|
+
if (!type) return nullptr;
|
|
1729
|
+
return static_cast<lldb::SBType*>(type)->GetName();
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
const char* lldb_type_get_display_type_name(lldb_type_t type) {
|
|
1733
|
+
if (!type) return nullptr;
|
|
1734
|
+
return static_cast<lldb::SBType*>(type)->GetDisplayTypeName();
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
uint64_t lldb_type_get_byte_size(lldb_type_t type) {
|
|
1738
|
+
if (!type) return 0;
|
|
1739
|
+
return static_cast<lldb::SBType*>(type)->GetByteSize();
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
int lldb_type_is_pointer_type(lldb_type_t type) {
|
|
1743
|
+
if (!type) return 0;
|
|
1744
|
+
return static_cast<lldb::SBType*>(type)->IsPointerType() ? 1 : 0;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
int lldb_type_is_reference_type(lldb_type_t type) {
|
|
1748
|
+
if (!type) return 0;
|
|
1749
|
+
return static_cast<lldb::SBType*>(type)->IsReferenceType() ? 1 : 0;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
int lldb_type_is_array_type(lldb_type_t type) {
|
|
1753
|
+
if (!type) return 0;
|
|
1754
|
+
return static_cast<lldb::SBType*>(type)->IsArrayType() ? 1 : 0;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
int lldb_type_is_vector_type(lldb_type_t type) {
|
|
1758
|
+
if (!type) return 0;
|
|
1759
|
+
return static_cast<lldb::SBType*>(type)->IsVectorType() ? 1 : 0;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
int lldb_type_is_typedef_type(lldb_type_t type) {
|
|
1763
|
+
if (!type) return 0;
|
|
1764
|
+
return static_cast<lldb::SBType*>(type)->IsTypedefType() ? 1 : 0;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
int lldb_type_is_function_type(lldb_type_t type) {
|
|
1768
|
+
if (!type) return 0;
|
|
1769
|
+
return static_cast<lldb::SBType*>(type)->IsFunctionType() ? 1 : 0;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
int lldb_type_is_polymorphic_class(lldb_type_t type) {
|
|
1773
|
+
if (!type) return 0;
|
|
1774
|
+
return static_cast<lldb::SBType*>(type)->IsPolymorphicClass() ? 1 : 0;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
lldb_type_t lldb_type_get_pointer_type(lldb_type_t type) {
|
|
1778
|
+
if (!type) return nullptr;
|
|
1779
|
+
|
|
1780
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1781
|
+
lldb::SBType ptr = t->GetPointerType();
|
|
1782
|
+
|
|
1783
|
+
if (!ptr.IsValid()) return nullptr;
|
|
1784
|
+
|
|
1785
|
+
return static_cast<lldb_type_t>(new lldb::SBType(ptr));
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
lldb_type_t lldb_type_get_pointee_type(lldb_type_t type) {
|
|
1789
|
+
if (!type) return nullptr;
|
|
1790
|
+
|
|
1791
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1792
|
+
lldb::SBType pointee = t->GetPointeeType();
|
|
1793
|
+
|
|
1794
|
+
if (!pointee.IsValid()) return nullptr;
|
|
1795
|
+
|
|
1796
|
+
return static_cast<lldb_type_t>(new lldb::SBType(pointee));
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
lldb_type_t lldb_type_get_reference_type(lldb_type_t type) {
|
|
1800
|
+
if (!type) return nullptr;
|
|
1801
|
+
|
|
1802
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1803
|
+
lldb::SBType ref = t->GetReferenceType();
|
|
1804
|
+
|
|
1805
|
+
if (!ref.IsValid()) return nullptr;
|
|
1806
|
+
|
|
1807
|
+
return static_cast<lldb_type_t>(new lldb::SBType(ref));
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
lldb_type_t lldb_type_get_dereferenced_type(lldb_type_t type) {
|
|
1811
|
+
if (!type) return nullptr;
|
|
1812
|
+
|
|
1813
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1814
|
+
lldb::SBType deref = t->GetDereferencedType();
|
|
1815
|
+
|
|
1816
|
+
if (!deref.IsValid()) return nullptr;
|
|
1817
|
+
|
|
1818
|
+
return static_cast<lldb_type_t>(new lldb::SBType(deref));
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
lldb_type_t lldb_type_get_unqualified_type(lldb_type_t type) {
|
|
1822
|
+
if (!type) return nullptr;
|
|
1823
|
+
|
|
1824
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1825
|
+
lldb::SBType unqual = t->GetUnqualifiedType();
|
|
1826
|
+
|
|
1827
|
+
if (!unqual.IsValid()) return nullptr;
|
|
1828
|
+
|
|
1829
|
+
return static_cast<lldb_type_t>(new lldb::SBType(unqual));
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
lldb_type_t lldb_type_get_canonical_type(lldb_type_t type) {
|
|
1833
|
+
if (!type) return nullptr;
|
|
1834
|
+
|
|
1835
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1836
|
+
lldb::SBType canon = t->GetCanonicalType();
|
|
1837
|
+
|
|
1838
|
+
if (!canon.IsValid()) return nullptr;
|
|
1839
|
+
|
|
1840
|
+
return static_cast<lldb_type_t>(new lldb::SBType(canon));
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
lldb_type_t lldb_type_get_array_element_type(lldb_type_t type) {
|
|
1844
|
+
if (!type) return nullptr;
|
|
1845
|
+
|
|
1846
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1847
|
+
lldb::SBType elem = t->GetArrayElementType();
|
|
1848
|
+
|
|
1849
|
+
if (!elem.IsValid()) return nullptr;
|
|
1850
|
+
|
|
1851
|
+
return static_cast<lldb_type_t>(new lldb::SBType(elem));
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
uint64_t lldb_type_get_array_size(lldb_type_t type) {
|
|
1855
|
+
if (!type) return 0;
|
|
1856
|
+
lldb::SBType* t = static_cast<lldb::SBType*>(type);
|
|
1857
|
+
// GetArraySize may not be available in older LLDB versions
|
|
1858
|
+
// Use byte_size / element_type_byte_size as a fallback
|
|
1859
|
+
if (!t->IsArrayType()) return 0;
|
|
1860
|
+
lldb::SBType elem = t->GetArrayElementType();
|
|
1861
|
+
if (!elem.IsValid() || elem.GetByteSize() == 0) return 0;
|
|
1862
|
+
return t->GetByteSize() / elem.GetByteSize();
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
uint32_t lldb_type_get_num_fields(lldb_type_t type) {
|
|
1866
|
+
if (!type) return 0;
|
|
1867
|
+
return static_cast<lldb::SBType*>(type)->GetNumberOfFields();
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
uint32_t lldb_type_get_num_direct_base_classes(lldb_type_t type) {
|
|
1871
|
+
if (!type) return 0;
|
|
1872
|
+
return static_cast<lldb::SBType*>(type)->GetNumberOfDirectBaseClasses();
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
uint32_t lldb_type_get_num_virtual_base_classes(lldb_type_t type) {
|
|
1876
|
+
if (!type) return 0;
|
|
1877
|
+
return static_cast<lldb::SBType*>(type)->GetNumberOfVirtualBaseClasses();
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
int lldb_type_get_basic_type(lldb_type_t type) {
|
|
1881
|
+
if (!type) return LLDB_BASIC_TYPE_INVALID;
|
|
1882
|
+
return static_cast<int>(static_cast<lldb::SBType*>(type)->GetBasicType());
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// ============================================================================
|
|
1886
|
+
// SBWatchpoint
|
|
1887
|
+
// ============================================================================
|
|
1888
|
+
|
|
1889
|
+
void lldb_watchpoint_destroy(lldb_watchpoint_t wp) {
|
|
1890
|
+
if (wp) {
|
|
1891
|
+
delete static_cast<lldb::SBWatchpoint*>(wp);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
int lldb_watchpoint_is_valid(lldb_watchpoint_t wp) {
|
|
1896
|
+
if (!wp) return 0;
|
|
1897
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->IsValid() ? 1 : 0;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
int32_t lldb_watchpoint_get_id(lldb_watchpoint_t wp) {
|
|
1901
|
+
if (!wp) return -1;
|
|
1902
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->GetID();
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
int lldb_watchpoint_is_enabled(lldb_watchpoint_t wp) {
|
|
1906
|
+
if (!wp) return 0;
|
|
1907
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->IsEnabled() ? 1 : 0;
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
void lldb_watchpoint_set_enabled(lldb_watchpoint_t wp, int enabled) {
|
|
1911
|
+
if (!wp) return;
|
|
1912
|
+
static_cast<lldb::SBWatchpoint*>(wp)->SetEnabled(enabled != 0);
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
uint32_t lldb_watchpoint_get_hit_count(lldb_watchpoint_t wp) {
|
|
1916
|
+
if (!wp) return 0;
|
|
1917
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->GetHitCount();
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
uint32_t lldb_watchpoint_get_ignore_count(lldb_watchpoint_t wp) {
|
|
1921
|
+
if (!wp) return 0;
|
|
1922
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->GetIgnoreCount();
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
void lldb_watchpoint_set_ignore_count(lldb_watchpoint_t wp, uint32_t count) {
|
|
1926
|
+
if (!wp) return;
|
|
1927
|
+
static_cast<lldb::SBWatchpoint*>(wp)->SetIgnoreCount(count);
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
const char* lldb_watchpoint_get_condition(lldb_watchpoint_t wp) {
|
|
1931
|
+
if (!wp) return nullptr;
|
|
1932
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->GetCondition();
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
void lldb_watchpoint_set_condition(lldb_watchpoint_t wp, const char* condition) {
|
|
1936
|
+
if (!wp) return;
|
|
1937
|
+
static_cast<lldb::SBWatchpoint*>(wp)->SetCondition(condition);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
uint64_t lldb_watchpoint_get_watch_address(lldb_watchpoint_t wp) {
|
|
1941
|
+
if (!wp) return 0;
|
|
1942
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->GetWatchAddress();
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
size_t lldb_watchpoint_get_watch_size(lldb_watchpoint_t wp) {
|
|
1946
|
+
if (!wp) return 0;
|
|
1947
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->GetWatchSize();
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
int lldb_watchpoint_is_watching_reads(lldb_watchpoint_t wp) {
|
|
1951
|
+
if (!wp) return 0;
|
|
1952
|
+
#if LLDB_VERSION_MAJOR >= 15
|
|
1953
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->IsWatchingReads() ? 1 : 0;
|
|
1954
|
+
#else
|
|
1955
|
+
// IsWatchingReads() not available in LLDB < 15
|
|
1956
|
+
// Return -1 to indicate the method is not available
|
|
1957
|
+
return -1;
|
|
1958
|
+
#endif
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
int lldb_watchpoint_is_watching_writes(lldb_watchpoint_t wp) {
|
|
1962
|
+
if (!wp) return 0;
|
|
1963
|
+
#if LLDB_VERSION_MAJOR >= 15
|
|
1964
|
+
return static_cast<lldb::SBWatchpoint*>(wp)->IsWatchingWrites() ? 1 : 0;
|
|
1965
|
+
#else
|
|
1966
|
+
// IsWatchingWrites() not available in LLDB < 15
|
|
1967
|
+
// Return -1 to indicate the method is not available
|
|
1968
|
+
return -1;
|
|
1969
|
+
#endif
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// ============================================================================
|
|
1973
|
+
// SBCommandInterpreter
|
|
1974
|
+
// ============================================================================
|
|
1975
|
+
|
|
1976
|
+
void lldb_command_interpreter_destroy(lldb_command_interpreter_t interp) {
|
|
1977
|
+
if (interp) {
|
|
1978
|
+
delete static_cast<lldb::SBCommandInterpreter*>(interp);
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
int lldb_command_interpreter_is_valid(lldb_command_interpreter_t interp) {
|
|
1983
|
+
if (!interp) return 0;
|
|
1984
|
+
return static_cast<lldb::SBCommandInterpreter*>(interp)->IsValid() ? 1 : 0;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
int lldb_command_interpreter_handle_command(lldb_command_interpreter_t interp,
|
|
1988
|
+
const char* command,
|
|
1989
|
+
lldb_command_return_object_t result,
|
|
1990
|
+
int add_to_history) {
|
|
1991
|
+
if (!interp || !command) return 0;
|
|
1992
|
+
|
|
1993
|
+
lldb::SBCommandInterpreter* i = static_cast<lldb::SBCommandInterpreter*>(interp);
|
|
1994
|
+
lldb::SBCommandReturnObject* r = result ? static_cast<lldb::SBCommandReturnObject*>(result) : nullptr;
|
|
1995
|
+
lldb::SBCommandReturnObject local_result;
|
|
1996
|
+
|
|
1997
|
+
lldb::ReturnStatus status = i->HandleCommand(command, r ? *r : local_result, add_to_history != 0);
|
|
1998
|
+
return status == lldb::eReturnStatusSuccessFinishResult ||
|
|
1999
|
+
status == lldb::eReturnStatusSuccessFinishNoResult ? 1 : 0;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
int lldb_command_interpreter_command_exists(lldb_command_interpreter_t interp, const char* command) {
|
|
2003
|
+
if (!interp || !command) return 0;
|
|
2004
|
+
return static_cast<lldb::SBCommandInterpreter*>(interp)->CommandExists(command) ? 1 : 0;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
int lldb_command_interpreter_alias_exists(lldb_command_interpreter_t interp, const char* alias) {
|
|
2008
|
+
if (!interp || !alias) return 0;
|
|
2009
|
+
return static_cast<lldb::SBCommandInterpreter*>(interp)->AliasExists(alias) ? 1 : 0;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
// ============================================================================
|
|
2013
|
+
// SBCommandReturnObject
|
|
2014
|
+
// ============================================================================
|
|
2015
|
+
|
|
2016
|
+
lldb_command_return_object_t lldb_command_return_object_create(void) {
|
|
2017
|
+
return static_cast<lldb_command_return_object_t>(new lldb::SBCommandReturnObject());
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
void lldb_command_return_object_destroy(lldb_command_return_object_t obj) {
|
|
2021
|
+
if (obj) {
|
|
2022
|
+
delete static_cast<lldb::SBCommandReturnObject*>(obj);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
int lldb_command_return_object_is_valid(lldb_command_return_object_t obj) {
|
|
2027
|
+
if (!obj) return 0;
|
|
2028
|
+
return static_cast<lldb::SBCommandReturnObject*>(obj)->IsValid() ? 1 : 0;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
const char* lldb_command_return_object_get_output(lldb_command_return_object_t obj) {
|
|
2032
|
+
if (!obj) return nullptr;
|
|
2033
|
+
return static_cast<lldb::SBCommandReturnObject*>(obj)->GetOutput();
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
const char* lldb_command_return_object_get_error(lldb_command_return_object_t obj) {
|
|
2037
|
+
if (!obj) return nullptr;
|
|
2038
|
+
return static_cast<lldb::SBCommandReturnObject*>(obj)->GetError();
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
int lldb_command_return_object_succeeded(lldb_command_return_object_t obj) {
|
|
2042
|
+
if (!obj) return 0;
|
|
2043
|
+
return static_cast<lldb::SBCommandReturnObject*>(obj)->Succeeded() ? 1 : 0;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
void lldb_command_return_object_clear(lldb_command_return_object_t obj) {
|
|
2047
|
+
if (!obj) return;
|
|
2048
|
+
static_cast<lldb::SBCommandReturnObject*>(obj)->Clear();
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
} // extern "C"
|