Class: LLDB::Module

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/module.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, target:, context: target&.context) ⇒ Module

Returns a new instance of Module.

RBS:

  • ptr: FFI::Pointer

  • target: Target?

  • return: void



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

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

Instance Attribute Details

#targetObject (readonly)

RBS:

  • return: Target?



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

def target
  @target
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



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

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

Instance Method Details

#fileObject

RBS:

  • return: FileSpec?



50
51
52
53
54
55
56
57
# File 'lib/lldb/module.rb', line 50

def file
  return nil unless valid?

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

  FileSpec.from_ptr(file_ptr, context: context)
end

#file_pathObject

RBS:

  • return: String?



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

def file_path
  return nil unless valid?

  file&.path
end

#num_symbolsObject

RBS:

  • return: Integer



70
71
72
73
74
# File 'lib/lldb/module.rb', line 70

def num_symbols
  return 0 unless valid?

  FFIBindings.lldb_module_get_num_symbols(@ptr)
end

#platform_fileObject

RBS:

  • return: FileSpec?



60
61
62
63
64
65
66
67
# File 'lib/lldb/module.rb', line 60

def platform_file
  return nil unless valid?

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

  FileSpec.from_ptr(file_ptr, context: context)
end

#platform_file_pathObject

RBS:

  • return: String?



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

def platform_file_path
  return nil unless valid?

  platform_file&.path
end

#symbol_at_index(index) ⇒ Object

RBS:

  • index: Integer

  • return: Symbol?

Raises:



78
79
80
81
82
83
84
85
# File 'lib/lldb/module.rb', line 78

def symbol_at_index(index)
  raise InvalidObjectError, 'Module is not valid' unless valid?

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

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

#symbolsObject

RBS:

  • return: Array[Symbol]



88
89
90
# File 'lib/lldb/module.rb', line 88

def symbols
  (0...num_symbols).map { |index| symbol_at_index(index) }.compact
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



98
99
100
# File 'lib/lldb/module.rb', line 98

def to_ptr
  @ptr
end

#to_sObject

RBS:

  • return: String



93
94
95
# File 'lib/lldb/module.rb', line 93

def to_s
  file_path || '(unknown module)'
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


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

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