Class: DEBUGGER__::ThreadClient::Recorder
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | lib/debug/thread_client.rb |
Class Method Summary
- .new ⇒ Recorder constructor
Instance Attribute Summary
- #backup_frames rw
- #can_step_back? ⇒ Boolean readonly
- #enabled? ⇒ Boolean readonly
- #index readonly
- #log readonly
- #replaying? ⇒ Boolean readonly
Instance Method Summary
- #append(frames)
- #current_frame
-
#current_position
for debugging.
- #disable
- #enable
- #log_index
- #step_back(iter)
- #step_forward(iter)
- #step_reset
::DEBUGGER__::SkipPathHelper
- Included
Constructor Details
.new ⇒ Recorder
# File 'lib/debug/thread_client.rb', line 1291
def initialize @log = [] @index = 0 @backup_frames = nil thread = Thread.current @tp_recorder ||= TracePoint.new(:line){|tp| next unless Thread.current == thread # can't be replaced by skip_location next if skip_internal_path?(tp.path) 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 } append(frames) } end
Instance Attribute Details
#backup_frames (rw)
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1287
attr_accessor :backup_frames
#can_step_back? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/debug/thread_client.rb', line 1363
def can_step_back? log.size > @index end
#enabled? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/debug/thread_client.rb', line 1336
def enabled? @tp_recorder.enabled? end
#index (readonly)
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1286
attr_reader :log, :index
#log (readonly)
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1286
attr_reader :log, :index
#replaying? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/debug/thread_client.rb', line 1359
def @index > 0 end
Instance Method Details
#append(frames)
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1318
def append frames @log << frames end
#current_frame
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1371
def current_frame if @index == 0 f = @backup_frames @backup_frames = nil f else frames = @log[log_index] frames end end
#current_position
for debugging
#disable
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1329
def disable if @tp_recorder.enabled? @log.clear @tp_recorder.disable end end
#enable
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1322
def enable unless @tp_recorder.enabled? @log.clear @tp_recorder.enable end end
#log_index
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1367
def log_index @log.size - @index end
#step_back(iter)
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1340
def step_back iter @index += iter if @index > @log.size @index = @log.size end end
#step_forward(iter)
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1347
def step_forward iter @index -= iter if @index < 0 @index = 0 end end
#step_reset
[ GitHub ]# File 'lib/debug/thread_client.rb', line 1354
def step_reset @index = 0 @backup_frames = nil end