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.
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
1319
|
# File 'lib/debug/thread_client.rb', line 1294
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.
1290
1291
1292
|
# File 'lib/debug/thread_client.rb', line 1290
def backup_frames
@backup_frames
end
|
Returns the value of attribute index.
1289
1290
1291
|
# File 'lib/debug/thread_client.rb', line 1289
def index
@index
end
|
Returns the value of attribute log.
1289
1290
1291
|
# File 'lib/debug/thread_client.rb', line 1289
def log
@log
end
|
Instance Method Details
#append(frames) ⇒ Object
1321
1322
1323
|
# File 'lib/debug/thread_client.rb', line 1321
def append frames
@log << frames
end
|
#can_step_back? ⇒ Boolean
1366
1367
1368
|
# File 'lib/debug/thread_client.rb', line 1366
def can_step_back?
log.size > @index
end
|
#current_frame ⇒ Object
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
|
# File 'lib/debug/thread_client.rb', line 1374
def current_frame
if @index == 0
f = @backup_frames
@backup_frames = nil
f
else
frames = @log[log_index]
frames
end
end
|
#current_position ⇒ Object
1386
1387
1388
1389
1390
1391
1392
1393
1394
|
# File 'lib/debug/thread_client.rb', line 1386
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
|
1332
1333
1334
1335
1336
1337
|
# File 'lib/debug/thread_client.rb', line 1332
def disable
if @tp_recorder.enabled?
@log.clear
@tp_recorder.disable
end
end
|
1325
1326
1327
1328
1329
1330
|
# File 'lib/debug/thread_client.rb', line 1325
def enable
unless @tp_recorder.enabled?
@log.clear
@tp_recorder.enable
end
end
|
#enabled? ⇒ Boolean
1339
1340
1341
|
# File 'lib/debug/thread_client.rb', line 1339
def enabled?
@tp_recorder.enabled?
end
|
#log_index ⇒ Object
1370
1371
1372
|
# File 'lib/debug/thread_client.rb', line 1370
def log_index
@log.size - @index
end
|
#replaying? ⇒ Boolean
1362
1363
1364
|
# File 'lib/debug/thread_client.rb', line 1362
def replaying?
@index > 0
end
|
#step_back(iter) ⇒ Object
1343
1344
1345
1346
1347
1348
|
# File 'lib/debug/thread_client.rb', line 1343
def step_back iter
@index += iter
if @index > @log.size
@index = @log.size
end
end
|
#step_forward(iter) ⇒ Object
1350
1351
1352
1353
1354
1355
|
# File 'lib/debug/thread_client.rb', line 1350
def step_forward iter
@index -= iter
if @index < 0
@index = 0
end
end
|
#step_reset ⇒ Object
1357
1358
1359
1360
|
# File 'lib/debug/thread_client.rb', line 1357
def step_reset
@index = 0
@backup_frames = nil
end
|