Class: LLDB::Frame

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/frame.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NativeLifecycle

#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object

Constructor Details

#initialize(ptr, thread:, context: thread.context) ⇒ Frame

Returns a new instance of Frame.

RBS:

  • ptr: FFI::Pointer

  • thread: Thread

  • return: void



15
16
17
18
19
20
21
22
# File 'lib/lldb/frame.rb', line 15

def initialize(ptr, thread:, context: thread.context)
  @thread = thread
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_frame_destroy(released) },
    context: context
  )
end

Instance Attribute Details

#threadObject (readonly)

RBS:

  • return: Thread



10
11
12
# File 'lib/lldb/frame.rb', line 10

def thread
  @thread
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



26
27
28
# File 'lib/lldb/frame.rb', line 26

def self.release(ptr)
  ->(_id) { FFIBindings.lldb_frame_destroy(ptr) unless ptr.null? }
end

Instance Method Details

#blockObject

RBS:

  • return: Block?

Raises:



115
116
117
118
119
120
121
122
# File 'lib/lldb/frame.rb', line 115

def block
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  block_ptr = FFIBindings.lldb_frame_get_block(@ptr)
  return nil if block_ptr.nil? || block_ptr.null?

  Block.new(block_ptr, target: @thread.process.target, context: context)
end

#columnObject

RBS:

  • return: Integer



125
126
127
128
129
# File 'lib/lldb/frame.rb', line 125

def column
  return 0 unless valid?

  FFIBindings.lldb_frame_get_column(@ptr)
end

#compile_unitObject

RBS:

  • return: CompileUnit?

Raises:



105
106
107
108
109
110
111
112
# File 'lib/lldb/frame.rb', line 105

def compile_unit
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  unit_ptr = FFIBindings.lldb_frame_get_compile_unit(@ptr)
  return nil if unit_ptr.nil? || unit_ptr.null?

  CompileUnit.new(unit_ptr, target: @thread.process.target, context: context)
end

#disassembleObject

RBS:

  • return: String?

Raises:



275
276
277
278
279
# File 'lib/lldb/frame.rb', line 275

def disassemble
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  FFIBindings.lldb_frame_disassemble(@ptr)
end

#display_function_nameObject

RBS:

  • return: String?

Raises:



43
44
45
46
47
# File 'lib/lldb/frame.rb', line 43

def display_function_name
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  FFIBindings.lldb_frame_get_display_function_name(@ptr)
end

#evaluate_expression(expression, options: nil) ⇒ Object

RBS:

  • expression: String

  • options: ExpressionOptions?

  • return: Value?

Raises:



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/lldb/frame.rb', line 176

def evaluate_expression(expression, options: nil)
  raise InvalidObjectError, 'Frame is not valid' unless valid?
  APISupport.require_method!(:lldb_frame_evaluate_expression, 'evaluate_expression')

  value_ptr = if options
                unless options.is_a?(ExpressionOptions)
                  raise ArgumentError, 'options must be an ExpressionOptions'
                end

                FFIBindings.lldb_frame_evaluate_expression_with_options(
                  @ptr, expression, options.to_ptr
                )
              else
                FFIBindings.lldb_frame_evaluate_expression(@ptr, expression)
              end
  return nil if value_ptr.nil? || value_ptr.null?

  Value.new(value_ptr, parent: self, context: context)
end

#file_pathObject

RBS:

  • return: String?

Raises:



57
58
59
60
61
# File 'lib/lldb/frame.rb', line 57

def file_path
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  file_spec&.path
end

#file_specObject

RBS:

  • return: FileSpec?

Raises:



64
65
66
67
68
69
70
71
# File 'lib/lldb/frame.rb', line 64

def file_spec
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  file_ptr = FFIBindings.lldb_frame_get_file_spec(@ptr)
  return nil if file_ptr.nil? || file_ptr.null?

  FileSpec.from_ptr(file_ptr, context: context)
end

#find_variable(name) ⇒ Object

RBS:

  • name: String

  • return: Value?

Raises:



