lldb 0.2.0 → 0.3.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -4
  3. data/README.md +86 -2
  4. data/Rakefile +36 -0
  5. data/bindings/constants.yml +137 -0
  6. data/bindings/surface.yml +3072 -0
  7. data/ext/lldb/discovery.rb +101 -0
  8. data/ext/lldb/extconf.rb +206 -88
  9. data/ext/lldb/lldb_wrapper.cpp +7934 -877
  10. data/ext/lldb/lldb_wrapper.h +596 -333
  11. data/lib/lldb/address.rb +81 -0
  12. data/lib/lldb/api_support.rb +23 -6
  13. data/lib/lldb/attach_info.rb +122 -0
  14. data/lib/lldb/block.rb +121 -0
  15. data/lib/lldb/breakpoint.rb +11 -6
  16. data/lib/lldb/breakpoint_location.rb +20 -5
  17. data/lib/lldb/broadcaster.rb +79 -0
  18. data/lib/lldb/command_interpreter.rb +9 -4
  19. data/lib/lldb/command_return_object.rb +24 -5
  20. data/lib/lldb/compile_unit.rb +64 -0
  21. data/lib/lldb/context.rb +81 -0
  22. data/lib/lldb/debugger.rb +55 -12
  23. data/lib/lldb/error.rb +50 -3
  24. data/lib/lldb/event.rb +109 -0
  25. data/lib/lldb/expression_options.rb +124 -0
  26. data/lib/lldb/ffi_bindings.rb +313 -31
  27. data/lib/lldb/file_spec.rb +90 -0
  28. data/lib/lldb/file_spec_list.rb +78 -0
  29. data/lib/lldb/frame.rb +109 -17
  30. data/lib/lldb/function.rb +121 -0
  31. data/lib/lldb/instruction.rb +83 -0
  32. data/lib/lldb/instruction_list.rb +68 -0
  33. data/lib/lldb/launch_info.rb +145 -19
  34. data/lib/lldb/line_entry.rb +75 -0
  35. data/lib/lldb/listener.rb +96 -0
  36. data/lib/lldb/memory_region_info.rb +8 -3
  37. data/lib/lldb/module.rb +46 -5
  38. data/lib/lldb/native.rb +36 -0
  39. data/lib/lldb/native_buffer.rb +32 -0
  40. data/lib/lldb/native_handle.rb +60 -0
  41. data/lib/lldb/native_lifecycle.rb +64 -0
  42. data/lib/lldb/native_string_array.rb +34 -0
  43. data/lib/lldb/process.rb +102 -40
  44. data/lib/lldb/symbol.rb +117 -0
  45. data/lib/lldb/symbol_context.rb +9 -4
  46. data/lib/lldb/target.rb +69 -67
  47. data/lib/lldb/thread.rb +51 -18
  48. data/lib/lldb/type.rb +40 -3
  49. data/lib/lldb/type_member.rb +67 -0
  50. data/lib/lldb/types.rb +69 -4
  51. data/lib/lldb/value.rb +27 -17
  52. data/lib/lldb/value_list.rb +9 -5
  53. data/lib/lldb/version.rb +1 -1
  54. data/lib/lldb/watchpoint.rb +26 -9
  55. data/lib/lldb.rb +78 -10
  56. data/lldb.gemspec +4 -1
  57. data/rbs_collection.yaml +1 -1
  58. data/script/check_bindings +259 -0
  59. data/script/guard_c_exports +139 -0
  60. data/sig/lldb/ffi_bindings.rbs +247 -21
  61. data/sig/lldb/weak_ref.rbs +7 -0
  62. metadata +30 -6
  63. data/ext/lldb/Makefile +0 -24
  64. data/ext/lldb/liblldb_wrapper.dylib +0 -0
  65. data/ext/lldb/lldb_wrapper.o +0 -0
  66. data/ext/lldb/mkmf.log +0 -24
@@ -7,6 +7,11 @@ module LLDB
7
7
  module FFIBindings
8
8
  extend FFI::Library
9
9
 
10
+ EXPECTED_WRAPPER_ABI_VERSION = 1
11
+ CAPABILITIES = {
12
+ watchpoint_access_kind: 1
13
+ }.freeze
14
+
10
15
  class << self
11
16
  # @rbs return: String
12
17
  def library_name
@@ -15,10 +20,9 @@ module LLDB
15
20
  'liblldb_wrapper.dylib'
16
21
  when /linux/
17
22
  'liblldb_wrapper.so'
18
- when /mswin|mingw/
19
- 'lldb_wrapper.dll'
20
23
  else
21
- raise "Unsupported platform: #{RbConfig::CONFIG['host_os']}"
24
+ raise UnsupportedPlatformError,
25
+ "Unsupported platform: #{RbConfig::CONFIG['host_os']} (supported: Linux, macOS)"
22
26
  end
23
27
  end
24
28
 
@@ -37,6 +41,10 @@ module LLDB
37
41
  if defined?(Gem) && Gem.loaded_specs['lldb']
38
42
  spec = Gem.loaded_specs['lldb']
39
43
  search_paths << File.join(spec.full_gem_path, 'lib', 'lldb') if spec.respond_to?(:full_gem_path)
44
+ if spec.respond_to?(:extension_dir) && spec.extension_dir
45
+ search_paths << File.join(spec.extension_dir, 'lldb')
46
+ search_paths << spec.extension_dir
47
+ end
40
48
  end
41
49
  # steep:ignore:end
