Class: LLDB::Breakpoint

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/breakpoint.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) ⇒ Breakpoint

Returns a new instance of Breakpoint.

RBS:

  • ptr: FFI::Pointer

  • target: Target

  • return: void



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

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

Instance Attribute Details

#targetObject (readonly)

RBS:

  • return: Target



10
11
12
# File 'lib/lldb/breakpoint.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/breakpoint.rb', line 26

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

Instance Method Details

#auto_continue=(value) ⇒ Object

RBS:

  • value: bool

  • return: void

Raises:



182
183
184
185
186
# File 'lib/lldb/breakpoint.rb', line 182

def auto_continue=(value)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_auto_continue(@ptr, value ? 1 : 0)
end

#auto_continue?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


174
175
176
177
178
# File 'lib/lldb/breakpoint.rb', line 174

def auto_continue?
  return false unless valid?

  FFIBindings.lldb_breakpoint_get_auto_continue(@ptr) != 0
end

#conditionObject

RBS:

  • return: String?



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

def condition
  return nil unless valid?

  cond = FFIBindings.lldb_breakpoint_get_condition(@ptr)
  cond.nil? || cond.empty? ? nil : cond
end

#condition=(expr) ⇒ Object

RBS:

  • expr: String?

  • return: void

Raises:



114
115
116
117
118
# File 'lib/lldb/breakpoint.rb', line 114

def condition=(expr)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_condition(@ptr, expr)
end

#deleteObject

RBS:

  • return: bool

Raises:



128
129
130
131
132
# File 'lib/lldb/breakpoint.rb', line 128

def delete
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  target.delete_breakpoint(id)
end

#disableObject

RBS:

  • return: void



63
64
65
# File 'lib/lldb/breakpoint.rb', line 63

def disable
  self.enabled = false
end

#enableObject

RBS:

  • return: void



58
59
60
# File 'lib/lldb/breakpoint.rb', line 58

def enable
  self.enabled = true
end

#enabled=(value) ⇒ Object

RBS:

  • value: bool

  • return: void

Raises:



51
52
53
54
55
# File 'lib/lldb/breakpoint.rb', line 51

def enabled=(value)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_enabled(@ptr, value ? 1 : 0)
end

#enabled?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


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

def enabled?
  return false unless valid?

  FFIBindings.lldb_breakpoint_is_enabled(@ptr) != 0
end

#find_location_by_id(location_id) ⇒ Object

RBS:

  • location_id: Integer

  • return: BreakpointLocation?

Raises:



152
153
154
155
156
157
158
159
# File 'lib/lldb/breakpoint.rb', line 152

def find_location_by_id(location_id)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  loc_ptr = FFIBindings.lldb_breakpoint_find_location_by_id(@ptr, location_id)
  return nil if loc_ptr.nil? || loc_ptr.null?

  BreakpointLocation.new(loc_ptr, breakpoint: self, context: context)
end

#hardware?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


167
168
169
170
171
# File 'lib/lldb/breakpoint.rb', line 167

def hardware?
  return false unless valid?

  FFIBindings.lldb_breakpoint_is_hardware(@ptr) != 0
end

#hit_countObject

RBS:

  • return: Integer



83
84
85
86
87
# File 'lib/lldb/breakpoint.rb', line 83

def hit_count
  return 0 unless valid?

  FFIBindings.lldb_breakpoint_get_hit_count(@ptr)
end

#idObject

RBS:

  • return: Integer



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

def id
  return INVALID_BREAK_ID unless valid?

  FFIBindings.lldb_breakpoint_get_id(@ptr)
end

#ignore_countObject

RBS:

  • return: Integer



90
91
92
93
94
# File 'lib/lldb/breakpoint.rb', line 90

def ignore_count
  return 0 unless valid?

  FFIBindings.lldb_breakpoint_get_ignore_count(@ptr)
end

#ignore_count=(count) ⇒ Object

RBS:

  • count: Integer

  • return: void

Raises:



98
99
100
101
102
# File 'lib/lldb/breakpoint.rb', line 98

def ignore_count=(count)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_ignore_count(@ptr, count)
end

#location_at_index(index) ⇒ Object

RBS:

  • index: Integer

  • return: BreakpointLocation?

Raises:



141
142
143
144
145
146
147
148
# File 'lib/lldb/breakpoint.rb', line 141

def location_at_index(index)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

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

  BreakpointLocation.new(loc_ptr, breakpoint: self, context: context)
end

#locationsObject

RBS:

  • return: Array[BreakpointLocation]



162
163
164
# File 'lib/lldb/breakpoint.rb', line 162

def locations
  (0...num_locations).map { |i| location_at_index(i) }.compact
end

#num_locationsObject

RBS:

  • return: Integer



121
122
123
124
125
# File 'lib/lldb/breakpoint.rb', line 121

def num_locations
  return 0 unless valid?

  FFIBindings.lldb_breakpoint_get_num_locations(@ptr)
end

#one_shot=(value) ⇒ Object

RBS:

  • value: bool

  • return: void

Raises:



76
77
78
79
80
# File 'lib/lldb/breakpoint.rb', line 76

def one_shot=(value)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_one_shot(@ptr, value ? 1 : 0)
end

#one_shot?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


68
69
70
71
72
# File 'lib/lldb/breakpoint.rb', line 68

def one_shot?
  return false unless valid?

  FFIBindings.lldb_breakpoint_is_one_shot(@ptr) != 0
end

#thread_idObject

RBS:

  • return: Integer



189
190
191
192
193
# File 'lib/lldb/breakpoint.rb', line 189

def thread_id
  return 0 unless valid?

  FFIBindings.lldb_breakpoint_get_thread_id(@ptr)
end

#thread_id=(value) ⇒ Object

RBS:

  • value: Integer

  • return: void

Raises:



197
198
199
200
201
# File 'lib/lldb/breakpoint.rb', line 197

def thread_id=(value)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_thread_id(@ptr, value)
end

#thread_indexObject

RBS:

  • return: Integer



219
220
221
222
223
# File 'lib/lldb/breakpoint.rb', line 219

def thread_index
  return 0 unless valid?

  FFIBindings.lldb_breakpoint_get_thread_index(@ptr)
end

#thread_index=(value) ⇒ Object

RBS:

  • value: Integer

  • return: void

Raises:



227
228
229
230
231
# File 'lib/lldb/breakpoint.rb', line 227

def thread_index=(value)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_thread_index(@ptr, value)
end

#thread_nameObject

RBS:

  • return: String?



204
205
206
207
208
# File 'lib/lldb/breakpoint.rb', line 204

def thread_name
  return nil unless valid?

  FFIBindings.lldb_breakpoint_get_thread_name(@ptr)
end

#thread_name=(value) ⇒ Object

RBS:

  • value: String?

  • return: void

Raises:



212
213
214
215
216
# File 'lib/lldb/breakpoint.rb', line 212

def thread_name=(value)
  raise InvalidObjectError, 'Breakpoint is not valid' unless valid?

  FFIBindings.lldb_breakpoint_set_thread_name(@ptr, value)
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



234
235
236
# File 'lib/lldb/breakpoint.rb', line 234

def to_ptr
  @ptr
end

#to_sObject

RBS:

  • return: String



135
136
137
# File 'lib/lldb/breakpoint.rb', line 135

def to_s
  "Breakpoint #{id}: enabled=#{enabled?}, hit_count=#{hit_count}, locations=#{num_locations}"
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


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

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