class DEBUGGER__::ThreadClient::Recorder
Attributes
backup_frames[RW]
index[R]
log[R]
Public Class Methods
new()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 996 def initialize @log = [] @index = 0 @backup_frames = nil thread = Thread.current @tp_recorder ||= TracePoint.new(:line){|tp| next unless Thread.current == thread next if tp.path.start_with? __dir__ next if tp.path.start_with? '<internal:' loc = caller_locations(1, 1).first next if skip_location?(loc) frames = DEBUGGER__.capture_frames(__dir__) frames.each{|frame| if b = frame.binding frame.binding = nil frame._local_variables = b.local_variables.map{|name| [name, b.local_variable_get(name)] }.to_h frame._callee = b.eval('__callee__') end } @log << frames } end
Public Instance Methods
can_step_back?()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1058 def can_step_back? log.size > @index end
current_frame()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1066 def current_frame if @index == 0 f = @backup_frames @backup_frames = nil f else frames = @log[log_index] frames end end
current_position()
click to toggle source
for debugging
# File debug-1.4.0/lib/debug/thread_client.rb, line 1078 def current_position puts "INDEX: #{@index}" li = log_index @log.each_with_index{|frame, i| loc = frame.first&.location prefix = i == li ? "=> " : ' ' puts "#{prefix} #{loc}" } end
disable()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1030 def disable if @tp_recorder.enabled? @log.clear @tp_recorder.disable end end
enable()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1023 def enable unless @tp_recorder.enabled? @log.clear @tp_recorder.enable end end
enabled?()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1037 def enabled? @tp_recorder.enabled? end
log_index()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1062 def log_index @log.size - @index end
replaying?()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1054 def replaying? @index > 0 end
step_back()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1041 def step_back @index += 1 end
step_forward()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1045 def step_forward @index -= 1 end
step_reset()
click to toggle source
# File debug-1.4.0/lib/debug/thread_client.rb, line 1049 def step_reset @index = 0 @backup_frames = nil end