42
50
 
@@ -47,20 +55,73 @@ module LLDB
47
55
 
48
56
  library_name
49
57
  end
58
+
59
+ # @rbs return: Integer
60
+ def wrapper_abi_version
61
+ lldb_wrapper_abi_version
62
+ end
63
+
64
+ # @rbs return: String
65
+ def build_lldb_version
66
+ lldb_wrapper_build_lldb_version
67
+ end
68
+
69
+ # @rbs return: String
70
+ def runtime_lldb_version
71
+ lldb_wrapper_runtime_lldb_version
72
+ end
73
+
74
+ # @rbs feature: ::Symbol
75
+ # @rbs return: bool
76
+ def capability_supported?(feature)
77
+ capability = CAPABILITIES[feature]
78
+ return false unless capability
79
+
80
+ lldb_wrapper_has_capability(capability) != 0
81
+ end
50
82
  end
51
83
 
52
- ffi_lib library_path
84
+ LIBRARY_PATH = library_path
85
+
86
+ ffi_lib LIBRARY_PATH
87
+
88
+ begin
89
+ attach_function :lldb_wrapper_abi_version, [], :uint32
90
+ attach_function :lldb_wrapper_build_lldb_version, [], :string
91
+ attach_function :lldb_wrapper_runtime_lldb_version, [], :string
92
+ attach_function :lldb_wrapper_has_capability, [:uint32], :int
93
+
94
+ actual_abi_version = lldb_wrapper_abi_version
95
+ if actual_abi_version != EXPECTED_WRAPPER_ABI_VERSION
96
+ raise IncompatibleWrapperError,
97
+ "Incompatible LLDB wrapper at #{LIBRARY_PATH}: " \
98
+ "expected ABI #{EXPECTED_WRAPPER_ABI_VERSION}, got #{actual_abi_version}"
99
+ end
100
+ rescue FFI::NotFoundError, LoadError => e
101
+ raise IncompatibleWrapperError,
102
+ "Incompatible LLDB wrapper at #{LIBRARY_PATH}: metadata is unavailable (#{e.message})"
103
+ end
104
+
105
+ # Wrapper metadata and capabilities
106
+ attach_function :lldb_wrapper_abi_version, [], :uint32
107
+ attach_function :lldb_wrapper_build_lldb_version, [], :string
108
+ attach_function :lldb_wrapper_runtime_lldb_version, [], :string
109
+ attach_function :lldb_wrapper_has_capability, [:uint32], :int
110
+ attach_function :lldb_wrapper_last_error_message, [], :string
111
+ attach_function :lldb_wrapper_last_error_code, [], :int
112
+ attach_function :lldb_wrapper_clear_last_error, [], :void
53
113
 
54
114
  # =========================================================================
55
115
  # Initialization
56
116
  # =========================================================================
57
- attach_function :lldb_initialize, [], :void
117
+ attach_function :lldb_initialize, [:pointer], :int
58
118
  attach_function :lldb_terminate, [], :void
59
119
 
60
120
  # =========================================================================
61
121
  # SBDebugger
62
122
  # =========================================================================
63
123
  attach_function :lldb_debugger_create, [], :pointer
124
+ attach_function :lldb_debugger_create_with_source_init_files, [:int], :pointer
64
125
  attach_function :lldb_debugger_destroy, [:pointer], :void
65
126
  attach_function :lldb_debugger_is_valid, [:pointer], :int
66
127
  attach_function :lldb_debugger_create_target, %i[pointer string string string int pointer], :pointer
@@ -75,17 +136,56 @@ module LLDB
75
136
  attach_function :lldb_debugger_get_async, [:pointer], :int
76
137
  attach_function :lldb_debugger_get_version_string, [], :string
77
138
  attach_function :lldb_debugger_get_command_interpreter, [:pointer], :pointer
78
- attach_function :lldb_debugger_handle_command, %i[pointer string], :void
139
+ attach_function :lldb_debugger_get_broadcaster, [:pointer], :pointer
140
+ attach_function :lldb_debugger_get_listener, [:pointer], :pointer
141
+ # LLDB command execution can run user-provided command scripts.
142
+ attach_function :lldb_debugger_handle_command, %i[pointer string], :void, blocking: true
143
+
144
+ # =========================================================================
145
+ # SBBroadcaster, SBListener, and SBEvent
146
+ # =========================================================================
147
+ attach_function :lldb_broadcaster_create, [:string], :pointer
148
+ attach_function :lldb_broadcaster_destroy, [:pointer], :void
149
+ attach_function :lldb_broadcaster_is_valid, [:pointer], :int
150
+ attach_function :lldb_broadcaster_get_name, [:pointer], :string
151
+ attach_function :lldb_broadcaster_add_listener, %i[pointer pointer uint32], :uint32
152
+ attach_function :lldb_broadcaster_remove_listener, %i[pointer pointer uint32], :int
153
+ attach_function :lldb_broadcaster_event_type_has_listeners, %i[pointer uint32], :int
154
+ attach_function :lldb_broadcaster_broadcast_event_by_type, %i[pointer uint32 int], :void
155
+
156
+ attach_function :lldb_listener_create, [:string], :pointer
157
+ attach_function :lldb_listener_destroy, [:pointer], :void
158
+ attach_function :lldb_listener_is_valid, [:pointer], :int
159
+ attach_function :lldb_listener_start_listening_for_events, %i[pointer pointer uint32], :uint32
160
+ attach_function :lldb_listener_stop_listening_for_events, %i[pointer pointer uint32], :int
161
+ attach_function :lldb_listener_wait_for_event, [:pointer, :uint32], :pointer, blocking: true
162
+ attach_function :lldb_listener_peek_event, [:pointer], :pointer
163
+ attach_function :lldb_listener_next_event, [:pointer], :pointer
164
+
165
+ attach_function :lldb_event_destroy, [:pointer], :void
166
+ attach_function :lldb_event_is_valid, [:pointer], :int
167
+ attach_function :lldb_event_get_type, [:pointer], :uint32
168
+ attach_function :lldb_event_get_data_flavor, [:pointer], :string
169
+ attach_function :lldb_event_get_broadcaster_class, [:pointer], :string
170
+ attach_function :lldb_event_get_description, %i[pointer pointer size_t], :uint32
171
+ attach_function :lldb_event_get_broadcaster, [:pointer], :pointer
172
+ attach_function :lldb_event_is_process_event, [:pointer], :int
173
+ attach_function :lldb_event_get_process_state, [:pointer], :int
174
+ attach_function :lldb_event_get_restarted, [:pointer], :int
175
+ attach_function :lldb_event_get_interrupted, [:pointer], :int
176
+ attach_function :lldb_event_get_process, [:pointer], :pointer
79
177
 