163
164
165
166
167
168
169
170
171
# File 'lib/lldb/frame.rb', line 163

def find_variable(name)
  raise InvalidObjectError, 'Frame is not valid' unless valid?
  APISupport.require_method!(:lldb_frame_find_variable, 'find_variable')

  value_ptr = FFIBindings.lldb_frame_find_variable(@ptr, name)
  return nil if value_ptr.nil? || value_ptr.null?

  Value.new(value_ptr, parent: self, context: context)
end

#fpObject

RBS:

  • return: Integer



146
147
148
149
150
# File 'lib/lldb/frame.rb', line 146

def fp
  return INVALID_ADDRESS unless valid?

  FFIBindings.lldb_frame_get_fp(@ptr)
end

#frame_idObject Also known as: id

RBS:

  • return: Integer



153
154
155
156
157
# File 'lib/lldb/frame.rb', line 153

def frame_id
  return 0 unless valid?

  FFIBindings.lldb_frame_get_frame_id(@ptr)
end

#functionObject

RBS:

  • return: Function?

Raises:



85
86
87
88
89
90
91
92
# File 'lib/lldb/frame.rb', line 85

def function
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  function_ptr = FFIBindings.lldb_frame_get_function(@ptr)
  return nil if function_ptr.nil? || function_ptr.null?

  Function.new(function_ptr, target: @thread.process.target, context: context)
end

#function_nameObject

RBS:

  • return: String?

Raises:



36
37
38
39
40
# File 'lib/lldb/frame.rb', line 36

def function_name
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  FFIBindings.lldb_frame_get_function_name(@ptr)
end

#get_moduleObject

RBS:

  • return: Module?

Raises:



297
298
299
300
301
302
303
304
# File 'lib/lldb/frame.rb', line 297

def get_module
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  mod_ptr = FFIBindings.lldb_frame_get_module(@ptr)
  return nil if mod_ptr.nil? || mod_ptr.null?

  Module.new(mod_ptr, target: @thread.process.target, context: context)
end

#get_registersObject

RBS:

  • return: ValueList

Raises:



257
258
259
260
261
262
263
264
265
# File 'lib/lldb/frame.rb', line 257

def get_registers
  raise InvalidObjectError, 'Frame is not valid' unless valid?
  APISupport.require_method!(:lldb_frame_get_registers, 'get_registers')

  list_ptr = FFIBindings.lldb_frame_get_registers(@ptr)
  raise LLDBError, 'Failed to get registers' if list_ptr.nil? || list_ptr.null?

  ValueList.new(list_ptr, parent: self, context: context)
end

#get_threadObject

RBS:

  • return: Thread?

Raises:



307
308
309
310
311
312
313
314
# File 'lib/lldb/frame.rb', line 307

def get_thread
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  thread_ptr = FFIBindings.lldb_frame_get_thread(@ptr)
  return nil if thread_ptr.nil? || thread_ptr.null?

  Thread.new(thread_ptr, process: @thread.process, context: context)
end

#get_value_for_variable_path(path) ⇒ Object

RBS:

  • path: String

  • return: Value?

Raises:



198
199
200
201
202
203
204
205
# File 'lib/lldb/frame.rb', line 198

def get_value_for_variable_path(path)
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  value_ptr = FFIBindings.lldb_frame_get_value_for_variable_path(@ptr, path)
  return nil if value_ptr.nil? || value_ptr.null?

  Value.new(value_ptr, parent: self, context: context)
end

#get_variables(arguments: true, locals: true, statics: true, in_scope_only: true) ⇒ Object

RBS:

  • arguments: bool

  • locals: bool

  • statics: bool

  • in_scope_only: bool

  • return: ValueList

Raises:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/lldb/frame.rb', line 241

def get_variables(arguments: true, locals: true, statics: true, in_scope_only: true)
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  list_ptr = FFIBindings.lldb_frame_get_variables(
    @ptr,
    arguments ? 1 : 0,
    locals ? 1 : 0,
    statics ? 1 : 0,
    in_scope_only ? 1 : 0
  )
  raise LLDBError, 'Failed to get variables' if list_ptr.nil? || list_ptr.null?

  ValueList.new(list_ptr, parent: self, context: context)
