Class: DEBUGGER__::ThreadClient::Recorder
Instance Attribute Summary collapse
Instance Method Summary
collapse
#skip_config_skip_path?, #skip_internal_path?, #skip_location?, #skip_path?
Constructor Details
Returns a new instance of Recorder.
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
|
# File 'lib/debug/thread_client.rb', line 1293
def initialize
@log = []
@index = 0
@backup_frames = nil
thread = Thread.current
@tp_recorder ||= TracePoint.new(:line){|tp|
next unless Thread.current == thread
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 ⇒ Object
Returns the value of attribute backup_frames.
1289
1290
1291
|
# File 'lib/debug/thread_client.rb', line 1289
def backup_frames
@backup_frames
end
|
Returns the value of attribute index.
1288
1289
1290
|
# File 'lib/debug/thread_client.rb', line 1288
def index
@index
end
|
Returns the value of attribute log.
1288
1289
1290
|
# File 'lib/debug/thread_client.rb', line 1288
def log
@log
end
|
Instance Method Details
#append(frames) ⇒ Object
1320
1321
1322
|
# File 'lib/debug/thread_client.rb', line 1320
def append frames
@log << frames
end
|
#can_step_back? ⇒ Boolean
1365
1366
1367
|
# File 'lib/debug/thread_client.rb', line 1365
def can_step_back?
log.size > @index
end
|
#current_frame ⇒ Object
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
|
# File 'lib/debug/thread_client.rb', line 1373
def current_frame
if @index == 0
f = @backup_frames
@backup_frames = nil
f
else
frames = @log[log_index]
frames
end
end
|
#current_position ⇒ Object
1385
1386
1387
1388
1389
1390
1391
1392
1393
|
# File 'lib/debug/thread_client.rb', line 1385
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
|
1331
1332
1333
1334
1335
1336
|
# File 'lib/debug/thread_client.rb', line 1331
def disable
if @tp_recorder.enabled?
@log.clear
@tp_recorder.disable
end
end
|
1324
1325
1326
1327
1328
1329
|
# File 'lib/debug/thread_client.rb', line 1324
def enable
unless @tp_recorder.enabled?
@log.clear
@tp_recorder.enable
end
end
|
#enabled? ⇒ Boolean
1338
1339
1340
|
# File 'lib/debug/thread_client.rb', line 1338
def enabled?
@tp_recorder.enabled?
end
|
#log_index ⇒ Object
1369
1370
1371
|
# File 'lib/debug/thread_client.rb', line 1369
def log_index
@log.size - @index
end
|
#replaying? ⇒ Boolean
1361
1362
1363
|
# File 'lib/debug/thread_client.rb', line 1361
def replaying?
@index > 0
end
|
#step_back(iter) ⇒ Object
1342
1343
1344
1345
1346
1347
|
# File 'lib/debug/thread_client.rb', line 1342
def step_back iter
@index += iter
if @index > @log.size
@index = @log.size
end
end
|
#step_forward(iter) ⇒ Object
1349
1350
1351
1352
1353
1354
|
# File 'lib/debug/thread_client.rb', line 1349
def step_forward iter
@index -= iter
if @index < 0
@index = 0
end
end
|
#step_reset ⇒ Object
1356
1357
1358
1359
|
# File 'lib/debug/thread_client.rb', line 1356
def step_reset
@index = 0
@backup_frames = nil
end
|