80
178
  # =========================================================================
81
179
  # SBTarget
82
180
  # =========================================================================
83
181
  attach_function :lldb_target_destroy, [:pointer], :void
84
182
  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
183
+ # Launch and attach may wait for the inferior or its debug server.
184
+ attach_function :lldb_target_launch_simple, %i[pointer pointer pointer string], :pointer, blocking: true
185
+ attach_function :lldb_target_launch, %i[pointer pointer pointer], :pointer, blocking: true
186
+ attach_function :lldb_target_attach_to_process_with_id, %i[pointer uint64 pointer], :pointer, blocking: true
187
+ attach_function :lldb_target_attach_to_process_with_name, %i[pointer string int pointer], :pointer, blocking: true
188
+ attach_function :lldb_target_attach_with_info, %i[pointer pointer pointer], :pointer, blocking: true
89
189
  attach_function :lldb_target_breakpoint_create_by_name, %i[pointer string string], :pointer
90
190
  attach_function :lldb_target_breakpoint_create_by_location, %i[pointer string uint32], :pointer
91
191
  attach_function :lldb_target_breakpoint_create_by_address, %i[pointer uint64], :pointer
@@ -100,9 +200,11 @@ module LLDB
100
200
  attach_function :lldb_target_get_breakpoint_at_index, %i[pointer uint32], :pointer
101
201
  attach_function :lldb_target_get_process, [:pointer], :pointer
102
202
  attach_function :lldb_target_get_executable_path, [:pointer], :string
203
+ attach_function :lldb_target_get_executable_file, [:pointer], :pointer
103
204
  attach_function :lldb_target_get_num_modules, [:pointer], :uint32
104
205
  attach_function :lldb_target_get_module_at_index, %i[pointer uint32], :pointer
105
206
  attach_function :lldb_target_evaluate_expression, %i[pointer string], :pointer
207
+ attach_function :lldb_target_evaluate_expression_with_options, %i[pointer string pointer], :pointer
106
208
  attach_function :lldb_target_read_memory, %i[pointer uint64 pointer size_t pointer], :size_t
107
209
  attach_function :lldb_target_get_address_byte_size, [:pointer], :uint32
108
210
  attach_function :lldb_target_get_triple, [:pointer], :string
@@ -118,22 +220,117 @@ module LLDB
118
220
  # =========================================================================
119
221
  attach_function :lldb_launch_info_create, [:pointer], :pointer
120
222
  attach_function :lldb_launch_info_destroy, [:pointer], :void
223
+ attach_function :lldb_launch_info_get_num_arguments, [:pointer], :uint32
224
+ attach_function :lldb_launch_info_get_argument_at_index, %i[pointer uint32], :string
121
225
  attach_function :lldb_launch_info_set_working_directory, %i[pointer string], :void
226
+ attach_function :lldb_launch_info_get_working_directory, [:pointer], :string
122
227
  attach_function :lldb_launch_info_set_environment_entries, %i[pointer pointer int], :void
228
+ attach_function :lldb_launch_info_get_num_environment_entries, [:pointer], :uint32
229
+ attach_function :lldb_launch_info_get_environment_entry_at_index, %i[pointer uint32], :string
123
230
  attach_function :lldb_launch_info_get_launch_flags, [:pointer], :uint32
124
231
  attach_function :lldb_launch_info_set_launch_flags, %i[pointer uint32], :void
