85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/thread_weaver/controllable_thread.rb', line 85
def handle_trace_point(tp)
event = T.let(tp.event, Symbol)
klass = T.let(tp.defined_class, T.nilable(Module))
path = T.let(tp.path, T.nilable(String))
line = T.let(tp.lineno, T.nilable(Integer))
method_name = T.let(tp.method_id, T.nilable(Symbol))
@last_trace_point_summary = "#{event} #{klass}##{method_name} #{path}#L#{line}"
if klass
current_count = @line_counts_by_class.fetch(klass, 0)
@line_counts_by_class[klass] = (current_count + 1)
end
case @current_instruction
when PauseAtThreadStart
if event == :thread_begin
wait_until_released
end
when ContinueToThreadEnd
when PauseWhenLineCount
current_count = @current_instruction.target_classes.map { |klass| @line_counts_by_class.fetch(klass, 0) }.sum
required_count = @current_instruction.count
if required_count == current_count
wait_until_released
end
when PauseAtMethodCall
if @current_instruction.klass == klass && @current_instruction.method_name == method_name
wait_until_released
end
when PauseAtMethodReturn
if @current_instruction.klass == klass && @current_instruction.method_name == method_name
wait_until_released
end
when PauseAtSourceLine
if path&.end_with?(@current_instruction.path_suffix) && @current_instruction.line == line
wait_until_released
end
else
T.absurd(@current_instruction)
end
end
|