Class: LLDB::Value
- Inherits:
-
Object
- Object
- LLDB::Value
- Includes:
- Enumerable, NativeLifecycle
- Defined in:
- lib/lldb/value.rb
Instance Attribute Summary collapse
- #parent ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #address_of ⇒ Object
- #byte_size ⇒ Object
- #cast(target_type) ⇒ Object
- #child_at_index(index) ⇒ Object
- #child_member(name) ⇒ Object (also: #[])
- #children ⇒ Object
- #create_child_at_offset(name, value_type, offset) ⇒ Object
- #create_value_from_address(name, address, value_type) ⇒ Object
- #create_value_from_expression(name, expression) ⇒ Object
- #dereference ⇒ Object
- #each(&block) ⇒ Object
- #error ⇒ Object
- #expression_path ⇒ Object
- #has_error? ⇒ Boolean
-
#initialize(ptr, parent:, context: parent.context) ⇒ Value
constructor
A new instance of Value.
- #inspect ⇒ Object
- #load_address ⇒ Object
- #might_have_children? ⇒ Boolean
- #name ⇒ Object
- #non_synthetic_value ⇒ Object
- #num_children ⇒ Object
- #pointer_type? ⇒ Boolean
- #set_value_from_cstring(str) ⇒ Object
- #summary ⇒ Object
- #to_ptr ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #type_name ⇒ Object
- #valid? ⇒ Boolean
- #value ⇒ Object
- #value_as_signed ⇒ Object (also: #to_i)
- #value_as_unsigned ⇒ Object
- #value_type ⇒ Object
- #value_type_name ⇒ Object
- #watch(resolve: true, read: false, write: true) ⇒ Object
Methods included from NativeLifecycle
#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object
Constructor Details
#initialize(ptr, parent:, context: parent.context) ⇒ Value
Returns a new instance of Value.
16 17 18 19 20 21 22 23 |
# File 'lib/lldb/value.rb', line 16 def initialize(ptr, parent:, context: parent.context) @parent = parent initialize_native_object( ptr, release: ->(released) { FFIBindings.lldb_value_destroy(released) }, context: context ) end |
Instance Attribute Details
#parent ⇒ Object (readonly)
11 12 13 |
# File 'lib/lldb/value.rb', line 11 def parent @parent end |
Class Method Details
.release(ptr) ⇒ Object
27 28 29 |
# File 'lib/lldb/value.rb', line 27 def self.release(ptr) ->(_id) { FFIBindings.lldb_value_destroy(ptr) unless ptr.null? } end |
Instance Method Details
#address_of ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/lldb/value.rb', line 170 def address_of raise InvalidObjectError, 'Value is not valid' unless valid? addr_ptr = FFIBindings.lldb_value_address_of(@ptr) return nil if addr_ptr.nil? || addr_ptr.null? Value.new(addr_ptr, parent: self, context: context) end |
#byte_size ⇒ Object
131 132 133 134 135 |
# File 'lib/lldb/value.rb', line 131 def byte_size return 0 unless valid? FFIBindings.lldb_value_get_byte_size(@ptr) end |
#cast(target_type) ⇒ Object
207 208 209 210 211 212 213 214 |
# File 'lib/lldb/value.rb', line 207 def cast(target_type) raise InvalidObjectError, 'Value is not valid' unless valid? cast_ptr = FFIBindings.lldb_value_cast(@ptr, target_type.to_ptr) return nil if cast_ptr.nil? || cast_ptr.null? Value.new(cast_ptr, parent: self, context: context) end |
#child_at_index(index) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/lldb/value.rb', line 73 def child_at_index(index) raise InvalidObjectError, 'Value is not valid' unless valid? child_ptr = FFIBindings.lldb_value_get_child_at_index(@ptr, index) return nil if child_ptr.nil? || child_ptr.null? Value.new(child_ptr, parent: self, context: context) end |
#child_member(name) ⇒ Object Also known as: []
84 85 86 87 88 89 90 91 |
# File 'lib/lldb/value.rb', line 84 def child_member(name) raise InvalidObjectError, 'Value is not valid' unless valid? child_ptr = FFIBindings.lldb_value_get_child_member_with_name(@ptr, name) return nil if child_ptr.nil? || child_ptr.null? Value.new(child_ptr, parent: self, context: context) end |
#children ⇒ Object
96 97 98 |
# File 'lib/lldb/value.rb', line 96 def children (0...num_children).map { |i| child_at_index(i) }.compact end |
#create_child_at_offset(name, value_type, offset) ⇒ Object
250 251 252 253 254 255 256 257 |
# File 'lib/lldb/value.rb', line 250 def create_child_at_offset(name, value_type, offset) raise InvalidObjectError, 'Value is not valid' unless valid? child_ptr = FFIBindings.lldb_value_create_child_at_offset(@ptr, name, value_type.to_ptr, offset) return nil if child_ptr.nil? || child_ptr.null? Value.new(child_ptr, parent: self, context: context) end |
#create_value_from_address(name, address, value_type) ⇒ Object
263 264 265 266 267 268 269 270 |
# File 'lib/lldb/value.rb', line 263 def create_value_from_address(name, address, value_type) raise InvalidObjectError, 'Value is not valid' unless valid? value_ptr = FFIBindings.lldb_value_create_value_from_address(@ptr, name, address, value_type.to_ptr) return nil if value_ptr.nil? || value_ptr.null? Value.new(value_ptr, parent: self, context: context) end |
#create_value_from_expression(name, expression) ⇒ Object
275 276 277 278 279 280 281 282 |
# File 'lib/lldb/value.rb', line 275 def create_value_from_expression(name, expression) raise InvalidObjectError, 'Value is not valid' unless valid? value_ptr = FFIBindings.lldb_value_create_value_from_expression(@ptr, name, expression) return nil if value_ptr.nil? || value_ptr.null? Value.new(value_ptr, parent: self, context: context) end |
#dereference ⇒ Object
160 161 162 163 164 165 166 167 |
# File 'lib/lldb/value.rb', line 160 def dereference raise InvalidObjectError, 'Value is not valid' unless valid? deref_ptr = FFIBindings.lldb_value_dereference(@ptr) return nil if deref_ptr.nil? || deref_ptr.null? Value.new(deref_ptr, parent: self, context: context) end |
#each(&block) ⇒ Object
102 103 104 105 106 |
# File 'lib/lldb/value.rb', line 102 def each(&block) return enum_for(:each) unless block_given? children.each(&block) end |
#error ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/lldb/value.rb', line 145 def error raise InvalidObjectError, 'Value is not valid' unless valid? error = Error.new FFIBindings.lldb_value_get_error(@ptr, error.to_ptr) error end |
#expression_path ⇒ Object
302 303 304 305 306 |
# File 'lib/lldb/value.rb', line 302 def expression_path return nil unless valid? FFIBindings.lldb_value_get_expression_path(@ptr) end |
#has_error? ⇒ Boolean
154 155 156 157 |
# File 'lib/lldb/value.rb', line 154 def has_error? err = error err.fail? end |
#inspect ⇒ Object
191 192 193 |
# File 'lib/lldb/value.rb', line 191 def inspect "#<LLDB::Value name=#{name.inspect} type=#{type_name.inspect} value=#{value.inspect}>" end |
#load_address ⇒ Object
217 218 219 220 221 |
# File 'lib/lldb/value.rb', line 217 def load_address return INVALID_ADDRESS unless valid? FFIBindings.lldb_value_get_load_address(@ptr) end |
#might_have_children? ⇒ Boolean
138 139 140 141 142 |
# File 'lib/lldb/value.rb', line 138 def might_have_children? return false unless valid? FFIBindings.lldb_value_might_have_children(@ptr) != 0 end |
#name ⇒ Object
37 38 39 40 41 |
# File 'lib/lldb/value.rb', line 37 def name return nil unless valid? FFIBindings.lldb_value_get_name(@ptr) end |
#non_synthetic_value ⇒ Object
316 317 318 319 320 321 322 323 |
# File 'lib/lldb/value.rb', line 316 def non_synthetic_value raise InvalidObjectError, 'Value is not valid' unless valid? value_ptr = FFIBindings.lldb_value_get_non_synthetic_value(@ptr) return nil if value_ptr.nil? || value_ptr.null? Value.new(value_ptr, parent: self, context: context) end |
#num_children ⇒ Object
65 66 67 68 69 |
# File 'lib/lldb/value.rb', line 65 def num_children return 0 unless valid? FFIBindings.lldb_value_get_num_children(@ptr) end |
#pointer_type? ⇒ Boolean
309 310 311 312 313 |
# File 'lib/lldb/value.rb', line 309 def pointer_type? return false unless valid? FFIBindings.lldb_value_is_pointer_type(@ptr) != 0 end |
#set_value_from_cstring(str) ⇒ Object
237 238 239 240 241 242 243 244 |
# File 'lib/lldb/value.rb', line 237 def set_value_from_cstring(str) raise InvalidObjectError, 'Value is not valid' unless valid? error = Error.new result = FFIBindings.lldb_value_set_value_from_cstring(@ptr, str, error.to_ptr) error.raise_if_error! result != 0 end |
#summary ⇒ Object
51 52 53 54 55 |
# File 'lib/lldb/value.rb', line 51 def summary return nil unless valid? FFIBindings.lldb_value_get_summary(@ptr) end |
#to_ptr ⇒ Object
326 327 328 |
# File 'lib/lldb/value.rb', line 326 def to_ptr @ptr end |
#to_s ⇒ Object
180 181 182 183 184 185 186 187 188 |
# File 'lib/lldb/value.rb', line 180 def to_s if summary "#{name} = #{summary}" elsif value "#{name} = #{value}" else "#{name} (#{type_name})" end end |
#type ⇒ Object
196 197 198 199 200 201 202 203 |
# File 'lib/lldb/value.rb', line 196 def type raise InvalidObjectError, 'Value is not valid' unless valid? type_ptr = FFIBindings.lldb_value_get_type(@ptr) return nil if type_ptr.nil? || type_ptr.null? Type.new(type_ptr, context: context) end |
#type_name ⇒ Object
58 59 60 61 62 |
# File 'lib/lldb/value.rb', line 58 def type_name return nil unless valid? FFIBindings.lldb_value_get_type_name(@ptr) end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/lldb/value.rb', line 32 def valid? !@ptr.null? && FFIBindings.lldb_value_is_valid(@ptr) != 0 end |
#value ⇒ Object
44 45 46 47 48 |
# File 'lib/lldb/value.rb', line 44 def value return nil unless valid? FFIBindings.lldb_value_get_value(@ptr) end |
#value_as_signed ⇒ Object Also known as: to_i
109 110 111 112 113 114 115 116 |
# File 'lib/lldb/value.rb', line 109 def value_as_signed return 0 unless valid? error = Error.new result = FFIBindings.lldb_value_get_value_as_signed(@ptr, error.to_ptr, 0) error.raise_if_error!('value.value_as_signed') result end |
#value_as_unsigned ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'lib/lldb/value.rb', line 121 def value_as_unsigned return 0 unless valid? error = Error.new result = FFIBindings.lldb_value_get_value_as_unsigned(@ptr, error.to_ptr, 0) error.raise_if_error!('value.value_as_unsigned') result end |
#value_type ⇒ Object
224 225 226 227 228 |
# File 'lib/lldb/value.rb', line 224 def value_type return ValueType::INVALID unless valid? FFIBindings.lldb_value_get_value_type(@ptr) end |
#value_type_name ⇒ Object
231 232 233 |
# File 'lib/lldb/value.rb', line 231 def value_type_name ValueType.name(value_type) end |
#watch(resolve: true, read: false, write: true) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/lldb/value.rb', line 288 def watch(resolve: true, read: false, write: true) raise InvalidObjectError, 'Value is not valid' unless valid? error = Error.new wp_ptr = FFIBindings.lldb_value_watch(@ptr, resolve ? 1 : 0, read ? 1 : 0, write ? 1 : 0, error.to_ptr) error.raise_if_error! return nil if wp_ptr.nil? || wp_ptr.null? target = get_target_from_parent Watchpoint.new(wp_ptr, target: target, context: context) end |