Class: LLDB::CompileUnit

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

Instance Method Summary collapse

Methods included from NativeLifecycle

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

Constructor Details

#initialize(ptr, target: nil, context: nil) ⇒ CompileUnit

Returns a new instance of CompileUnit.

RBS:

  • target: Target?

  • context: Context?

  • return: void



12
13
14
15
16
17
18
19
# File 'lib/lldb/compile_unit.rb', line 12

def initialize(ptr, target: nil, context: nil)
  @target = target
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_compile_unit_destroy(released) },
    context: context || target&.context
  )
end

Instance Method Details

#file_specObject

RBS:

  • return: FileSpec?



27
28
29
30
31
32
33
34
# File 'lib/lldb/compile_unit.rb', line 27

def file_spec
  return nil unless valid?

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

  FileSpec.from_ptr(ptr, context: context)
end

#line_entriesObject

RBS:

  • return: Array[LineEntry]



55
56
57
# File 'lib/lldb/compile_unit.rb', line 55

def line_entries
  (0...num_line_entries).map { |index| line_entry_at_index(index) }.compact
end

#line_entry_at_index(index) ⇒ Object

RBS:

  • index: Integer

  • return: LineEntry?



45
46
47
48
49
50
51
52
# File 'lib/lldb/compile_unit.rb', line 45

def line_entry_at_index(index)
  return nil unless valid?

  ptr = FFIBindings.lldb_compile_unit_get_line_entry_at_index(@ptr, index)
  return nil if ptr.nil? || ptr.null?

  LineEntry.new(ptr, target: @target, context: context)
end

#num_line_entriesObject

RBS:

  • return: Integer



37
38
39
40
41
# File 'lib/lldb/compile_unit.rb', line 37

def num_line_entries
  return 0 unless valid?

  FFIBindings.lldb_compile_unit_get_num_line_entries(@ptr)
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



60
61
62
# File 'lib/lldb/compile_unit.rb', line 60

def to_ptr
  @ptr
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


22
23
24
# File 'lib/lldb/compile_unit.rb', line 22

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