232
+ attach_function :lldb_launch_info_set_arguments, %i[pointer pointer int], :void
233
+ attach_function :lldb_launch_info_get_executable_file, [:pointer], :pointer
234
+ attach_function :lldb_launch_info_set_executable_file, %i[pointer pointer int], :void
235
+ attach_function :lldb_launch_info_get_listener, [:pointer], :pointer
236
+ attach_function :lldb_launch_info_set_listener, %i[pointer pointer], :void
237
+ attach_function :lldb_launch_info_get_process_plugin_name, [:pointer], :string
238
+ attach_function :lldb_launch_info_set_process_plugin_name, %i[pointer string], :void
239
+ attach_function :lldb_launch_info_get_shell, [:pointer], :string
240
+ attach_function :lldb_launch_info_set_shell, %i[pointer string], :void
241
+ attach_function :lldb_launch_info_add_close_file_action, %i[pointer int], :int
242
+ attach_function :lldb_launch_info_add_duplicate_file_action, %i[pointer int int], :int
243
+ attach_function :lldb_launch_info_add_open_file_action, %i[pointer int string int int], :int
244
+ attach_function :lldb_launch_info_add_suppress_file_action, %i[pointer int int int], :int
245
+
246
+ # SBAttachInfo
247
+ attach_function :lldb_attach_info_create, [:uint64], :pointer
248
+ attach_function :lldb_attach_info_destroy, [:pointer], :void
249
+ attach_function :lldb_attach_info_get_process_id, [:pointer], :uint64
250
+ attach_function :lldb_attach_info_set_process_id, %i[pointer uint64], :void
251
+ attach_function :lldb_attach_info_set_executable, %i[pointer string], :void
252
+ attach_function :lldb_attach_info_set_executable_file, %i[pointer pointer], :void
253
+ attach_function :lldb_attach_info_get_wait_for_launch, [:pointer], :int
254
+ attach_function :lldb_attach_info_set_wait_for_launch, %i[pointer int], :void
255
+ attach_function :lldb_attach_info_get_ignore_existing, [:pointer], :int
256
+ attach_function :lldb_attach_info_set_ignore_existing, %i[pointer int], :void
257
+ attach_function :lldb_attach_info_get_resume_count, [:pointer], :uint32
258
+ attach_function :lldb_attach_info_set_resume_count, %i[pointer uint32], :void
259
+ attach_function :lldb_attach_info_get_process_plugin_name, [:pointer], :string
260
+ attach_function :lldb_attach_info_set_process_plugin_name, %i[pointer string], :void
261
+ attach_function :lldb_attach_info_get_listener, [:pointer], :pointer
262
+ attach_function :lldb_attach_info_set_listener, %i[pointer pointer], :void
263
+
264
+ # SBExpressionOptions
265
+ attach_function :lldb_expression_options_create, [], :pointer
266
+ attach_function :lldb_expression_options_destroy, [:pointer], :void
267
+ attach_function :lldb_expression_options_get_timeout, [:pointer], :uint32
268
+ attach_function :lldb_expression_options_set_timeout, %i[pointer uint32], :void
269
+ attach_function :lldb_expression_options_get_unwind_on_error, [:pointer], :int
270
+ attach_function :lldb_expression_options_set_unwind_on_error, %i[pointer int], :void
271
+ attach_function :lldb_expression_options_get_ignore_breakpoints, [:pointer], :int
272
+ attach_function :lldb_expression_options_set_ignore_breakpoints, %i[pointer int], :void
273
+ attach_function :lldb_expression_options_get_fetch_dynamic_value, [:pointer], :int
274
+ attach_function :lldb_expression_options_set_fetch_dynamic_value, %i[pointer int], :void
275
+ attach_function :lldb_expression_options_get_try_all_threads, [:pointer], :int
276
+ attach_function :lldb_expression_options_set_try_all_threads, %i[pointer int], :void
277
+ attach_function :lldb_expression_options_get_stop_others, [:pointer], :int
278
+ attach_function :lldb_expression_options_set_stop_others, %i[pointer int], :void
279
+ attach_function :lldb_expression_options_set_language, %i[pointer int], :void
280
+ attach_function :lldb_expression_options_get_suppress_persistent_result, [:pointer], :int
281
+ attach_function :lldb_expression_options_set_suppress_persistent_result, %i[pointer int], :void
282
+
283
+ # =========================================================================
284
+ # SBFileSpec
285
+ # =========================================================================
286
+ attach_function :lldb_file_spec_create, %i[string int], :pointer
287
+ attach_function :lldb_file_spec_destroy, [:pointer], :void
288
+ attach_function :lldb_file_spec_is_valid, [:pointer], :int
289
+ attach_function :lldb_file_spec_exists, [:pointer], :int
290
+ attach_function :lldb_file_spec_get_filename, [:pointer], :string
291
+ attach_function :lldb_file_spec_get_directory, [:pointer], :string
292
+ attach_function :lldb_file_spec_get_path, %i[pointer pointer size_t], :uint32
293
+ attach_function :lldb_file_spec_set_filename, %i[pointer string], :void
294
+ attach_function :lldb_file_spec_set_directory, %i[pointer string], :void
295
+ attach_function :lldb_file_spec_list_create, [], :pointer
296
+ attach_function :lldb_file_spec_list_destroy, [:pointer], :void
297
+ attach_function :lldb_file_spec_list_is_valid, [:pointer], :int
298
+ attach_function :lldb_file_spec_list_get_size, [:pointer], :uint32
299
+ attach_function :lldb_file_spec_list_append, %i[pointer pointer], :void
300
+ attach_function :lldb_file_spec_list_append_if_unique, %i[pointer pointer], :int
301
+ attach_function :lldb_file_spec_list_clear, [:pointer], :void
302
+ attach_function :lldb_file_spec_list_get_file_spec_at_index, %i[pointer uint32], :pointer
303
+
304
+ # =========================================================================
305
+ # SBAddress and SBLineEntry
306
+ # =========================================================================
307
+ attach_function :lldb_address_create, [], :pointer
308
+ attach_function :lldb_address_create_from_load_address, %i[uint64 pointer], :pointer
309
+ attach_function :lldb_address_destroy, [:pointer], :void
310
+ attach_function :lldb_address_is_valid, [:pointer], :int
311
+ attach_function :lldb_address_get_file_address, [:pointer], :uint64
312
+ attach_function :lldb_address_get_load_address, %i[pointer pointer], :uint64
313
+ attach_function :lldb_address_get_offset, [:pointer], :uint64
314
+ attach_function :lldb_address_get_line_entry, [:pointer], :pointer
315
+ attach_function :lldb_line_entry_destroy, [:pointer], :void
316
+ attach_function :lldb_line_entry_is_valid, [:pointer], :int
317
+ attach_function :lldb_line_entry_get_start_address, [:pointer], :pointer
318
+ attach_function :lldb_line_entry_get_end_address, [:pointer], :pointer
319
+ attach_function :lldb_line_entry_get_file_spec, [:pointer], :pointer
320
+ attach_function :lldb_line_entry_get_line, [:pointer], :uint32
321
+ attach_function :lldb_line_entry_get_column, [:pointer], :uint32
125
322
 
