@@ -870,6 +870,7 @@ def wait_next_action_
870
870
frame = @target_frames . first
871
871
path = frame . location . absolute_path || "!eval:#{ frame . path } "
872
872
line = frame . location . lineno
873
+ label = frame . location . base_label
873
874
874
875
if frame . iseq
875
876
frame . iseq . traceable_lines_norec ( lines = { } )
@@ -881,23 +882,32 @@ def wait_next_action_
881
882
882
883
depth = @target_frames . first . frame_depth
883
884
884
- step_tp iter do
885
+ step_tp iter do | tp |
885
886
loc = caller_locations ( 2 , 1 ) . first
886
887
loc_path = loc . absolute_path || "!eval:#{ loc . path } "
888
+ loc_label = loc . base_label
889
+ loc_depth = DEBUGGER__ . frame_depth - 3
887
890
888
- # same stack depth
889
- ( DEBUGGER__ . frame_depth - 3 <= depth ) ||
890
-
891
- # different frame
892
- ( next_line && loc_path == path &&
893
- ( loc_lineno = loc . lineno ) > line &&
894
- loc_lineno <= next_line )
891
+ case
892
+ when loc_depth == depth && loc_label == label
893
+ true
894
+ when loc_depth < depth
895
+ # lower stack depth
896
+ true
897
+ when ( next_line &&
898
+ loc_path == path &&
899
+ ( loc_lineno = loc . lineno ) > line &&
900
+ loc_lineno <= next_line )
901
+ # different frame (maybe block) but the line is before next_line
902
+ true
903
+ end
895
904
end
896
905
break
897
906
898
907
when :finish
899
908
finish_frames = ( iter || 1 ) - 1
900
- goal_depth = @target_frames . first . frame_depth - finish_frames
909
+ frame = @target_frames . first
910
+ goal_depth = frame . frame_depth - finish_frames - ( frame . has_return_value ? 1 : 0 )
901
911
902
912
step_tp nil , [ :return , :b_return ] do
903
913
DEBUGGER__ . frame_depth - 3 <= goal_depth ? true : false
@@ -907,22 +917,25 @@ def wait_next_action_
907
917
when :until
908
918
location = iter &.strip
909
919
frame = @target_frames . first
910
- depth = frame . frame_depth
920
+ depth = frame . frame_depth - ( frame . has_return_value ? 1 : 0 )
911
921
target_location_label = frame . location . base_label
912
922
913
923
case location
914
924
when nil , /\A (?:(.+):)?(\d +)\z /
915
- file = $1
925
+ no_loc = !location
926
+ file = $1 || frame . location . path
916
927
line = ( $2 || frame . location . lineno + 1 ) . to_i
917
928
918
929
step_tp nil , [ :line , :return ] do |tp |
919
930
if tp . event == :line
920
- next true if file && tp . path . end_with? ( file )
921
- next true if tp . lineno >= line
931
+ next false if no_loc && depth < DEBUGGER__ . frame_depth - 3
932
+ next false unless tp . path . end_with? ( file )
933
+ next false unless tp . lineno >= line
934
+ true
922
935
else
923
- next true if depth >= DEBUGGER__ . frame_depth - 3 &&
924
- caller_locations ( 2 , 1 ) . first . label == target_location_label
925
- # TODO: imcomplete condition
936
+ true if depth >= DEBUGGER__ . frame_depth - 3 &&
937
+ caller_locations ( 2 , 1 ) . first . label == target_location_label
938
+ # TODO: imcomplete condition
926
939
end
927
940
end
928
941
else
@@ -934,11 +947,11 @@ def wait_next_action_
934
947
step_tp nil , [ :call , :c_call , :return ] do |tp |
935
948
case tp . event
936
949
when :call , :c_call
937
- next true if pat === tp . callee_id . to_s
950
+ true if pat === tp . callee_id . to_s
938
951
else # :return, :b_return
939
- next true if depth >= DEBUGGER__ . frame_depth - 3 &&
940
- caller_locations ( 2 , 1 ) . first . label == target_location_label
941
- # TODO: imcomplete condition
952
+ true if depth >= DEBUGGER__ . frame_depth - 3 &&
953
+ caller_locations ( 2 , 1 ) . first . label == target_location_label
954
+ # TODO: imcomplete condition
942
955
end
943
956
end
944
957
end
@@ -1181,6 +1194,8 @@ def wait_next_action_
1181
1194
rescue Exception => e
1182
1195
pp [ "DEBUGGER Exception: #{ __FILE__ } :#{ __LINE__ } " , e , e . backtrace ]
1183
1196
raise
1197
+ ensure
1198
+ @returning = false
1184
1199
end
1185
1200
1186
1201
def debug_event ( ev , args )
0 commit comments