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,394 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ffi'
|
|
4
|
+
require 'rbconfig'
|
|
5
|
+
|
|
6
|
+
module LLDB
|
|
7
|
+
module FFIBindings
|
|
8
|
+
extend FFI::Library
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
# @rbs return: String
|
|
12
|
+
def library_name
|
|
13
|
+
case RbConfig::CONFIG['host_os']
|
|
14
|
+
when /darwin/
|
|
15
|
+
'liblldb_wrapper.dylib'
|
|
16
|
+
when /linux/
|
|
17
|
+
'liblldb_wrapper.so'
|
|
18
|
+
when /mswin|mingw/
|
|
19
|
+
'lldb_wrapper.dll'
|
|
20
|
+
else
|
|
21
|
+
raise "Unsupported platform: #{RbConfig::CONFIG['host_os']}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @rbs return: String
|
|
26
|
+
def library_path
|
|
27
|
+
current_dir = __dir__ || File.dirname(__FILE__)
|
|
28
|
+
|
|
29
|
+
search_paths = [
|
|
30
|
+
File.expand_path(current_dir),
|
|
31
|
+
File.expand_path('../lldb', current_dir),
|
|
32
|
+
File.join(current_dir, '..'),
|
|
33
|
+
current_dir
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
# steep:ignore:start
|
|
37
|
+
if defined?(Gem) && Gem.loaded_specs['lldb']
|
|
38
|
+
spec = Gem.loaded_specs['lldb']
|
|
39
|
+
search_paths << File.join(spec.full_gem_path, 'lib', 'lldb') if spec.respond_to?(:full_gem_path)
|
|
40
|
+
end
|
|
41
|
+
# steep:ignore:end
|
|
42
|
+
|
|
43
|
+
search_paths.compact.each do |path|
|
|
44
|
+
lib_path = File.join(path, library_name)
|
|
45
|
+
return lib_path if File.exist?(lib_path)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
library_name
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
ffi_lib library_path
|
|
53
|
+
|
|
54
|
+
# =========================================================================
|
|
55
|
+
# Initialization
|
|
56
|
+
# =========================================================================
|
|
57
|
+
attach_function :lldb_initialize, [], :void
|
|
58
|
+
attach_function :lldb_terminate, [], :void
|
|
59
|
+
|
|
60
|
+
# =========================================================================
|
|
61
|
+
# SBDebugger
|
|
62
|
+
# =========================================================================
|
|
63
|
+
attach_function :lldb_debugger_create, [], :pointer
|
|
64
|
+
attach_function :lldb_debugger_destroy, [:pointer], :void
|
|
65
|
+
attach_function :lldb_debugger_is_valid, [:pointer], :int
|
|
66
|
+
attach_function :lldb_debugger_create_target, %i[pointer string string string int pointer], :pointer
|
|
67
|
+
attach_function :lldb_debugger_create_target_simple, %i[pointer string], :pointer
|
|
68
|
+
attach_function :lldb_debugger_get_num_targets, [:pointer], :uint32
|
|
69
|
+
attach_function :lldb_debugger_get_target_at_index, %i[pointer uint32], :pointer
|
|
70
|
+
attach_function :lldb_debugger_get_selected_target, [:pointer], :pointer
|
|
71
|
+
attach_function :lldb_debugger_set_selected_target, %i[pointer pointer], :void
|
|
72
|
+
attach_function :lldb_debugger_delete_target, %i[pointer pointer], :int
|
|
73
|
+
attach_function :lldb_debugger_find_target_with_process_id, %i[pointer uint64], :pointer
|
|
74
|
+
attach_function :lldb_debugger_set_async, %i[pointer int], :void
|
|
75
|
+
attach_function :lldb_debugger_get_async, [:pointer], :int
|
|
76
|
+
attach_function :lldb_debugger_get_version_string, [], :string
|
|
77
|
+
attach_function :lldb_debugger_get_command_interpreter, [:pointer], :pointer
|
|
78
|
+
attach_function :lldb_debugger_handle_command, %i[pointer string], :void
|
|
79
|
+
|
|
80
|
+
# =========================================================================
|
|
81
|
+
# SBTarget
|
|
82
|
+
# =========================================================================
|
|
83
|
+
attach_function :lldb_target_destroy, [:pointer], :void
|
|
84
|
+
attach_function :lldb_target_is_valid, [:pointer], :int
|
|
85
|
+
attach_function :lldb_target_launch_simple, %i[pointer pointer pointer string], :pointer
|
|
86
|
+
attach_function :lldb_target_launch, %i[pointer pointer pointer], :pointer
|
|
87
|
+
attach_function :lldb_target_attach_to_process_with_id, %i[pointer uint64 pointer], :pointer
|
|
88
|
+
attach_function :lldb_target_attach_to_process_with_name, %i[pointer string int pointer], :pointer
|
|
89
|
+
attach_function :lldb_target_breakpoint_create_by_name, %i[pointer string string], :pointer
|
|
90
|
+
attach_function :lldb_target_breakpoint_create_by_location, %i[pointer string uint32], :pointer
|
|
91
|
+
attach_function :lldb_target_breakpoint_create_by_address, %i[pointer uint64], :pointer
|
|
92
|
+
attach_function :lldb_target_breakpoint_create_by_regex, %i[pointer string string], :pointer
|
|
93
|
+
attach_function :lldb_target_breakpoint_create_by_source_regex, %i[pointer string string], :pointer
|
|
94
|
+
attach_function :lldb_target_delete_breakpoint, %i[pointer int32], :int
|
|
95
|
+
attach_function :lldb_target_delete_all_breakpoints, [:pointer], :int
|
|
96
|
+
attach_function :lldb_target_enable_all_breakpoints, [:pointer], :int
|
|
97
|
+
attach_function :lldb_target_disable_all_breakpoints, [:pointer], :int
|
|
98
|
+
attach_function :lldb_target_find_breakpoint_by_id, %i[pointer int32], :pointer
|
|
99
|
+
attach_function :lldb_target_get_num_breakpoints, [:pointer], :uint32
|
|
100
|
+
attach_function :lldb_target_get_breakpoint_at_index, %i[pointer uint32], :pointer
|
|
101
|
+
attach_function :lldb_target_get_process, [:pointer], :pointer
|
|
102
|
+
attach_function :lldb_target_get_executable_path, [:pointer], :string
|
|
103
|
+
attach_function :lldb_target_get_num_modules, [:pointer], :uint32
|
|
104
|
+
attach_function :lldb_target_get_module_at_index, %i[pointer uint32], :pointer
|
|
105
|
+
attach_function :lldb_target_evaluate_expression, %i[pointer string], :pointer
|
|
106
|
+
attach_function :lldb_target_read_memory, %i[pointer uint64 pointer size_t pointer], :size_t
|
|
107
|
+
attach_function :lldb_target_get_address_byte_size, [:pointer], :uint32
|
|
108
|
+
attach_function :lldb_target_get_triple, [:pointer], :string
|
|
109
|
+
attach_function :lldb_target_watch_address, %i[pointer uint64 size_t int int pointer], :pointer
|
|
110
|
+
attach_function :lldb_target_delete_watchpoint, %i[pointer int32], :int
|
|
111
|
+
attach_function :lldb_target_delete_all_watchpoints, [:pointer], :int
|
|
112
|
+
attach_function :lldb_target_find_watchpoint_by_id, %i[pointer int32], :pointer
|
|
113
|
+
attach_function :lldb_target_get_num_watchpoints, [:pointer], :uint32
|
|
114
|
+
attach_function :lldb_target_get_watchpoint_at_index, %i[pointer uint32], :pointer
|
|
115
|
+
|
|
116
|
+
# =========================================================================
|
|
117
|
+
# SBLaunchInfo
|
|
118
|
+
# =========================================================================
|
|
119
|
+
attach_function :lldb_launch_info_create, [:pointer], :pointer
|
|
120
|
+
attach_function :lldb_launch_info_destroy, [:pointer], :void
|
|
121
|
+
attach_function :lldb_launch_info_set_working_directory, %i[pointer string], :void
|
|
122
|
+
attach_function :lldb_launch_info_set_environment_entries, %i[pointer pointer int], :void
|
|
123
|
+
attach_function :lldb_launch_info_get_launch_flags, [:pointer], :uint32
|
|
124
|
+
attach_function :lldb_launch_info_set_launch_flags, %i[pointer uint32], :void
|
|
125
|
+
|
|
126
|
+
# =========================================================================
|
|
127
|
+
# SBProcess
|
|
128
|
+
# =========================================================================
|
|
129
|
+
attach_function :lldb_process_destroy, [:pointer], :void
|
|
130
|
+
attach_function :lldb_process_is_valid, [:pointer], :int
|
|
131
|
+
attach_function :lldb_process_continue, [:pointer], :int
|
|
132
|
+
attach_function :lldb_process_stop, [:pointer], :int
|
|
133
|
+
attach_function :lldb_process_kill, [:pointer], :int
|
|
134
|
+
attach_function :lldb_process_detach, [:pointer], :int
|
|
135
|
+
attach_function :lldb_process_destroy_process, [:pointer], :int
|
|
136
|
+
attach_function :lldb_process_signal, %i[pointer int], :int
|
|
137
|
+
attach_function :lldb_process_get_state, [:pointer], :int
|
|
138
|
+
attach_function :lldb_process_get_num_threads, [:pointer], :uint32
|
|
139
|
+
attach_function :lldb_process_get_thread_at_index, %i[pointer uint32], :pointer
|
|
140
|
+
attach_function :lldb_process_get_thread_by_id, %i[pointer uint64], :pointer
|
|
141
|
+
attach_function :lldb_process_get_thread_by_index_id, %i[pointer uint32], :pointer
|
|
142
|
+
attach_function :lldb_process_get_selected_thread, [:pointer], :pointer
|
|
143
|
+
attach_function :lldb_process_set_selected_thread_by_id, %i[pointer uint64], :int
|
|
144
|
+
attach_function :lldb_process_set_selected_thread_by_index_id, %i[pointer uint32], :int
|
|
145
|
+
attach_function :lldb_process_get_process_id, [:pointer], :uint64
|
|
146
|
+
attach_function :lldb_process_get_exit_status, [:pointer], :int
|
|
147
|
+
attach_function :lldb_process_get_exit_description, [:pointer], :string
|
|
148
|
+
attach_function :lldb_process_read_memory, %i[pointer uint64 pointer size_t pointer], :size_t
|
|
149
|
+
attach_function :lldb_process_write_memory, %i[pointer uint64 pointer size_t pointer], :size_t
|
|
150
|
+
attach_function :lldb_process_allocate_memory, %i[pointer size_t uint32 pointer], :uint64
|
|
151
|
+
attach_function :lldb_process_deallocate_memory, %i[pointer uint64], :int
|
|
152
|
+
attach_function :lldb_process_read_cstring_from_memory, %i[pointer uint64 pointer size_t pointer], :size_t
|
|
153
|
+
attach_function :lldb_process_get_stdout, %i[pointer pointer size_t], :size_t
|
|
154
|
+
attach_function :lldb_process_get_stderr, %i[pointer pointer size_t], :size_t
|
|
155
|
+
attach_function :lldb_process_put_stdin, %i[pointer string size_t], :size_t
|
|
156
|
+
attach_function :lldb_process_send_async_interrupt, [:pointer], :int
|
|
157
|
+
attach_function :lldb_process_get_num_supported_hardware_watchpoints, %i[pointer pointer], :uint32
|
|
158
|
+
attach_function :lldb_process_get_unique_id, [:pointer], :uint32
|
|
159
|
+
|
|
160
|
+
# =========================================================================
|
|
161
|
+
# SBThread
|
|
162
|
+
# =========================================================================
|
|
163
|
+
attach_function :lldb_thread_destroy, [:pointer], :void
|
|
164
|
+
attach_function :lldb_thread_is_valid, [:pointer], :int
|
|
165
|
+
attach_function :lldb_thread_step_over, [:pointer], :int
|
|
166
|
+
attach_function :lldb_thread_step_into, [:pointer], :int
|
|
167
|
+
attach_function :lldb_thread_step_out, [:pointer], :int
|
|
168
|
+
attach_function :lldb_thread_step_instruction, %i[pointer int], :int
|
|
169
|
+
attach_function :lldb_thread_run_to_address, %i[pointer uint64], :int
|
|
170
|
+
attach_function :lldb_thread_get_num_frames, [:pointer], :uint32
|
|
171
|
+
attach_function :lldb_thread_get_frame_at_index, %i[pointer uint32], :pointer
|
|
172
|
+
attach_function :lldb_thread_get_selected_frame, [:pointer], :pointer
|
|
173
|
+
attach_function :lldb_thread_set_selected_frame, %i[pointer uint32], :int
|
|
174
|
+
attach_function :lldb_thread_get_thread_id, [:pointer], :uint64
|
|
175
|
+
attach_function :lldb_thread_get_index_id, [:pointer], :uint32
|
|
176
|
+
attach_function :lldb_thread_get_name, [:pointer], :string
|
|
177
|
+
attach_function :lldb_thread_get_queue_name, [:pointer], :string
|
|
178
|
+
attach_function :lldb_thread_get_stop_reason, [:pointer], :int
|
|
179
|
+
attach_function :lldb_thread_get_stop_description, %i[pointer size_t], :string
|
|
180
|
+
attach_function :lldb_thread_get_stop_reason_data_count, [:pointer], :uint64
|
|
181
|
+
attach_function :lldb_thread_get_stop_reason_data_at_index, %i[pointer uint32], :uint64
|
|
182
|
+
attach_function :lldb_thread_is_stopped, [:pointer], :int
|
|
183
|
+
attach_function :lldb_thread_is_suspended, [:pointer], :int
|
|
184
|
+
attach_function :lldb_thread_suspend, [:pointer], :int
|
|
185
|
+
attach_function :lldb_thread_resume, [:pointer], :int
|
|
186
|
+
attach_function :lldb_thread_get_process, [:pointer], :pointer
|
|
187
|
+
|
|
188
|
+
# =========================================================================
|
|
189
|
+
# SBFrame
|
|
190
|
+
# =========================================================================
|
|
191
|
+
attach_function :lldb_frame_destroy, [:pointer], :void
|
|
192
|
+
attach_function :lldb_frame_is_valid, [:pointer], :int
|
|
193
|
+
attach_function :lldb_frame_get_function_name, [:pointer], :string
|
|
194
|
+
attach_function :lldb_frame_get_display_function_name, [:pointer], :string
|
|
195
|
+
attach_function :lldb_frame_get_line, [:pointer], :uint32
|
|
196
|
+
attach_function :lldb_frame_get_file_path, [:pointer], :string
|
|
197
|
+
attach_function :lldb_frame_get_column, [:pointer], :uint32
|
|
198
|
+
attach_function :lldb_frame_get_pc, [:pointer], :uint64
|
|
199
|
+
attach_function :lldb_frame_set_pc, %i[pointer uint64], :int
|
|
200
|
+
attach_function :lldb_frame_get_sp, [:pointer], :uint64
|
|
201
|
+
attach_function :lldb_frame_get_fp, [:pointer], :uint64
|
|
202
|
+
attach_function :lldb_frame_find_variable, %i[pointer string], :pointer
|
|
203
|
+
attach_function :lldb_frame_evaluate_expression, %i[pointer string], :pointer
|
|
204
|
+
attach_function :lldb_frame_get_value_for_variable_path, %i[pointer string], :pointer
|
|
205
|
+
attach_function :lldb_frame_get_frame_id, [:pointer], :uint32
|
|
206
|
+
attach_function :lldb_frame_get_thread, [:pointer], :pointer
|
|
207
|
+
attach_function :lldb_frame_get_symbol_context, %i[pointer uint32], :pointer
|
|
208
|
+
attach_function :lldb_frame_get_variables, %i[pointer int int int int], :pointer
|
|
209
|
+
attach_function :lldb_frame_get_registers, [:pointer], :pointer
|
|
210
|
+
attach_function :lldb_frame_is_inlined, [:pointer], :int
|
|
211
|
+
attach_function :lldb_frame_disassemble, [:pointer], :string
|
|
212
|
+
attach_function :lldb_frame_get_module, [:pointer], :pointer
|
|
213
|
+
|
|
214
|
+
# =========================================================================
|
|
215
|
+
# SBBreakpoint
|
|
216
|
+
# =========================================================================
|
|
217
|
+
attach_function :lldb_breakpoint_destroy, [:pointer], :void
|
|
218
|
+
attach_function :lldb_breakpoint_is_valid, [:pointer], :int
|
|
219
|
+
attach_function :lldb_breakpoint_get_id, [:pointer], :int32
|
|
220
|
+
attach_function :lldb_breakpoint_is_enabled, [:pointer], :int
|
|
221
|
+
attach_function :lldb_breakpoint_set_enabled, %i[pointer int], :void
|
|
222
|
+
attach_function :lldb_breakpoint_is_one_shot, [:pointer], :int
|
|
223
|
+
attach_function :lldb_breakpoint_set_one_shot, %i[pointer int], :void
|
|
224
|
+
attach_function :lldb_breakpoint_get_hit_count, [:pointer], :uint32
|
|
225
|
+
attach_function :lldb_breakpoint_get_ignore_count, [:pointer], :uint32
|
|
226
|
+
attach_function :lldb_breakpoint_set_ignore_count, %i[pointer uint32], :void
|
|
227
|
+
attach_function :lldb_breakpoint_get_condition, [:pointer], :string
|
|
228
|
+
attach_function :lldb_breakpoint_set_condition, %i[pointer string], :void
|
|
229
|
+
attach_function :lldb_breakpoint_get_num_locations, [:pointer], :uint32
|
|
230
|
+
attach_function :lldb_breakpoint_get_location_at_index, %i[pointer uint32], :pointer
|
|
231
|
+
attach_function :lldb_breakpoint_find_location_by_id, %i[pointer int32], :pointer
|
|
232
|
+
attach_function :lldb_breakpoint_is_hardware, [:pointer], :int
|
|
233
|
+
attach_function :lldb_breakpoint_get_auto_continue, [:pointer], :int
|
|
234
|
+
attach_function :lldb_breakpoint_set_auto_continue, %i[pointer int], :void
|
|
235
|
+
attach_function :lldb_breakpoint_get_thread_id, [:pointer], :uint64
|
|
236
|
+
attach_function :lldb_breakpoint_set_thread_id, %i[pointer uint64], :void
|
|
237
|
+
attach_function :lldb_breakpoint_get_thread_name, [:pointer], :string
|
|
238
|
+
attach_function :lldb_breakpoint_set_thread_name, %i[pointer string], :void
|
|
239
|
+
attach_function :lldb_breakpoint_get_thread_index, [:pointer], :uint32
|
|
240
|
+
attach_function :lldb_breakpoint_set_thread_index, %i[pointer uint32], :void
|
|
241
|
+
|
|
242
|
+
# =========================================================================
|
|
243
|
+
# SBBreakpointLocation
|
|
244
|
+
# =========================================================================
|
|
245
|
+
attach_function :lldb_breakpoint_location_destroy, [:pointer], :void
|
|
246
|
+
attach_function :lldb_breakpoint_location_is_valid, [:pointer], :int
|
|
247
|
+
attach_function :lldb_breakpoint_location_get_id, [:pointer], :int32
|
|
248
|
+
attach_function :lldb_breakpoint_location_get_load_address, [:pointer], :uint64
|
|
249
|
+
attach_function :lldb_breakpoint_location_is_enabled, [:pointer], :int
|
|
250
|
+
attach_function :lldb_breakpoint_location_set_enabled, %i[pointer int], :void
|
|
251
|
+
attach_function :lldb_breakpoint_location_get_hit_count, [:pointer], :uint32
|
|
252
|
+
attach_function :lldb_breakpoint_location_get_ignore_count, [:pointer], :uint32
|
|
253
|
+
attach_function :lldb_breakpoint_location_set_ignore_count, %i[pointer uint32], :void
|
|
254
|
+
attach_function :lldb_breakpoint_location_get_condition, [:pointer], :string
|
|
255
|
+
attach_function :lldb_breakpoint_location_set_condition, %i[pointer string], :void
|
|
256
|
+
attach_function :lldb_breakpoint_location_get_breakpoint, [:pointer], :pointer
|
|
257
|
+
|
|
258
|
+
# =========================================================================
|
|
259
|
+
# SBValue
|
|
260
|
+
# =========================================================================
|
|
261
|
+
attach_function :lldb_value_destroy, [:pointer], :void
|
|
262
|
+
attach_function :lldb_value_is_valid, [:pointer], :int
|
|
263
|
+
attach_function :lldb_value_get_name, [:pointer], :string
|
|
264
|
+
attach_function :lldb_value_get_value, [:pointer], :string
|
|
265
|
+
attach_function :lldb_value_get_summary, [:pointer], :string
|
|
266
|
+
attach_function :lldb_value_get_type_name, [:pointer], :string
|
|
267
|
+
attach_function :lldb_value_get_type, [:pointer], :pointer
|
|
268
|
+
attach_function :lldb_value_get_num_children, [:pointer], :uint32
|
|
269
|
+
attach_function :lldb_value_get_child_at_index, %i[pointer uint32], :pointer
|
|
270
|
+
attach_function :lldb_value_get_child_member_with_name, %i[pointer string], :pointer
|
|
271
|
+
attach_function :lldb_value_get_value_as_signed, [:pointer], :int64
|
|
272
|
+
attach_function :lldb_value_get_value_as_unsigned, [:pointer], :uint64
|
|
273
|
+
attach_function :lldb_value_get_byte_size, [:pointer], :uint64
|
|
274
|
+
attach_function :lldb_value_might_have_children, [:pointer], :int
|
|
275
|
+
attach_function :lldb_value_get_error, %i[pointer pointer], :int
|
|
276
|
+
attach_function :lldb_value_dereference, [:pointer], :pointer
|
|
277
|
+
attach_function :lldb_value_address_of, [:pointer], :pointer
|
|
278
|
+
attach_function :lldb_value_cast, %i[pointer pointer], :pointer
|
|
279
|
+
attach_function :lldb_value_get_load_address, [:pointer], :uint64
|
|
280
|
+
attach_function :lldb_value_get_value_type, [:pointer], :int
|
|
281
|
+
attach_function :lldb_value_set_value_from_cstring, %i[pointer string pointer], :int
|
|
282
|
+
attach_function :lldb_value_create_child_at_offset, %i[pointer string pointer uint32], :pointer
|
|
283
|
+
attach_function :lldb_value_create_value_from_address, %i[pointer string uint64 pointer], :pointer
|
|
284
|
+
attach_function :lldb_value_create_value_from_expression, %i[pointer string string], :pointer
|
|
285
|
+
attach_function :lldb_value_watch, %i[pointer int int int pointer], :pointer
|
|
286
|
+
attach_function :lldb_value_get_expression_path, [:pointer], :string
|
|
287
|
+
attach_function :lldb_value_is_pointer_type, [:pointer], :int
|
|
288
|
+
attach_function :lldb_value_get_non_synthetic_value, [:pointer], :pointer
|
|
289
|
+
|
|
290
|
+
# =========================================================================
|
|
291
|
+
# SBValueList
|
|
292
|
+
# =========================================================================
|
|
293
|
+
attach_function :lldb_value_list_destroy, [:pointer], :void
|
|
294
|
+
attach_function :lldb_value_list_is_valid, [:pointer], :int
|
|
295
|
+
attach_function :lldb_value_list_get_size, [:pointer], :uint32
|
|
296
|
+
attach_function :lldb_value_list_get_value_at_index, %i[pointer uint32], :pointer
|
|
297
|
+
attach_function :lldb_value_list_get_first_value_by_name, %i[pointer string], :pointer
|
|
298
|
+
|
|
299
|
+
# =========================================================================
|
|
300
|
+
# SBError
|
|
301
|
+
# =========================================================================
|
|
302
|
+
attach_function :lldb_error_create, [], :pointer
|
|
303
|
+
attach_function :lldb_error_destroy, [:pointer], :void
|
|
304
|
+
attach_function :lldb_error_success, [:pointer], :int
|
|
305
|
+
attach_function :lldb_error_fail, [:pointer], :int
|
|
306
|
+
attach_function :lldb_error_get_cstring, [:pointer], :string
|
|
307
|
+
attach_function :lldb_error_get_error, [:pointer], :uint32
|
|
308
|
+
attach_function :lldb_error_clear, [:pointer], :void
|
|
309
|
+
attach_function :lldb_error_set_error_string, %i[pointer string], :void
|
|
310
|
+
|
|
311
|
+
# =========================================================================
|
|
312
|
+
# SBModule
|
|
313
|
+
# =========================================================================
|
|
314
|
+
attach_function :lldb_module_destroy, [:pointer], :void
|
|
315
|
+
attach_function :lldb_module_is_valid, [:pointer], :int
|
|
316
|
+
attach_function :lldb_module_get_file_path, [:pointer], :string
|
|
317
|
+
attach_function :lldb_module_get_platform_file_path, [:pointer], :string
|
|
318
|
+
attach_function :lldb_module_get_num_symbols, [:pointer], :uint32
|
|
319
|
+
|
|
320
|
+
# =========================================================================
|
|
321
|
+
# SBSymbolContext
|
|
322
|
+
# =========================================================================
|
|
323
|
+
attach_function :lldb_symbol_context_destroy, [:pointer], :void
|
|
324
|
+
attach_function :lldb_symbol_context_is_valid, [:pointer], :int
|
|
325
|
+
attach_function :lldb_symbol_context_get_module, [:pointer], :pointer
|
|
326
|
+
attach_function :lldb_symbol_context_get_function_name, [:pointer], :string
|
|
327
|
+
|
|
328
|
+
# =========================================================================
|
|
329
|
+
# SBType
|
|
330
|
+
# =========================================================================
|
|
331
|
+
attach_function :lldb_type_destroy, [:pointer], :void
|
|
332
|
+
attach_function :lldb_type_is_valid, [:pointer], :int
|
|
333
|
+
attach_function :lldb_type_get_name, [:pointer], :string
|
|
334
|
+
attach_function :lldb_type_get_display_type_name, [:pointer], :string
|
|
335
|
+
attach_function :lldb_type_get_byte_size, [:pointer], :uint64
|
|
336
|
+
attach_function :lldb_type_is_pointer_type, [:pointer], :int
|
|
337
|
+
attach_function :lldb_type_is_reference_type, [:pointer], :int
|
|
338
|
+
attach_function :lldb_type_is_array_type, [:pointer], :int
|
|
339
|
+
attach_function :lldb_type_is_vector_type, [:pointer], :int
|
|
340
|
+
attach_function :lldb_type_is_typedef_type, [:pointer], :int
|
|
341
|
+
attach_function :lldb_type_is_function_type, [:pointer], :int
|
|
342
|
+
attach_function :lldb_type_is_polymorphic_class, [:pointer], :int
|
|
343
|
+
attach_function :lldb_type_get_pointer_type, [:pointer], :pointer
|
|
344
|
+
attach_function :lldb_type_get_pointee_type, [:pointer], :pointer
|
|
345
|
+
attach_function :lldb_type_get_reference_type, [:pointer], :pointer
|
|
346
|
+
attach_function :lldb_type_get_dereferenced_type, [:pointer], :pointer
|
|
347
|
+
attach_function :lldb_type_get_unqualified_type, [:pointer], :pointer
|
|
348
|
+
attach_function :lldb_type_get_canonical_type, [:pointer], :pointer
|
|
349
|
+
attach_function :lldb_type_get_array_element_type, [:pointer], :pointer
|
|
350
|
+
attach_function :lldb_type_get_array_size, [:pointer], :uint64
|
|
351
|
+
attach_function :lldb_type_get_num_fields, [:pointer], :uint32
|
|
352
|
+
attach_function :lldb_type_get_num_direct_base_classes, [:pointer], :uint32
|
|
353
|
+
attach_function :lldb_type_get_num_virtual_base_classes, [:pointer], :uint32
|
|
354
|
+
attach_function :lldb_type_get_basic_type, [:pointer], :int
|
|
355
|
+
|
|
356
|
+
# =========================================================================
|
|
357
|
+
# SBWatchpoint
|
|
358
|
+
# =========================================================================
|
|
359
|
+
attach_function :lldb_watchpoint_destroy, [:pointer], :void
|
|
360
|
+
attach_function :lldb_watchpoint_is_valid, [:pointer], :int
|
|
361
|
+
attach_function :lldb_watchpoint_get_id, [:pointer], :int32
|
|
362
|
+
attach_function :lldb_watchpoint_is_enabled, [:pointer], :int
|
|
363
|
+
attach_function :lldb_watchpoint_set_enabled, %i[pointer int], :void
|
|
364
|
+
attach_function :lldb_watchpoint_get_hit_count, [:pointer], :uint32
|
|
365
|
+
attach_function :lldb_watchpoint_get_ignore_count, [:pointer], :uint32
|
|
366
|
+
attach_function :lldb_watchpoint_set_ignore_count, %i[pointer uint32], :void
|
|
367
|
+
attach_function :lldb_watchpoint_get_condition, [:pointer], :string
|
|
368
|
+
attach_function :lldb_watchpoint_set_condition, %i[pointer string], :void
|
|
369
|
+
attach_function :lldb_watchpoint_get_watch_address, [:pointer], :uint64
|
|
370
|
+
attach_function :lldb_watchpoint_get_watch_size, [:pointer], :size_t
|
|
371
|
+
attach_function :lldb_watchpoint_is_watching_reads, [:pointer], :int
|
|
372
|
+
attach_function :lldb_watchpoint_is_watching_writes, [:pointer], :int
|
|
373
|
+
|
|
374
|
+
# =========================================================================
|
|
375
|
+
# SBCommandInterpreter
|
|
376
|
+
# =========================================================================
|
|
377
|
+
attach_function :lldb_command_interpreter_destroy, [:pointer], :void
|
|
378
|
+
attach_function :lldb_command_interpreter_is_valid, [:pointer], :int
|
|
379
|
+
attach_function :lldb_command_interpreter_handle_command, %i[pointer string pointer int], :int
|
|
380
|
+
attach_function :lldb_command_interpreter_command_exists, %i[pointer string], :int
|
|
381
|
+
attach_function :lldb_command_interpreter_alias_exists, %i[pointer string], :int
|
|
382
|
+
|
|
383
|
+
# =========================================================================
|
|
384
|
+
# SBCommandReturnObject
|
|
385
|
+
# =========================================================================
|
|
386
|
+
attach_function :lldb_command_return_object_create, [], :pointer
|
|
387
|
+
attach_function :lldb_command_return_object_destroy, [:pointer], :void
|
|
388
|
+
attach_function :lldb_command_return_object_is_valid, [:pointer], :int
|
|
389
|
+
attach_function :lldb_command_return_object_get_output, [:pointer], :string
|
|
390
|
+
attach_function :lldb_command_return_object_get_error, [:pointer], :string
|
|
391
|
+
attach_function :lldb_command_return_object_succeeded, [:pointer], :int
|
|
392
|
+
attach_function :lldb_command_return_object_clear, [:pointer], :void
|
|
393
|
+
end
|
|
394
|
+
end
|
data/lib/lldb/frame.rb
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rbs_inline: enabled
|
|
4
|
+
|
|
5
|
+
module LLDB
|
|
6
|
+
class Frame
|
|
7
|
+
# @rbs return: Thread
|
|
8
|
+
attr_reader :thread
|
|
9
|
+
|
|
10
|
+
# @rbs ptr: FFI::Pointer
|
|
11
|
+
# @rbs thread: Thread
|
|
12
|
+
# @rbs return: void
|
|
13
|
+
def initialize(ptr, thread:)
|
|
14
|
+
@ptr = ptr # : FFI::Pointer
|
|
15
|
+
@thread = thread
|
|
16
|
+
ObjectSpace.define_finalizer(self, self.class.release(@ptr))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @rbs ptr: FFI::Pointer
|
|
20
|
+
# @rbs return: ^(Integer) -> void
|
|
21
|
+
def self.release(ptr)
|
|
22
|
+
->(_id) { FFIBindings.lldb_frame_destroy(ptr) unless ptr.null? }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @rbs return: bool
|
|
26
|
+
def valid?
|
|
27
|
+
!@ptr.null? && FFIBindings.lldb_frame_is_valid(@ptr) != 0
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @rbs return: String?
|
|
31
|
+
def function_name
|
|
32
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
33
|
+
|
|
34
|
+
FFIBindings.lldb_frame_get_function_name(@ptr)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @rbs return: String?
|
|
38
|
+
def display_function_name
|
|
39
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
40
|
+
|
|
41
|
+
FFIBindings.lldb_frame_get_display_function_name(@ptr)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @rbs return: Integer
|
|
45
|
+
def line
|
|
46
|
+
return 0 unless valid?
|
|
47
|
+
|
|
48
|
+
FFIBindings.lldb_frame_get_line(@ptr)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @rbs return: String?
|
|
52
|
+
def file_path
|
|
53
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
54
|
+
|
|
55
|
+
FFIBindings.lldb_frame_get_file_path(@ptr)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @rbs return: Integer
|
|
59
|
+
def column
|
|
60
|
+
return 0 unless valid?
|
|
61
|
+
|
|
62
|
+
FFIBindings.lldb_frame_get_column(@ptr)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @rbs return: Integer
|
|
66
|
+
def pc
|
|
67
|
+
return 0 unless valid?
|
|
68
|
+
|
|
69
|
+
FFIBindings.lldb_frame_get_pc(@ptr)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# @rbs return: Integer
|
|
73
|
+
def sp
|
|
74
|
+
return 0 unless valid?
|
|
75
|
+
|
|
76
|
+
FFIBindings.lldb_frame_get_sp(@ptr)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @rbs return: Integer
|
|
80
|
+
def fp
|
|
81
|
+
return 0 unless valid?
|
|
82
|
+
|
|
83
|
+
FFIBindings.lldb_frame_get_fp(@ptr)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# @rbs return: Integer
|
|
87
|
+
def frame_id
|
|
88
|
+
return 0 unless valid?
|
|
89
|
+
|
|
90
|
+
FFIBindings.lldb_frame_get_frame_id(@ptr)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
alias id frame_id
|
|
94
|
+
|
|
95
|
+
# @rbs name: String
|
|
96
|
+
# @rbs return: Value?
|
|
97
|
+
def find_variable(name)
|
|
98
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
99
|
+
|
|
100
|
+
value_ptr = FFIBindings.lldb_frame_find_variable(@ptr, name)
|
|
101
|
+
return nil if value_ptr.nil? || value_ptr.null?
|
|
102
|
+
|
|
103
|
+
Value.new(value_ptr, parent: self)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# @rbs expression: String
|
|
107
|
+
# @rbs return: Value?
|
|
108
|
+
def evaluate_expression(expression)
|
|
109
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
110
|
+
|
|
111
|
+
value_ptr = FFIBindings.lldb_frame_evaluate_expression(@ptr, expression)
|
|
112
|
+
return nil if value_ptr.nil? || value_ptr.null?
|
|
113
|
+
|
|
114
|
+
Value.new(value_ptr, parent: self)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# @rbs path: String
|
|
118
|
+
# @rbs return: Value?
|
|
119
|
+
def get_value_for_variable_path(path)
|
|
120
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
121
|
+
|
|
122
|
+
value_ptr = FFIBindings.lldb_frame_get_value_for_variable_path(@ptr, path)
|
|
123
|
+
return nil if value_ptr.nil? || value_ptr.null?
|
|
124
|
+
|
|
125
|
+
Value.new(value_ptr, parent: self)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @rbs scope: Integer
|
|
129
|
+
# @rbs return: SymbolContext?
|
|
130
|
+
def symbol_context(scope = SymbolContextItem::EVERYTHING)
|
|
131
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
132
|
+
|
|
133
|
+
ctx_ptr = FFIBindings.lldb_frame_get_symbol_context(@ptr, scope)
|
|
134
|
+
return nil if ctx_ptr.nil? || ctx_ptr.null?
|
|
135
|
+
|
|
136
|
+
SymbolContext.new(ctx_ptr, parent: self)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# @rbs return: String
|
|
140
|
+
def location
|
|
141
|
+
"#{file_path || '?'}:#{line}"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# @rbs return: String
|
|
145
|
+
def to_s
|
|
146
|
+
"#{display_function_name || function_name || '?'} at #{location}"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# @rbs value: Integer
|
|
150
|
+
# @rbs return: bool
|
|
151
|
+
def pc=(value)
|
|
152
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
153
|
+
|
|
154
|
+
FFIBindings.lldb_frame_set_pc(@ptr, value) != 0
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# @rbs arguments: bool
|
|
158
|
+
# @rbs locals: bool
|
|
159
|
+
# @rbs statics: bool
|
|
160
|
+
# @rbs in_scope_only: bool
|
|
161
|
+
# @rbs return: ValueList
|
|
162
|
+
def get_variables(arguments: true, locals: true, statics: true, in_scope_only: true)
|
|
163
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
164
|
+
|
|
165
|
+
list_ptr = FFIBindings.lldb_frame_get_variables(
|
|
166
|
+
@ptr,
|
|
167
|
+
arguments ? 1 : 0,
|
|
168
|
+
locals ? 1 : 0,
|
|
169
|
+
statics ? 1 : 0,
|
|
170
|
+
in_scope_only ? 1 : 0
|
|
171
|
+
)
|
|
172
|
+
raise LLDBError, 'Failed to get variables' if list_ptr.nil? || list_ptr.null?
|
|
173
|
+
|
|
174
|
+
ValueList.new(list_ptr, parent: self)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# @rbs return: ValueList
|
|
178
|
+
def get_registers
|
|
179
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
180
|
+
|
|
181
|
+
list_ptr = FFIBindings.lldb_frame_get_registers(@ptr)
|
|
182
|
+
raise LLDBError, 'Failed to get registers' if list_ptr.nil? || list_ptr.null?
|
|
183
|
+
|
|
184
|
+
ValueList.new(list_ptr, parent: self)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# @rbs return: bool
|
|
188
|
+
def inlined?
|
|
189
|
+
return false unless valid?
|
|
190
|
+
|
|
191
|
+
FFIBindings.lldb_frame_is_inlined(@ptr) != 0
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# @rbs return: String?
|
|
195
|
+
def disassemble
|
|
196
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
197
|
+
|
|
198
|
+
FFIBindings.lldb_frame_disassemble(@ptr)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# @rbs return: Module?
|
|
202
|
+
def get_module
|
|
203
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
204
|
+
|
|
205
|
+
mod_ptr = FFIBindings.lldb_frame_get_module(@ptr)
|
|
206
|
+
return nil if mod_ptr.nil? || mod_ptr.null?
|
|
207
|
+
|
|
208
|
+
Module.new(mod_ptr, target: @thread.process.target)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# @rbs return: Thread?
|
|
212
|
+
def get_thread
|
|
213
|
+
raise InvalidObjectError, 'Frame is not valid' unless valid?
|
|
214
|
+
|
|
215
|
+
thread_ptr = FFIBindings.lldb_frame_get_thread(@ptr)
|
|
216
|
+
return nil if thread_ptr.nil? || thread_ptr.null?
|
|
217
|
+
|
|
218
|
+
Thread.new(thread_ptr, process: @thread.process)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# @rbs return: FFI::Pointer
|
|
222
|
+
def to_ptr
|
|
223
|
+
@ptr
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|