|
9 | 9 | #include <insns_info.inc> |
10 | 10 | #include "ruby_debug.h" |
11 | 11 |
|
12 | | -#define DEBUG_VERSION "0.11.30.pre" |
| 12 | +#define DEBUG_VERSION "0.11.30.pre2" |
13 | 13 |
|
14 | 14 | #define FRAME_N(n) (&debug_context->frames[debug_context->stack_size-(n)-1]) |
15 | 15 | #define GET_FRAME (FRAME_N(check_frame_number(debug_context, frame))) |
@@ -857,6 +857,35 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl |
857 | 857 | save_call_frame(event, debug_context, self, file, line, mid); |
858 | 858 | else |
859 | 859 | set_frame_source(event, debug_context, self, file, line, mid); |
| 860 | + if (CTX_FL_TEST(debug_context, CTX_FL_CATCHING)) |
| 861 | + { |
| 862 | + debug_frame_t *top_frame = get_top_frame(debug_context); |
| 863 | + |
| 864 | + if (top_frame != NULL) |
| 865 | + { |
| 866 | + rb_control_frame_t *cfp = top_frame->info.runtime.cfp; |
| 867 | + VALUE hit_count; |
| 868 | + |
| 869 | + /* restore the proper catch table */ |
| 870 | + cfp->iseq->catch_table_size = debug_context->catch_table.old_catch_table_size; |
| 871 | + cfp->iseq->catch_table = debug_context->catch_table.old_catch_table; |
| 872 | + |
| 873 | + /* send catchpoint notification */ |
| 874 | + int c_hit_count = FIX2INT(rb_hash_aref(rdebug_catchpoints, debug_context->catch_table.mod_name)) + 1; |
| 875 | + hit_count = INT2FIX(c_hit_count); |
| 876 | + rb_hash_aset(rdebug_catchpoints, debug_context->catch_table.mod_name, hit_count); |
| 877 | + debug_context->stop_reason = CTX_STOP_CATCHPOINT; |
| 878 | + rb_funcall(context, idAtCatchpoint, 1, debug_context->catch_table.errinfo); |
| 879 | + if(self && binding == Qnil) |
| 880 | + binding = create_binding(self); |
| 881 | + save_top_binding(debug_context, binding); |
| 882 | + call_at_line(context, debug_context, rb_str_new2(file), INT2FIX(line)); |
| 883 | + } |
| 884 | + |
| 885 | + /* now allow the next exception to be caught */ |
| 886 | + CTX_FL_UNSET(debug_context, CTX_FL_CATCHING); |
| 887 | + break; |
| 888 | + } |
860 | 889 |
|
861 | 890 | if(RTEST(tracing) || CTX_FL_TEST(debug_context, CTX_FL_TRACING)) |
862 | 891 | rb_funcall(context, idAtTracing, 2, rb_str_new2(file), INT2FIX(line)); |
@@ -971,7 +1000,7 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl |
971 | 1000 | VALUE expn_class, aclass; |
972 | 1001 | int i; |
973 | 1002 |
|
974 | | -// set_frame_source(event, debug_context, self, file, line, mid); |
| 1003 | + set_frame_source(event, debug_context, self, file, line, mid); |
975 | 1004 |
|
976 | 1005 | if(post_mortem == Qtrue && self) |
977 | 1006 | { |
@@ -1026,18 +1055,17 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl |
1026 | 1055 | debug_frame_t *top_frame = get_top_frame(debug_context); |
1027 | 1056 | rb_control_frame_t *cfp = top_frame->info.runtime.cfp; |
1028 | 1057 |
|
1029 | | - /* send catchpoint notification */ |
1030 | | - int c_hit_count = FIX2INT(rb_hash_aref(rdebug_catchpoints, mod_name)) + 1; |
1031 | | - hit_count = INT2FIX(c_hit_count); |
1032 | | - rb_hash_aset(rdebug_catchpoints, mod_name, hit_count); |
1033 | | - debug_context->stop_reason = CTX_STOP_CATCHPOINT; |
1034 | | - rb_funcall(context, idAtCatchpoint, 1, rb_errinfo()); |
1035 | | - |
1036 | | - if(self && binding == Qnil) |
1037 | | - binding = create_binding(self); |
1038 | | - save_top_binding(debug_context, binding); |
1039 | | - call_at_line(context, debug_context, rb_str_new2(file), INT2FIX(line)); |
1040 | | - break; |
| 1058 | + /* save the current catch table */ |
| 1059 | + CTX_FL_SET(debug_context, CTX_FL_CATCHING); |
| 1060 | + debug_context->catch_table.old_catch_table_size = cfp->iseq->catch_table_size; |
| 1061 | + debug_context->catch_table.old_catch_table = cfp->iseq->catch_table; |
| 1062 | + debug_context->catch_table.mod_name = mod_name; |
| 1063 | + debug_context->catch_table.errinfo = rb_errinfo(); |
| 1064 | + |
| 1065 | + /* create a new catch table to catch this exception, and put it in the current iseq */ |
| 1066 | + cfp->iseq->catch_table_size = 1; |
| 1067 | + cfp->iseq->catch_table = |
| 1068 | + create_catch_table(debug_context, top_frame->info.runtime.last_pc - cfp->iseq->iseq_encoded - insn_len(BIN(trace))); |
1041 | 1069 | } |
1042 | 1070 | } |
1043 | 1071 |
|
|
0 commit comments