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.
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
|
# File 'lib/debug/thread_client.rb', line 1290
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.
1286
1287
1288
|
# File 'lib/debug/thread_client.rb', line 1286
def backup_frames
@backup_frames
end
|
Returns the value of attribute index.
1285
1286
1287
|
# File 'lib/debug/thread_client.rb', line 1285
def index
@index
end
|
Returns the value of attribute log.
1285
1286
1287
|
# File 'lib/debug/thread_client.rb', line 1285
def log
@log
end
|
Instance Method Details
#append(frames) ⇒ Object
1317
1318
1319
|
# File 'lib/debug/thread_client.rb', line 1317
def append frames
@log << frames
end
|
#can_step_back? ⇒ Boolean
1362
1363
1364
|
# File 'lib/debug/thread_client.rb', line 1362
def can_step_back?
log.size > @index
end
|
#current_frame ⇒ Object
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
|
# File 'lib/debug/thread_client.rb', line 1370
def current_frame
if @index == 0
f = @backup_frames
@backup_frames = nil
f
else
frames = @log[log_index]
frames
end
end
|
#current_position ⇒ Object
1382
1383
1384
1385
1386
1387
1388
1389
1390
|
# File 'lib/debug/thread_client.rb', line 1382
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
|
1328
1329
1330
1331
1332
1333
|
# File 'lib/debug/thread_client.rb', line 1328
def disable
if @tp_recorder.enabled?
@log.clear
@tp_recorder.disable
end
end
|
1321
1322
1323
1324
1325
1326
|
# File 'lib/debug/thread_client.rb', line 1321
def enable
unless @tp_recorder.enabled?
@log.clear
@tp_recorder.enable
end
end
|
#enabled? ⇒ Boolean
1335
1336
1337
|
# File 'lib/debug/thread_client.rb', line 1335
def enabled?
@tp_recorder.enabled?
end
|
#log_index ⇒ Object
1366
1367
1368
|
# File 'lib/debug/thread_client.rb', line 1366
def log_index
@log.size - @index
end
|
#replaying? ⇒ Boolean
1358
1359
1360
|
# File 'lib/debug/thread_client.rb', line 1358
def replaying?
@index > 0
end
|
#step_back(iter) ⇒ Object
1339
1340
1341
1342
1343
1344
|
# File 'lib/debug/thread_client.rb', line 1339
def step_back iter
@index += iter
if @index > @log.size
@index = @log.size
end
end
|
#step_forward(iter) ⇒ Object
1346
1347
1348
1349
1350
1351
|
# File 'lib/debug/thread_client.rb', line 1346
def step_forward iter
@index -= iter
if @index < 0
@index = 0
end
end
|
#step_reset ⇒ Object
1353
1354
1355
1356
|
# File 'lib/debug/thread_client.rb', line 1353
def step_reset
@index = 0
@backup_frames = nil
end
|