Class: DEBUGGER__::WatchIVarBreakpoint
- Inherits:
-
Breakpoint
- Object
- Breakpoint
- DEBUGGER__::WatchIVarBreakpoint
- Defined in:
- lib/debug/breakpoint.rb
Instance Attribute Summary
Attributes inherited from Breakpoint
Instance Method Summary collapse
-
#initialize(ivar, object, current, cond: nil, command: nil, path: nil) ⇒ WatchIVarBreakpoint
constructor
A new instance of WatchIVarBreakpoint.
- #setup ⇒ Object
- #to_s ⇒ Object
- #watch_eval(tp) ⇒ Object
Methods inherited from Breakpoint
#delete, #deleted?, #description, #disable, #duplicable?, #enable, #enabled?, #generate_label, #oneshot?, #pending_until_load?, #safe_eval, #skip_path?, #suspend
Methods included from Color
#color_pp, #colored_inspect, #colorize, #colorize_blue, #colorize_code, #colorize_cyan, #colorize_dim, #colorize_magenta, #irb_colorize, #with_inspection_error_guard
Methods included from SkipPathHelper
#skip_config_skip_path?, #skip_internal_path?, #skip_location?, #skip_path?
Constructor Details
#initialize(ivar, object, current, cond: nil, command: nil, path: nil) ⇒ WatchIVarBreakpoint
384 385 386 387 388 389 390 391 392 |
# File 'lib/debug/breakpoint.rb', line 384 def initialize ivar, object, current, cond: nil, command: nil, path: nil @ivar = ivar.to_sym @object = object @key = [:watch, object.object_id, @ivar].freeze @current = current super(cond, command, path) end |
Instance Method Details
#setup ⇒ Object
412 413 414 415 416 |
# File 'lib/debug/breakpoint.rb', line 412 def setup @tp = TracePoint.new(:line, :return, :b_return){|tp| watch_eval(tp) } end |
#to_s ⇒ Object
418 419 420 421 422 423 424 425 426 |
# File 'lib/debug/breakpoint.rb', line 418 def to_s value_str = if defined?(@prev) "#{@prev} -> #{@current}" else "#{@current}" end "#{generate_label("Watch")} #{@object} #{@ivar} = #{value_str}" end |
#watch_eval(tp) ⇒ Object
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/debug/breakpoint.rb', line 394 def watch_eval(tp) result = @object.instance_variable_get(@ivar) if result != @current begin @prev = @current @current = result if (@cond.nil? || @object.instance_eval(@cond)) && !skip_path?(tp.path) suspend end ensure remove_instance_variable(:@prev) end end rescue Exception false end |