Class: DEBUGGER__::ThreadClient::Recorder
Instance Attribute Summary collapse
Instance Method Summary
collapse
#skip_internal_path?, #skip_location?, #skip_path?
Constructor Details
Returns a new instance of Recorder.
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
|
# File 'lib/debug/thread_client.rb', line 1048
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.
1044
1045
1046
|
# File 'lib/debug/thread_client.rb', line 1044
def backup_frames
@backup_frames
end
|
Returns the value of attribute index.
1043
1044
1045
|
# File 'lib/debug/thread_client.rb', line 1043
def index
@index
end
|
Returns the value of attribute log.
1043
1044
1045
|
# File 'lib/debug/thread_client.rb', line 1043
def log
@log
end
|
Instance Method Details
#can_step_back? ⇒ Boolean
1110
1111
1112
|
# File 'lib/debug/thread_client.rb', line 1110
def can_step_back?
log.size > @index
end
|
#current_frame ⇒ Object
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
# File 'lib/debug/thread_client.rb', line 1118
def current_frame
if @index == 0
f = @backup_frames
@backup_frames = nil
f
else
frames = @log[log_index]
frames
end
end
|
#current_position ⇒ Object
1130
1131
1132
1133
1134
1135
1136
1137
1138
|
# File 'lib/debug/thread_client.rb', line 1130
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
|
1082
1083
1084
1085
1086
1087
|
# File 'lib/debug/thread_client.rb', line 1082
def disable
if @tp_recorder.enabled?
@log.clear
@tp_recorder.disable
end
end
|
1075
1076
1077
1078
1079
1080
|
# File 'lib/debug/thread_client.rb', line 1075
def enable
unless @tp_recorder.enabled?
@log.clear
@tp_recorder.enable
end
end
|
#enabled? ⇒ Boolean
1089
1090
1091
|
# File 'lib/debug/thread_client.rb', line 1089
def enabled?
@tp_recorder.enabled?
end
|
#log_index ⇒ Object
1114
1115
1116
|
# File 'lib/debug/thread_client.rb', line 1114
def log_index
@log.size - @index
end
|
#replaying? ⇒ Boolean
1106
1107
1108
|
# File 'lib/debug/thread_client.rb', line 1106
def replaying?
@index > 0
end
|
#step_back ⇒ Object
1093
1094
1095
|
# File 'lib/debug/thread_client.rb', line 1093
def step_back
@index += 1
end
|
#step_forward ⇒ Object
1097
1098
1099
|
# File 'lib/debug/thread_client.rb', line 1097
def step_forward
@index -= 1
end
|
#step_reset ⇒ Object
1101
1102
1103
1104
|
# File 'lib/debug/thread_client.rb', line 1101
def step_reset
@index = 0
@backup_frames = nil
end
|