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.
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
|
# File 'lib/debug/thread_client.rb', line 1272
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
}
@log << frames
}
end
|
Instance Attribute Details
#backup_frames ⇒ Object
Returns the value of attribute backup_frames.
1268
1269
1270
|
# File 'lib/debug/thread_client.rb', line 1268
def backup_frames
@backup_frames
end
|
Returns the value of attribute index.
1267
1268
1269
|
# File 'lib/debug/thread_client.rb', line 1267
def index
@index
end
|
Returns the value of attribute log.
1267
1268
1269
|
# File 'lib/debug/thread_client.rb', line 1267
def log
@log
end
|
Instance Method Details
#can_step_back? ⇒ Boolean
1340
1341
1342
|
# File 'lib/debug/thread_client.rb', line 1340
def can_step_back?
log.size > @index
end
|
#current_frame ⇒ Object
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
|
# File 'lib/debug/thread_client.rb', line 1348
def current_frame
if @index == 0
f = @backup_frames
@backup_frames = nil
f
else
frames = @log[log_index]
frames
end
end
|
#current_position ⇒ Object
1360
1361
1362
1363
1364
1365
1366
1367
1368
|
# File 'lib/debug/thread_client.rb', line 1360
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
|
1306
1307
1308
1309
1310
1311
|
# File 'lib/debug/thread_client.rb', line 1306
def disable
if @tp_recorder.enabled?
@log.clear
@tp_recorder.disable
end
end
|
1299
1300
1301
1302
1303
1304
|
# File 'lib/debug/thread_client.rb', line 1299
def enable
unless @tp_recorder.enabled?
@log.clear
@tp_recorder.enable
end
end
|
#enabled? ⇒ Boolean
1313
1314
1315
|
# File 'lib/debug/thread_client.rb', line 1313
def enabled?
@tp_recorder.enabled?
end
|
#log_index ⇒ Object
1344
1345
1346
|
# File 'lib/debug/thread_client.rb', line 1344
def log_index
@log.size - @index
end
|
#replaying? ⇒ Boolean
1336
1337
1338
|
# File 'lib/debug/thread_client.rb', line 1336
def replaying?
@index > 0
end
|
#step_back(iter) ⇒ Object
1317
1318
1319
1320
1321
1322
|
# File 'lib/debug/thread_client.rb', line 1317
def step_back iter
@index += iter
if @index > @log.size
@index = @log.size
end
end
|
#step_forward(iter) ⇒ Object
1324
1325
1326
1327
1328
1329
|
# File 'lib/debug/thread_client.rb', line 1324
def step_forward iter
@index -= iter
if @index < 0
@index = 0
end
end
|
#step_reset ⇒ Object
1331
1332
1333
1334
|
# File 'lib/debug/thread_client.rb', line 1331
def step_reset
@index = 0
@backup_frames = nil
end
|