Class: LLDB::Instruction
- Inherits:
-
Object
- Object
- LLDB::Instruction
- Includes:
- NativeLifecycle
- Defined in:
- lib/lldb/instruction.rb
Instance Method Summary collapse
- #address ⇒ Object
- #byte_size ⇒ Object
- #bytes ⇒ Object
- #comment ⇒ Object
-
#initialize(ptr, target: nil, context: nil) ⇒ Instruction
constructor
A new instance of Instruction.
- #mnemonic ⇒ Object
- #operands ⇒ Object
- #to_ptr ⇒ Object
- #valid? ⇒ Boolean
Methods included from NativeLifecycle
#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object
Constructor Details
#initialize(ptr, target: nil, context: nil) ⇒ Instruction
Returns a new instance of Instruction.
12 13 14 15 16 17 18 19 |
# File 'lib/lldb/instruction.rb', line 12 def initialize(ptr, target: nil, context: nil) @target = target initialize_native_object( ptr, release: ->(released) { FFIBindings.lldb_instruction_destroy(released) }, context: context || target&.context ) end |
Instance Method Details
#address ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/lldb/instruction.rb', line 27 def address return nil unless valid? ptr = FFIBindings.lldb_instruction_get_address(@ptr) return nil if ptr.nil? || ptr.null? Address.from_ptr(ptr, target: @target, context: context) end |
#byte_size ⇒ Object
58 59 60 61 62 |
# File 'lib/lldb/instruction.rb', line 58 def byte_size return 0 unless valid? FFIBindings.lldb_instruction_get_byte_size(@ptr) end |
#bytes ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/lldb/instruction.rb', line 65 def bytes return ''.b unless valid? && @target length = byte_size return ''.b if length.zero? buffer = FFI::MemoryPointer.new(:uint8, length) written = FFIBindings.lldb_instruction_get_bytes( @ptr, @target.to_ptr, buffer, length ) buffer.get_bytes(0, [written, length].min).b end |
#comment ⇒ Object
51 52 53 54 55 |
# File 'lib/lldb/instruction.rb', line 51 def comment return nil unless valid? && @target FFIBindings.lldb_instruction_get_comment(@ptr, @target.to_ptr) end |
#mnemonic ⇒ Object
37 38 39 40 41 |
# File 'lib/lldb/instruction.rb', line 37 def mnemonic return nil unless valid? && @target FFIBindings.lldb_instruction_get_mnemonic(@ptr, @target.to_ptr) end |
#operands ⇒ Object
44 45 46 47 48 |
# File 'lib/lldb/instruction.rb', line 44 def operands return nil unless valid? && @target FFIBindings.lldb_instruction_get_operands(@ptr, @target.to_ptr) end |
#to_ptr ⇒ Object
79 80 81 |
# File 'lib/lldb/instruction.rb', line 79 def to_ptr @ptr end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/lldb/instruction.rb', line 22 def valid? !@ptr.null? && FFIBindings.lldb_instruction_is_valid(@ptr) != 0 end |