126
323
  # =========================================================================
127
324
  # SBProcess
128
325
  # =========================================================================
129
326
  attach_function :lldb_process_destroy, [:pointer], :void
130
327
  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
328
+ attach_function :lldb_process_continue, %i[pointer pointer], :int, blocking: true
329
+ attach_function :lldb_process_stop, %i[pointer pointer], :int
330
+ attach_function :lldb_process_kill, %i[pointer pointer], :int
331
+ attach_function :lldb_process_detach, %i[pointer pointer], :int
332
+ attach_function :lldb_process_destroy_process, %i[pointer pointer], :int
333
+ attach_function :lldb_process_signal, %i[pointer int pointer], :int
137
334
  attach_function :lldb_process_get_state, [:pointer], :int
138
335
  attach_function :lldb_process_get_num_threads, [:pointer], :uint32
139
336
  attach_function :lldb_process_get_thread_at_index, %i[pointer uint32], :pointer
@@ -148,13 +345,14 @@ module LLDB
148
345
  attach_function :lldb_process_read_memory, %i[pointer uint64 pointer size_t pointer], :size_t
149
346
  attach_function :lldb_process_write_memory, %i[pointer uint64 pointer size_t pointer], :size_t
150
347
  attach_function :lldb_process_allocate_memory, %i[pointer size_t uint32 pointer], :uint64
151
- attach_function :lldb_process_deallocate_memory, %i[pointer uint64], :int
348
+ attach_function :lldb_process_deallocate_memory, %i[pointer uint64 pointer], :int
152
349
  attach_function :lldb_process_read_cstring_from_memory, %i[pointer uint64 pointer size_t pointer], :size_t
153
350
  attach_function :lldb_process_get_stdout, %i[pointer pointer size_t], :size_t
154
351
  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
352
+ attach_function :lldb_process_put_stdin, %i[pointer pointer size_t], :size_t
353
+ attach_function :lldb_process_send_async_interrupt, [:pointer], :void
354
+ attach_function :lldb_process_get_broadcaster, [:pointer], :pointer
355
+ attach_function :lldb_process_get_num_supported_hardware_watchpoints, %i[pointer pointer pointer], :int
158
356
  attach_function :lldb_process_get_unique_id, [:pointer], :uint32
159
357
  attach_function :lldb_process_get_memory_region_info, %i[pointer uint64 pointer], :pointer
160
358
 
@@ -175,11 +373,11 @@ module LLDB
175
373
  # =========================================================================
176
374
  attach_function :lldb_thread_destroy, [:pointer], :void
177
375
  attach_function :lldb_thread_is_valid, [:pointer], :int
178
- attach_function :lldb_thread_step_over, [:pointer], :int
179
- attach_function :lldb_thread_step_into, [:pointer], :int
180
- attach_function :lldb_thread_step_out, [:pointer], :int
181
- attach_function :lldb_thread_step_instruction, %i[pointer int], :int
182
- attach_function :lldb_thread_run_to_address, %i[pointer uint64], :int
376
+ attach_function :lldb_thread_step_over, %i[pointer int pointer], :int, blocking: true
377
+ attach_function :lldb_thread_step_into, %i[pointer string uint32 int pointer], :int, blocking: true
378
+ attach_function :lldb_thread_step_out, %i[pointer pointer], :int, blocking: true
379
+ attach_function :lldb_thread_step_instruction, %i[pointer int pointer], :int, blocking: true
380
+ attach_function :lldb_thread_run_to_address, %i[pointer uint64 pointer], :int, blocking: true
183
381
  attach_function :lldb_thread_get_num_frames, [:pointer], :uint32
184
382
  attach_function :lldb_thread_get_frame_at_index, %i[pointer uint32], :pointer
185
383
  attach_function :lldb_thread_get_selected_frame, [:pointer], :pointer
@@ -189,7 +387,7 @@ module LLDB
189
387
  attach_function :lldb_thread_get_name, [:pointer], :string
190
388
  attach_function :lldb_thread_get_queue_name, [:pointer], :string
191
389
  attach_function :lldb_thread_get_stop_reason, [:pointer], :int
192
- attach_function :lldb_thread_get_stop_description, %i[pointer size_t], :string
390
+ attach_function :lldb_thread_get_stop_description, %i[pointer pointer size_t], :size_t
193
391
  attach_function :lldb_thread_get_stop_reason_data_count, [:pointer], :uint64
194
392
  attach_function :lldb_thread_get_stop_reason_data_at_index, %i[pointer uint32], :uint64
