File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -136,11 +136,14 @@ Turn on automatic breakpoints when any of the conditions described in `states` o
136
136
The supported states are:
137
137
138
138
- `:error`: trigger a breakpoint any time an uncaught exception is thrown
139
+ - `:throw` : trigger a breakpoint any time a throw is executed (even if it will eventually be caught)
139
140
"""
140
141
function break_on (states:: Vararg{Symbol} )
141
142
for state in states
142
143
if state == :error
143
144
break_on_error[] = true
145
+ elseif state == :throw
146
+ break_on_throw[] = true
144
147
else
145
148
throw (ArgumentError (string (" unsupported state :" , state)))
146
149
end
@@ -157,6 +160,8 @@ function break_off(states::Vararg{Symbol})
157
160
for state in states
158
161
if state == :error
159
162
break_on_error[] = false
163
+ elseif state == :throw
164
+ break_on_throw[] = false
160
165
else
161
166
throw (ArgumentError (string (" unsupported state :" , state)))
162
167
end
Original file line number Diff line number Diff line change @@ -560,13 +560,8 @@ behaviors:
560
560
function handle_err (@nospecialize (recurse), frame, err)
561
561
data = frame. framedata
562
562
err_will_be_thrown_to_top_level = isempty (data. exception_frames) && ! data. caller_will_catch_err
563
- if break_on_error[]
564
- # See if the current frame or a frame in the stack will catch this exception,
565
- # otherwise this exception would have been thrown to the user and we should
566
- # return a breakpoint
567
- if err_will_be_thrown_to_top_level
568
- return BreakpointRef (frame. framecode, frame. pc, err)
569
- end
563
+ if break_on_throw[] || (break_on_error[] && err_will_be_thrown_to_top_level)
564
+ return BreakpointRef (frame. framecode, frame. pc, err)
570
565
end
571
566
if isempty (data. exception_frames)
572
567
is_root_frame = frame. caller === nothing
Original file line number Diff line number Diff line change 15
15
truecondition (frame) = true
16
16
falsecondition (frame) = false
17
17
const break_on_error = Ref (false )
18
+ const break_on_throw = Ref (false )
18
19
19
20
"""
20
21
BreakpointState(isactive=true, condition=JuliaInterpreter.truecondition)
Original file line number Diff line number Diff line change 165
165
v = JuliaInterpreter. finish_and_return! (frame)
166
166
@test v isa ErrorException
167
167
@test stacklength (frame) == 1
168
+
169
+ # Break on caught exception when enabled
170
+ break_on (:throw )
171
+ try
172
+ frame = JuliaInterpreter. enter_call (f_exc_outer);
173
+ v = JuliaInterpreter. finish_and_return! (frame)
174
+ @test v isa BreakpointRef
175
+ @test v. err isa ErrorException
176
+ @test v. framecode. scope == @which error ()
177
+ finally
178
+ break_off (:throw )
179
+ end
168
180
finally
169
181
break_off (:error )
170
182
end
You can’t perform that action at this time.
0 commit comments