Class: LLDB::Watchpoint

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

Returns a new instance of Watchpoint.

RBS:

  • ptr: FFI::Pointer

  • target: Target

  • return: void



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

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

Instance Attribute Details

#targetObject (readonly)

RBS:

  • return: Target



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

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

Instance Method Details

#conditionObject

RBS:

  • return: String?



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

def condition
  return nil unless valid?

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

#condition=(expr) ⇒ Object

RBS:

  • expr: String?

  • return: void

Raises:



99
100
101
102
103
# File 'lib/lldb/watchpoint.rb', line 99

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

  FFIBindings.lldb_watchpoint_set_condition(@ptr, expr)
end

#deleteObject

RBS:

  • return: bool

Raises:



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

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

  target.delete_watchpoint(id)
end

#disableObject

RBS:

  • return: void



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

def disable
  self.enabled = false
end

#enableObject

RBS:

  • return: void



58
59
60
# File 'lib/lldb/watchpoint.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/watchpoint.rb', line 51

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

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

#enabled?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


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

def enabled?
  return false unless valid?

  FFIBindings.lldb_watchpoint_is_enabled(@ptr) != 0
end

#hit_countObject

RBS:

  • return: Integer



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

def hit_count
  return 0 unless valid?

  FFIBindings.lldb_watchpoint_get_hit_count(@ptr)
end

#idObject

RBS:

  • return: Integer



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

def id
  return INVALID_BREAK_ID unless valid?

  FFIBindings.lldb_watchpoint_get_id(@ptr)
end

#ignore_countObject

RBS:

  • return: Integer



75
76
77
78
79
# File 'lib/lldb/watchpoint.rb', line 75

def ignore_count
  return 0 unless valid?

  FFIBindings.lldb_watchpoint_get_ignore_count(@ptr)
end

#ignore_count=(count) ⇒ Object

RBS:

  • count: Integer

  • return: void

Raises:



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

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

  FFIBindings.lldb_watchpoint_set_ignore_count(@ptr, count)
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



158
159
160
# File 'lib/lldb/watchpoint.rb', line 158

def to_ptr
  @ptr
end

#to_sObject

RBS:

  • return: String



153
154
155
# File 'lib/lldb/watchpoint.rb', line 153

def to_s
  "Watchpoint #{id}: address=0x#{watch_address.to_s(16)}, size=#{watch_size}, enabled=#{enabled?}"
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


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

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

#watch_addressObject

RBS:

  • return: Integer



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

def watch_address
  return INVALID_ADDRESS unless valid?

  FFIBindings.lldb_watchpoint_get_watch_address(@ptr)
end

#watch_sizeObject

RBS:

  • return: Integer



113
114
115
116
117
# File 'lib/lldb/watchpoint.rb', line 113

def watch_size
  return 0 unless valid?

  FFIBindings.lldb_watchpoint_get_watch_size(@ptr)
end

#watching_reads?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)

Raises:



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/lldb/watchpoint.rb', line 120

def watching_reads?
  raise InvalidObjectError, 'Watchpoint is not valid' unless valid?
  APISupport.require_feature!(:watchpoint_access_kind)

  result = FFI::MemoryPointer.new(:int)
  status = FFIBindings.lldb_watchpoint_is_watching_reads(@ptr, result)
  raise UnsupportedAPIError, 'Watchpoint read access is unsupported' if status == NativeStatus::UNSUPPORTED
  raise LLDBError, "Failed to query watchpoint read access (status=#{status})" unless status == NativeStatus::OK

  result.read_int != 0
end

#watching_writes?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)

Raises:



133
134
135
136
137
138
139
140
141
142
143
# File 'lib/lldb/watchpoint.rb', line 133

def watching_writes?
  raise InvalidObjectError, 'Watchpoint is not valid' unless valid?
  APISupport.require_feature!(:watchpoint_access_kind)

  result = FFI::MemoryPointer.new(:int)
  status = FFIBindings.lldb_watchpoint_is_watching_writes(@ptr, result)
  raise UnsupportedAPIError, 'Watchpoint write access is unsupported' if status == NativeStatus::UNSUPPORTED
  raise LLDBError, "Failed to query watchpoint write access (status=#{status})" unless status == NativeStatus::OK

  result.read_int != 0
end