195
393
  attach_function :lldb_thread_is_stopped, [:pointer], :int
@@ -207,6 +405,8 @@ module LLDB
207
405
  attach_function :lldb_frame_get_display_function_name, [:pointer], :string
208
406
  attach_function :lldb_frame_get_line, [:pointer], :uint32
209
407
  attach_function :lldb_frame_get_file_path, [:pointer], :string
408
+ attach_function :lldb_frame_get_file_spec, [:pointer], :pointer
409
+ attach_function :lldb_frame_get_line_entry, [:pointer], :pointer
210
410
  attach_function :lldb_frame_get_column, [:pointer], :uint32
211
411
  attach_function :lldb_frame_get_pc, [:pointer], :uint64
212
412
  attach_function :lldb_frame_set_pc, %i[pointer uint64], :int
@@ -214,9 +414,15 @@ module LLDB
214
414
  attach_function :lldb_frame_get_fp, [:pointer], :uint64
215
415
  attach_function :lldb_frame_find_variable, %i[pointer string], :pointer
216
416
  attach_function :lldb_frame_evaluate_expression, %i[pointer string], :pointer
417
+ attach_function :lldb_frame_evaluate_expression_with_options, %i[pointer string pointer], :pointer
217
418
  attach_function :lldb_frame_get_value_for_variable_path, %i[pointer string], :pointer
218
419
  attach_function :lldb_frame_get_frame_id, [:pointer], :uint32
219
420
  attach_function :lldb_frame_get_thread, [:pointer], :pointer
421
+ attach_function :lldb_frame_get_function, [:pointer], :pointer
422
+ attach_function :lldb_frame_get_symbol, [:pointer], :pointer
423
+ attach_function :lldb_frame_get_compile_unit, [:pointer], :pointer
424
+ attach_function :lldb_frame_get_block, [:pointer], :pointer
425
+ attach_function :lldb_frame_get_instruction_list, %i[pointer pointer], :pointer
220
426
  attach_function :lldb_frame_get_symbol_context, %i[pointer uint32], :pointer
221
427
  attach_function :lldb_frame_get_variables, %i[pointer int int int int], :pointer
222
428
  attach_function :lldb_frame_get_registers, [:pointer], :pointer
@@ -259,6 +465,7 @@ module LLDB
259
465
  attach_function :lldb_breakpoint_location_is_valid, [:pointer], :int
260
466
  attach_function :lldb_breakpoint_location_get_id, [:pointer], :int32
261
467
  attach_function :lldb_breakpoint_location_get_load_address, [:pointer], :uint64
468
+ attach_function :lldb_breakpoint_location_get_address, [:pointer], :pointer
262
469
  attach_function :lldb_breakpoint_location_is_enabled, [:pointer], :int
263
470
  attach_function :lldb_breakpoint_location_set_enabled, %i[pointer int], :void
264
471
  attach_function :lldb_breakpoint_location_get_hit_count, [:pointer], :uint32
@@ -281,8 +488,8 @@ module LLDB
281
488
  attach_function :lldb_value_get_num_children, [:pointer], :uint32
282
489
  attach_function :lldb_value_get_child_at_index, %i[pointer uint32], :pointer
283
490
  attach_function :lldb_value_get_child_member_with_name, %i[pointer string], :pointer
284
- attach_function :lldb_value_get_value_as_signed, [:pointer], :int64
285
- attach_function :lldb_value_get_value_as_unsigned, [:pointer], :uint64
491
+ attach_function :lldb_value_get_value_as_signed, %i[pointer pointer int64], :int64
492
+ attach_function :lldb_value_get_value_as_unsigned, %i[pointer pointer uint64], :uint64
286
493
  attach_function :lldb_value_get_byte_size, [:pointer], :uint64
287
494
  attach_function :lldb_value_might_have_children, [:pointer], :int
288
495
  attach_function :lldb_value_get_error, %i[pointer pointer], :int
@@ -318,6 +525,7 @@ module LLDB
318
525
  attach_function :lldb_error_fail, [:pointer], :int
319
526
  attach_function :lldb_error_get_cstring, [:pointer], :string
320
527
  attach_function :lldb_error_get_error, [:pointer], :uint32
528
+ attach_function :lldb_error_get_type, [:pointer], :int
321
529
  attach_function :lldb_error_clear, [:pointer], :void
322
530
  attach_function :lldb_error_set_error_string, %i[pointer string], :void
323
531
 
@@ -328,7 +536,69 @@ module LLDB
328
536
  attach_function :lldb_module_is_valid, [:pointer], :int
329
537
  attach_function :lldb_module_get_file_path, [:pointer], :string
330
538
  attach_function :lldb_module_get_platform_file_path, [:pointer], :string
539
+ attach_function :lldb_module_get_file, [:pointer], :pointer
540
+ attach_function :lldb_module_get_platform_file, [:pointer], :pointer
331
541
  attach_function :lldb_module_get_num_symbols, [:pointer], :uint32
