Class: LLDB::Target
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#address_byte_size ⇒ Object
-
#attach(pid:) ⇒ Object
-
#attach_with_info(attach_info) ⇒ Object
-
#attach_with_name(name, wait_for: false) ⇒ Object
-
#breakpoint_at_index(index) ⇒ Object
-
#breakpoint_create_by_address(address) ⇒ Object
-
#breakpoint_create_by_location(file, line) ⇒ Object
-
#breakpoint_create_by_name(symbol_name, module_name: nil) ⇒ Object
-
#breakpoint_create_by_regex(regex, module_name: nil) ⇒ Object
-
#breakpoint_create_by_source_regex(regex, source_file: nil) ⇒ Object
-
#breakpoints ⇒ Object
-
#delete_all_breakpoints ⇒ Object
-
#delete_all_watchpoints ⇒ Object
-
#delete_breakpoint(breakpoint_id) ⇒ Object
-
#delete_watchpoint(watchpoint_id) ⇒ Object
-
#disable_all_breakpoints ⇒ Object
-
#enable_all_breakpoints ⇒ Object
-
#evaluate_expression(expression, options: nil) ⇒ Object
-
#executable_file ⇒ Object
-
#executable_path ⇒ Object
-
#find_breakpoint_by_id(id) ⇒ Object
-
#find_watchpoint_by_id(id) ⇒ Object
-
#initialize(ptr, debugger:, context: debugger.context) ⇒ Target
constructor
A new instance of Target.
-
#launch(args: nil, env: nil, working_dir: nil, launch_flags: nil) ⇒ Object
-
#launch_with_info(launch_info) ⇒ Object
-
#module_at_index(index) ⇒ Object
-
#modules ⇒ Object
-
#num_breakpoints ⇒ Object
-
#num_modules ⇒ Object
-
#num_watchpoints ⇒ Object
-
#process ⇒ Object
-
#read_memory(address, size) ⇒ Object
-
#to_ptr ⇒ Object
-
#triple ⇒ Object
-
#valid? ⇒ Boolean
-
#watch_address(address, size, read: false, write: true) ⇒ Object
-
#watchpoint_at_index(index) ⇒ Object
-
#watchpoints ⇒ Object
#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object
Constructor Details
#initialize(ptr, debugger:, context: debugger.context) ⇒ Target
Returns a new instance of Target.
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/lldb/target.rb', line 15
def initialize(ptr, debugger:, context: debugger.context)
@debugger = debugger
@breakpoints = [] @watchpoints = [] @process = nil initialize_native_object(
ptr,
release: ->(released) { FFIBindings.lldb_target_destroy(released) },
context: context
)
end
|
Instance Attribute Details
#debugger ⇒ Object
10
11
12
|
# File 'lib/lldb/target.rb', line 10
def debugger
@debugger
end
|
Instance Method Details
#address_byte_size ⇒ Object
#attach_with_info(attach_info) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/lldb/target.rb', line 84
def attach_with_info(attach_info)
raise InvalidObjectError, 'Target is not valid' unless valid?
raise ArgumentError, 'attach_info is required' unless attach_info.is_a?(AttachInfo)
error = Error.new
process_ptr = FFIBindings.lldb_target_attach_with_info(@ptr, attach_info.to_ptr, error.to_ptr)
error.raise_if_error!('target.attach')
raise AttachError, 'Failed to attach using attach info' if process_ptr.nil? || process_ptr.null?
@process = Process.new(process_ptr, target: self, context: context)
end
|
#attach_with_name(name, wait_for: false) ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/lldb/target.rb', line 240
def attach_with_name(name, wait_for: false)
raise InvalidObjectError, 'Target is not valid' unless valid?
error = Error.new
process_ptr = FFIBindings.lldb_target_attach_to_process_with_name(@ptr, name, wait_for ? 1 : 0, error.to_ptr)
error.raise_if_error!
raise AttachError, "Failed to attach to process '#{name}'" if process_ptr.nil? || process_ptr.null?
@process = Process.new(process_ptr, target: self, context: context)
end
|
#breakpoint_at_index(index) ⇒ Object
#breakpoint_create_by_address(address) ⇒ Object
#breakpoint_create_by_location(file, line) ⇒ Object
#breakpoint_create_by_name(symbol_name, module_name: nil) ⇒ Object
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/lldb/target.rb', line 100
def breakpoint_create_by_name(symbol_name, module_name: nil)
raise InvalidObjectError, 'Target is not valid' unless valid?
bp_ptr = FFIBindings.lldb_target_breakpoint_create_by_name(@ptr, symbol_name, module_name)
raise BreakpointError, "Failed to create breakpoint for '#{symbol_name}'" if bp_ptr.nil? || bp_ptr.null?
bp = Breakpoint.new(bp_ptr, target: self, context: context)
@breakpoints << bp
bp
end
|
#breakpoint_create_by_regex(regex, module_name: nil) ⇒ Object
#breakpoint_create_by_source_regex(regex, source_file: nil) ⇒ Object
#breakpoints ⇒ Object
183
184
185
|
# File 'lib/lldb/target.rb', line 183
def breakpoints
(0...num_breakpoints).map { |i| breakpoint_at_index(i) }.compact
end
|
#delete_all_breakpoints ⇒ Object
#delete_all_watchpoints ⇒ Object
#delete_breakpoint(breakpoint_id) ⇒ Object
145
146
147
148
149
150
151
|
# File 'lib/lldb/target.rb', line 145
def delete_breakpoint(breakpoint_id)
raise InvalidObjectError, 'Target is not valid' unless valid?
result = FFIBindings.lldb_target_delete_breakpoint(@ptr, breakpoint_id)
@breakpoints.reject! { |bp| bp.id == breakpoint_id } if result != 0
result != 0
end
|
#delete_watchpoint(watchpoint_id) ⇒ Object
376
377
378
379
380
381
382
|
# File 'lib/lldb/target.rb', line 376
def delete_watchpoint(watchpoint_id)
raise InvalidObjectError, 'Target is not valid' unless valid?
result = FFIBindings.lldb_target_delete_watchpoint(@ptr, watchpoint_id)
@watchpoints.reject! { |wp| wp.id == watchpoint_id } if result != 0
result != 0
end
|
#disable_all_breakpoints ⇒ Object
#enable_all_breakpoints ⇒ Object
#evaluate_expression(expression, options: nil) ⇒ Object
#executable_file ⇒ Object
#executable_path ⇒ Object
198
199
200
201
202
|
# File 'lib/lldb/target.rb', line 198
def executable_path
raise InvalidObjectError, 'Target is not valid' unless valid?
executable_file&.path
end
|
#find_breakpoint_by_id(id) ⇒ Object
#find_watchpoint_by_id(id) ⇒ Object
#launch(args: nil, env: nil, working_dir: nil, launch_flags: nil) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/lldb/target.rb', line 43
def launch(args: nil, env: nil, working_dir: nil, launch_flags: nil)
raise InvalidObjectError, 'Target is not valid' unless valid?
launch_info = LaunchInfo.new(args, context: context)
launch_info.launch_flags = launch_flags unless launch_flags.nil?
launch_info.working_directory = working_dir if working_dir
launch_info.set_environment(env) if env
launch_with_info(launch_info)
end
|
#launch_with_info(launch_info) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/lldb/target.rb', line 55
def launch_with_info(launch_info)
raise InvalidObjectError, 'Target is not valid' unless valid?
raise ArgumentError, 'launch_info is required' unless launch_info
error = Error.new
process_ptr = FFIBindings.lldb_target_launch(@ptr, launch_info.to_ptr, error.to_ptr)
error.raise_if_error!('target.launch')
raise LaunchError, 'Failed to launch process' if process_ptr.nil? || process_ptr.null?
@process = Process.new(process_ptr, target: self, context: context)
end
|
#module_at_index(index) ⇒ Object
#modules ⇒ Object
233
234
235
|
# File 'lib/lldb/target.rb', line 233
def modules
(0...num_modules).map { |i| module_at_index(i) }.compact
end
|
#num_breakpoints ⇒ Object
#num_watchpoints ⇒ Object
#process ⇒ Object
188
189
190
191
192
193
194
195
|
# File 'lib/lldb/target.rb', line 188
def process
raise InvalidObjectError, 'Target is not valid' unless valid?
process_ptr = FFIBindings.lldb_target_get_process(@ptr)
return nil if process_ptr.nil? || process_ptr.null?
Process.new(process_ptr, target: self, context: context)
end
|
#read_memory(address, size) ⇒ Object
330
331
332
333
334
335
336
337
338
339
|
# File 'lib/lldb/target.rb', line 330
def read_memory(address, size)
raise InvalidObjectError, 'Target is not valid' unless valid?
buffer = FFI::MemoryPointer.new(:uint8, size)
error = Error.new
bytes_read = FFIBindings.lldb_target_read_memory(@ptr, address, buffer, size, error.to_ptr)
error.raise_if_error!
buffer.read_string(bytes_read)
end
|
#to_ptr ⇒ Object
428
429
430
|
# File 'lib/lldb/target.rb', line 428
def to_ptr
@ptr
end
|
#watch_address(address, size, read: false, write: true) ⇒ Object
360
361
362
363
364
365
366
367
368
369
370
371
372
|
# File 'lib/lldb/target.rb', line 360
def watch_address(address, size, read: false, write: true)
raise InvalidObjectError, 'Target is not valid' unless valid?
error = Error.new
wp_ptr = FFIBindings.lldb_target_watch_address(@ptr, address, size, read ? 1 : 0, write ? 1 : 0, error.to_ptr)
error.raise_if_error!
raise LLDBError, "Failed to create watchpoint at address 0x#{address.to_s(16)}" if wp_ptr.nil? || wp_ptr.null?
wp = Watchpoint.new(wp_ptr, target: self, context: context)
@watchpoints << wp
wp
end
|
#watchpoint_at_index(index) ⇒ Object
#watchpoints ⇒ Object
423
424
425
|
# File 'lib/lldb/target.rb', line 423
def watchpoints
(0...num_watchpoints).map { |i| watchpoint_at_index(i) }.compact
end
|