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.
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
1316
|
# 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
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.
1287
1288
1289
|
# File 'lib/debug/thread_client.rb', line 1287
def backup_frames
@backup_frames
end
|
Returns the value of attribute index.
1286
1287
1288
|
# File 'lib/debug/thread_client.rb', line 1286
def index
@index
end
|
Returns the value of attribute log.
1286
1287
1288
|
# File 'lib/debug/thread_client.rb', line 1286
def log
@log
end
|
Instance Method Details
#append(frames) ⇒ Object
1318
1319
1320
|
# File 'lib/debug/thread_client.rb', line 1318
def append frames
@log << frames
end
|
#can_step_back? ⇒ Boolean
1363
1364
1365
|
# File 'lib/debug/thread_client.rb', line 1363
def can_step_back?
log.size > @index
end
|
#current_frame ⇒ Object
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
|
# 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 ⇒ Object
1383
1384
1385
1386
1387
1388
1389
1390
1391
|
# File 'lib/debug/thread_client.rb', line 1383
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
|
1329
1330
1331
1332
1333
1334
|
# File 'lib/debug/thread_client.rb', line 1329
def disable
if @tp_recorder.enabled?
@log.clear
@tp_recorder.disable
end
end
|
1322
1323
1324
1325
1326
1327
|
# File 'lib/debug/thread_client.rb', line 1322
def enable
unless @tp_recorder.enabled?
@log.clear
@tp_recorder.enable
end
end
|
#enabled? ⇒ Boolean
1336
1337
1338
|
# File 'lib/debug/thread_client.rb', line 1336
def enabled?
@tp_recorder.enabled?
end
|
#log_index ⇒ Object
1367
1368
1369
|
# File 'lib/debug/thread_client.rb', line 1367
def log_index
@log.size - @index
end
|
#replaying? ⇒ Boolean
1359
1360
1361
|
# File 'lib/debug/thread_client.rb', line 1359
def replaying?
@index > 0
end
|
#step_back(iter) ⇒ Object
1340
1341
1342
1343
1344
1345
|
# 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) ⇒ Object
1347
1348
1349
1350
1351
1352
|
# File 'lib/debug/thread_client.rb', line 1347
def step_forward iter
@index -= iter
if @index < 0
@index = 0
end
end
|
#step_reset ⇒ Object
1354
1355
1356
1357
|
# File 'lib/debug/thread_client.rb', line 1354
def step_reset
@index = 0
@backup_frames = nil
end
|