542
+ attach_function :lldb_module_get_symbol_at_index, %i[pointer uint32], :pointer
543
+
544
+ # =========================================================================
545
+ # SBSymbol, SBFunction, SBCompileUnit, and SBBlock
546
+ # =========================================================================
547
+ attach_function :lldb_symbol_destroy, [:pointer], :void
548
+ attach_function :lldb_symbol_is_valid, [:pointer], :int
549
+ attach_function :lldb_symbol_get_name, [:pointer], :string
550
+ attach_function :lldb_symbol_get_display_name, [:pointer], :string
551
+ attach_function :lldb_symbol_get_mangled_name, [:pointer], :string
552
+ attach_function :lldb_symbol_get_base_name, [:pointer], :string
553
+ attach_function :lldb_symbol_get_start_address, [:pointer], :pointer
554
+ attach_function :lldb_symbol_get_end_address, [:pointer], :pointer
555
+ attach_function :lldb_symbol_get_value, [:pointer], :uint64
556
+ attach_function :lldb_symbol_get_size, [:pointer], :uint64
557
+ attach_function :lldb_symbol_get_prologue_byte_size, [:pointer], :uint32
558
+ attach_function :lldb_symbol_get_type, [:pointer], :int
559
+ attach_function :lldb_symbol_get_id, [:pointer], :uint32
560
+ attach_function :lldb_function_destroy, [:pointer], :void
561
+ attach_function :lldb_function_is_valid, [:pointer], :int
562
+ attach_function :lldb_function_get_name, [:pointer], :string
563
+ attach_function :lldb_function_get_display_name, [:pointer], :string
564
+ attach_function :lldb_function_get_mangled_name, [:pointer], :string
565
+ attach_function :lldb_function_get_base_name, [:pointer], :string
566
+ attach_function :lldb_function_get_start_address, [:pointer], :pointer
567
+ attach_function :lldb_function_get_end_address, [:pointer], :pointer
568
+ attach_function :lldb_function_get_prologue_byte_size, [:pointer], :uint32
569
+ attach_function :lldb_function_get_type, [:pointer], :pointer
570
+ attach_function :lldb_function_get_block, [:pointer], :pointer
571
+ attach_function :lldb_function_is_optimized, [:pointer], :int
572
+ attach_function :lldb_function_get_language, [:pointer], :int
573
+ attach_function :lldb_compile_unit_destroy, [:pointer], :void
574
+ attach_function :lldb_compile_unit_is_valid, [:pointer], :int
575
+ attach_function :lldb_compile_unit_get_file_spec, [:pointer], :pointer
576
+ attach_function :lldb_compile_unit_get_num_line_entries, [:pointer], :uint32
577
+ attach_function :lldb_compile_unit_get_line_entry_at_index, %i[pointer uint32], :pointer
578
+ attach_function :lldb_block_destroy, [:pointer], :void
579
+ attach_function :lldb_block_is_valid, [:pointer], :int
580
+ attach_function :lldb_block_get_inlined_name, [:pointer], :string
581
+ attach_function :lldb_block_get_inlined_call_site_file, [:pointer], :pointer
582
+ attach_function :lldb_block_get_inlined_call_site_line, [:pointer], :uint32
583
+ attach_function :lldb_block_get_inlined_call_site_column, [:pointer], :uint32
584
+ attach_function :lldb_block_get_parent, [:pointer], :pointer
585
+ attach_function :lldb_block_get_sibling, [:pointer], :pointer
586
+ attach_function :lldb_block_get_first_child, [:pointer], :pointer
587
+ attach_function :lldb_block_get_num_ranges, [:pointer], :uint32
588
+ attach_function :lldb_block_get_range_start_address, %i[pointer uint32], :pointer
589
+ attach_function :lldb_block_get_range_end_address, %i[pointer uint32], :pointer
590
+ attach_function :lldb_instruction_list_destroy, [:pointer], :void
591
+ attach_function :lldb_instruction_list_is_valid, [:pointer], :int
592
+ attach_function :lldb_instruction_list_get_size, [:pointer], :uint64
593
+ attach_function :lldb_instruction_list_get_instruction_at_index, %i[pointer uint32], :pointer
594
+ attach_function :lldb_instruction_destroy, [:pointer], :void
595
+ attach_function :lldb_instruction_is_valid, [:pointer], :int
596
+ attach_function :lldb_instruction_get_address, [:pointer], :pointer
597
+ attach_function :lldb_instruction_get_mnemonic, %i[pointer pointer], :string
598
+ attach_function :lldb_instruction_get_operands, %i[pointer pointer], :string
599
+ attach_function :lldb_instruction_get_comment, %i[pointer pointer], :string
600
+ attach_function :lldb_instruction_get_byte_size, [:pointer], :uint32
601
+ attach_function :lldb_instruction_get_bytes, %i[pointer pointer pointer uint32], :uint32
332
602
 
333
603
  # =========================================================================
334
604
  # SBSymbolContext
@@ -364,7 +634,17 @@ module LLDB
364
634
  attach_function :lldb_type_get_num_fields, [:pointer], :uint32
365
635
  attach_function :lldb_type_get_num_direct_base_classes, [:pointer], :uint32
366
636
  attach_function :lldb_type_get_num_virtual_base_classes, [:pointer], :uint32
637
+ attach_function :lldb_type_get_field_at_index, %i[pointer uint32], :pointer
638
+ attach_function :lldb_type_get_direct_base_class_at_index, %i[pointer uint32], :pointer
639
+ attach_function :lldb_type_get_virtual_base_class_at_index, %i[pointer uint32], :pointer
367
640
  attach_function :lldb_type_get_basic_type, [:pointer], :int