end

#inlined?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


268
269
270
271
272
# File 'lib/lldb/frame.rb', line 268

def inlined?
  return false unless valid?

  FFIBindings.lldb_frame_is_inlined(@ptr) != 0
end

#instruction_listObject Also known as: instructions

RBS:

  • return: InstructionList?

Raises:



282
283
284
285
286
287
288
289
290
291
292
# File 'lib/lldb/frame.rb', line 282

def instruction_list
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  target = @thread.process.target
  return nil unless target

  list_ptr = FFIBindings.lldb_frame_get_instruction_list(@ptr, target.to_ptr)
  return nil if list_ptr.nil? || list_ptr.null?

  InstructionList.new(list_ptr, target: target, context: context)
end

#lineObject

RBS:

  • return: Integer



50
51
52
53
54
# File 'lib/lldb/frame.rb', line 50

def line
  return 0 unless valid?

  FFIBindings.lldb_frame_get_line(@ptr)
end

#line_entryObject

RBS:

  • return: LineEntry?

Raises:



74
75
76
77
78
79
80
81
82
# File 'lib/lldb/frame.rb', line 74

def line_entry
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  line_ptr = FFIBindings.lldb_frame_get_line_entry(@ptr)
  return nil if line_ptr.nil? || line_ptr.null?

  target = @thread.process.target
  LineEntry.new(line_ptr, target: target, context: context)
end

#locationObject

RBS:

  • return: String



219
220
221
# File 'lib/lldb/frame.rb', line 219

def location
  "#{file_path || '?'}:#{line}"
end

#pcObject

RBS:

  • return: Integer



132
133
134
135
136
# File 'lib/lldb/frame.rb', line 132

def pc
  return INVALID_ADDRESS unless valid?

  FFIBindings.lldb_frame_get_pc(@ptr)
end

#pc=(value) ⇒ Object

RBS:

  • value: Integer

  • return: bool

Raises:



230
231
232
233
234
# File 'lib/lldb/frame.rb', line 230

def pc=(value)
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  FFIBindings.lldb_frame_set_pc(@ptr, value) != 0
end

#spObject

RBS:

  • return: Integer



139
140
141
142
143
# File 'lib/lldb/frame.rb', line 139

def sp
  return INVALID_ADDRESS unless valid?

  FFIBindings.lldb_frame_get_sp(@ptr)
end

#symbolObject

RBS:

  • return: Symbol?

Raises:



95
96
97
98
99
100
101
102
# File 'lib/lldb/frame.rb', line 95

def symbol
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  symbol_ptr = FFIBindings.lldb_frame_get_symbol(@ptr)
  return nil if symbol_ptr.nil? || symbol_ptr.null?

  Symbol.new(symbol_ptr, target: @thread.process.target, context: context)
end

#symbol_context(scope = SymbolContextItem::EVERYTHING) ⇒ Object

RBS:

  • scope: Integer

  • return: SymbolContext?

Raises:



209
210
211
212
213
214
215
216
# File 'lib/lldb/frame.rb', line 209

def symbol_context(scope = SymbolContextItem::EVERYTHING)
  raise InvalidObjectError, 'Frame is not valid' unless valid?

  ctx_ptr = FFIBindings.lldb_frame_get_symbol_context(@ptr, scope)
  return nil if ctx_ptr.nil? || ctx_ptr.null?

  SymbolContext.new(ctx_ptr, parent: self, context: context)
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



317
318
319
# File 'lib/lldb/frame.rb', line 317

def to_ptr
  @ptr
end

#to_sObject

RBS:

  • return: String



224
225
226
# File 'lib/lldb/frame.rb', line 224

def to_s
  "#{display_function_name || function_name || '?'} at #{location}"
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


31
32
33
# File 'lib/lldb/frame.rb', line 31

def valid?
  !@ptr.null? && FFIBindings.lldb_frame_is_valid(@ptr) != 0
end