123456789_123456789_123456789_123456789_123456789_

Class: DEBUGGER__::WatchIVarBreakpoint

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Breakpoint
Instance Chain:
Inherits: DEBUGGER__::Breakpoint
Defined in: lib/debug/breakpoint.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Breakpoint - Inherited

Color - Included

#color_pp

See additional method definition at line 50.

#colored_inspect,
#colorize

See additional method definition at line 36.

#colorize_blue,
#colorize_code

See additional method definition at line 79.

#colorize_cyan, #colorize_dim, #colorize_magenta,
#irb_colorize

See additional method definition at line 27.

#with_inspection_error_guard

SkipPathHelper - Included

Constructor Details

.new(ivar, object, current, cond: nil, command: nil, path: nil) ⇒ WatchIVarBreakpoint

[ GitHub ]

  
# File 'lib/debug/breakpoint.rb', line 378

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

[ GitHub ]

  
# File 'lib/debug/breakpoint.rb', line 406

def setup
  @tp = TracePoint.new(:line, :return, :b_return){|tp|
    watch_eval(tp)
  }
end

#to_s

[ GitHub ]

  
# File 'lib/debug/breakpoint.rb', line 412

def to_s
  value_str =
    if defined?(@prev)
      "#{@prev} -> #{@current}"
    else
      "#{@current}"
    end
  "#{generate_label("Watch")} #{@object} #{@ivar} = #{value_str}"
end

#watch_eval(tp)

[ GitHub ]

  
# File 'lib/debug/breakpoint.rb', line 388

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