641
+ attach_function :lldb_type_member_destroy, [:pointer], :void
642
+ attach_function :lldb_type_member_is_valid, [:pointer], :int
643
+ attach_function :lldb_type_member_get_name, [:pointer], :string
644
+ attach_function :lldb_type_member_get_type, [:pointer], :pointer
645
+ attach_function :lldb_type_member_get_offset_in_bytes, [:pointer], :uint64
646
+ attach_function :lldb_type_member_get_offset_in_bits, [:pointer], :uint64
647
+ attach_function :lldb_type_member_get_bitfield_size_in_bits, [:pointer], :uint32
368
648
 
369
649
  # =========================================================================
370
650
  # SBWatchpoint
@@ -381,15 +661,15 @@ module LLDB
381
661
  attach_function :lldb_watchpoint_set_condition, %i[pointer string], :void
382
662
  attach_function :lldb_watchpoint_get_watch_address, [:pointer], :uint64
383
663
  attach_function :lldb_watchpoint_get_watch_size, [:pointer], :size_t
384
- attach_function :lldb_watchpoint_is_watching_reads, [:pointer], :int
385
- attach_function :lldb_watchpoint_is_watching_writes, [:pointer], :int
664
+ attach_function :lldb_watchpoint_is_watching_reads, %i[pointer pointer], :int
665
+ attach_function :lldb_watchpoint_is_watching_writes, %i[pointer pointer], :int
386
666
 
387
667
  # =========================================================================
388
668
  # SBCommandInterpreter
389
669
  # =========================================================================
390
670
  attach_function :lldb_command_interpreter_destroy, [:pointer], :void
391
671
  attach_function :lldb_command_interpreter_is_valid, [:pointer], :int
392
- attach_function :lldb_command_interpreter_handle_command, %i[pointer string pointer int], :int
672
+ attach_function :lldb_command_interpreter_handle_command, %i[pointer string pointer int], :int, blocking: true
393
673
  attach_function :lldb_command_interpreter_command_exists, %i[pointer string], :int
394
674
  attach_function :lldb_command_interpreter_alias_exists, %i[pointer string], :int
395
675
 
@@ -401,7 +681,9 @@ module LLDB
401
681
  attach_function :lldb_command_return_object_is_valid, [:pointer], :int
402
682
  attach_function :lldb_command_return_object_get_output, [:pointer], :string
403
683
  attach_function :lldb_command_return_object_get_error, [:pointer], :string
684
+ attach_function :lldb_command_return_object_get_status, [:pointer], :int
404
685
  attach_function :lldb_command_return_object_succeeded, [:pointer], :int
686
+ attach_function :lldb_command_return_object_has_result, [:pointer], :int
405
687
  attach_function :lldb_command_return_object_clear, [:pointer], :void
406
688
  end
407
689
  end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rbs_inline: enabled
4
+
5
+ module LLDB
6
+ class FileSpec
7
+ prepend NativeLifecycle
8
+
9
+ # @rbs path: String?
10
+ # @rbs resolve: bool
11
+ # @rbs context: Context?
12
+ # @rbs pointer: FFI::Pointer?
13
+ # @rbs return: void
14
+ def initialize(path = nil, resolve: false, context: nil, pointer: nil)
15
+ NativeStringArray.validate!(path) if path
16
+ ptr = pointer || FFIBindings.lldb_file_spec_create(path, resolve ? 1 : 0)
17
+ initialize_native_object(
18
+ ptr,
19
+ release: ->(released) { FFIBindings.lldb_file_spec_destroy(released) },
20
+ context: context
21
+ )
22
+ end
23
+
24
+ # @rbs ptr: FFI::Pointer
25
+ # @rbs context: Context?
26
+ # @rbs return: FileSpec
27
+ def self.from_ptr(ptr, context: nil)
28
+ new(context: context, pointer: ptr)
29
+ end
30
+
31
+ # @rbs return: bool
32
+ def valid?
33
+ !@ptr.null? && FFIBindings.lldb_file_spec_is_valid(@ptr) != 0
34
+ end
35
+
36
+ # @rbs return: bool
37
+ def exists?
38
+ valid? && FFIBindings.lldb_file_spec_exists(@ptr) != 0
39
+ end
40
+
41
+ # @rbs return: String?
42
+ def filename
43
+ return nil unless valid?
44
+
45
+ FFIBindings.lldb_file_spec_get_filename(@ptr)
46
+ end
47
+
48
+ # @rbs return: String?
49
+ def directory
50
+ return nil unless valid?
51
+
52
+ FFIBindings.lldb_file_spec_get_directory(@ptr)
53
+ end
54
+
55
+ # @rbs return: String
56
+ def path
57
+ return '' unless valid?
58
+
59
+ NativeBuffer.read_c_string do |buffer, length|
60
+ FFIBindings.lldb_file_spec_get_path(@ptr, buffer, length)
61
+ end
62
+ end
63
+
64
+ # @rbs value: String
65
+ # @rbs return: void
66
+ def filename=(value)
67
+ ensure_open!
68
+ NativeStringArray.validate!(value)
69
+ FFIBindings.lldb_file_spec_set_filename(@ptr, value)
70
+ end
71
+
72
+ # @rbs value: String
73
+ # @rbs return: void
74
+ def directory=(value)
75
+ ensure_open!
76
+ NativeStringArray.validate!(value)
77
+ FFIBindings.lldb_file_spec_set_directory(@ptr, value)
78
+ end
79
+
80
+ # @rbs return: String
81
+ def to_s
82
+ path
83
+ end
84
+
85
+ # @rbs return: FFI::Pointer
86
+ def to_ptr
87
+ @ptr
88
+ end
89
+ end
90
+ end