2222
2323int rb_vm_get_sourceline (const rb_control_frame_t * cfp ); /* from vm.c */
2424/* from iseq.c */
25- #ifdef RB_ISEQ_COMPILE_5ARGS
25+ #ifdef HAVE_RB_ISEQ_COMPILE_ON_BASE
26+ VALUE rb_iseq_compile_with_option (VALUE src , VALUE file , VALUE absolute_path , VALUE line , rb_block_t * base_block , VALUE opt );
27+ #elif RB_ISEQ_COMPILE_5ARGS
2628VALUE rb_iseq_compile_with_option (VALUE src , VALUE file , VALUE filepath , VALUE line , VALUE opt );
2729#else
2830VALUE rb_iseq_compile_with_option (VALUE src , VALUE file , VALUE line , VALUE opt );
@@ -502,7 +504,11 @@ save_call_frame(rb_event_flag_t _event, debug_context_t *debug_context, VALUE se
502504 debug_frame -> arg_ary = Qnil ;
503505 debug_frame -> argc = GET_THREAD ()-> cfp -> iseq -> argc ;
504506 debug_frame -> info .runtime .cfp = GET_THREAD ()-> cfp ;
507+ #if VM_DEBUG_BP_CHECK
508+ debug_frame -> info .runtime .bp_check = GET_THREAD ()-> cfp -> bp_check ;
509+ #else
505510 debug_frame -> info .runtime .bp = GET_THREAD ()-> cfp -> bp ;
511+ #endif
506512 debug_frame -> info .runtime .block_iseq = GET_THREAD ()-> cfp -> block_iseq ;
507513 debug_frame -> info .runtime .block_pc = NULL ;
508514 debug_frame -> info .runtime .last_pc = GET_THREAD ()-> cfp -> pc ;
@@ -705,7 +711,10 @@ create_catch_table(debug_context_t *debug_context, unsigned long cont)
705711 GET_THREAD ()-> parse_in_eval ++ ;
706712 GET_THREAD ()-> mild_compile_error ++ ;
707713 /* compiling with option Qfalse (no options) prevents debug hook calls during this catch routine */
708- #ifdef RB_ISEQ_COMPILE_5ARGS
714+ #ifdef HAVE_RB_ISEQ_COMPILE_ON_BASE
715+ catch_table -> iseq = rb_iseq_compile_with_option (
716+ rb_str_new_cstr ("begin\nend" ), rb_str_new_cstr ("(exception catcher)" ), Qnil , INT2FIX (1 ), NULL , Qfalse );
717+ #elif RB_ISEQ_COMPILE_5ARGS
709718 catch_table -> iseq = rb_iseq_compile_with_option (
710719 rb_str_new_cstr ("begin\nend" ), rb_str_new_cstr ("(exception catcher)" ), Qnil , INT2FIX (1 ), Qfalse );
711720#else
@@ -724,6 +733,7 @@ create_catch_table(debug_context_t *debug_context, unsigned long cont)
724733 return (catch_table );
725734}
726735
736+ #ifdef RUBY_EVENT_VM
727737static int
728738set_thread_event_flag_i (st_data_t key , st_data_t val , st_data_t flag )
729739{
@@ -734,6 +744,7 @@ set_thread_event_flag_i(st_data_t key, st_data_t val, st_data_t flag)
734744
735745 return (ST_CONTINUE );
736746}
747+ #endif
737748
738749static void
739750debug_event_hook (rb_event_flag_t event , VALUE data , VALUE self , ID mid , VALUE klass )
@@ -758,8 +769,9 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
758769 mid = iseq -> defined_method_id ;
759770 klass = iseq -> klass ;
760771 }
761-
772+ #ifdef ID_ALLOCATOR
762773 if (mid == ID_ALLOCATOR ) return ;
774+ #endif
763775
764776 /* return if thread is marked as 'ignored'.
765777 debugger's threads are marked this way
@@ -806,13 +818,19 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
806818 debug_context -> old_iseq_catch = NULL ;
807819 }
808820
821+ #ifdef RUBY_EVENT_VM
809822 /* make sure all threads have event flag set so we'll get its events */
810823 st_foreach (thread -> vm -> living_threads , set_thread_event_flag_i , 0 );
824+ #endif
811825
812826 /* remove any frames that are now out of scope */
813827 while (debug_context -> stack_size > 0 )
814828 {
829+ #if VM_DEBUG_BP_CHECK
830+ if (debug_context -> frames [debug_context -> stack_size - 1 ].info .runtime .bp_check <= thread -> cfp -> bp_check )
831+ #else
815832 if (debug_context -> frames [debug_context -> stack_size - 1 ].info .runtime .bp <= thread -> cfp -> bp )
833+ #endif
816834 break ;
817835 debug_context -> stack_size -- ;
818836 }
@@ -988,7 +1006,11 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
9881006 while (debug_context -> stack_size > 0 )
9891007 {
9901008 debug_context -> stack_size -- ;
1009+ #if VM_DEBUG_BP_CHECK
1010+ if (debug_context -> frames [debug_context -> stack_size ].info .runtime .bp_check <= GET_THREAD ()-> cfp -> bp_check )
1011+ #else
9911012 if (debug_context -> frames [debug_context -> stack_size ].info .runtime .bp <= GET_THREAD ()-> cfp -> bp )
1013+ #endif
9921014 break ;
9931015 }
9941016 CTX_FL_SET (debug_context , CTX_FL_ENABLE_BKPT );
@@ -1932,8 +1954,11 @@ copy_scalar_args(debug_frame_t *debug_frame)
19321954 for (i = 0 ; i < iseq -> argc ; i ++ )
19331955 {
19341956 if (!rb_is_local_id (iseq -> local_table [i ])) continue ; /* skip flip states */
1935-
1957+ #ifdef HAVE_RB_CONTROL_FRAME_T_EP
1958+ val = * (cfp -> ep - iseq -> local_size + i );
1959+ #else
19361960 val = * (cfp -> dfp - iseq -> local_size + i );
1961+ #endif
19371962
19381963 if (arg_value_is_small (val ))
19391964 rb_ary_push (debug_frame -> arg_ary , val );
@@ -1994,7 +2019,11 @@ context_copy_locals(debug_context_t *debug_context, debug_frame_t *debug_frame,
19942019 {
19952020 VALUE str = rb_id2str (iseq -> local_table [i ]);
19962021 if (str != 0 )
2022+ #ifdef HAVE_RB_CONTROL_FRAME_T_EP
2023+ rb_hash_aset (hash , str , * (cfp -> ep - iseq -> local_size + i ));
2024+ #else
19972025 rb_hash_aset (hash , str , * (cfp -> dfp - iseq -> local_size + i ));
2026+ #endif
19982027 }
19992028 }
20002029
@@ -2012,7 +2041,11 @@ context_copy_locals(debug_context_t *debug_context, debug_frame_t *debug_frame,
20122041 {
20132042 VALUE str = rb_id2str (iseq -> local_table [i ]);
20142043 if (str != 0 )
2044+ #ifdef HAVE_RB_CONTROL_FRAME_T_EP
2045+ rb_hash_aset (hash , str , * (block_frame -> ep - iseq -> local_table_size + i - 1 ));
2046+ #else
20152047 rb_hash_aset (hash , str , * (block_frame -> dfp - iseq -> local_table_size + i - 1 ));
2048+ #endif
20162049 }
20172050 return (hash );
20182051 }
@@ -2479,11 +2512,24 @@ context_jump(VALUE self, VALUE line, VALUE file)
24792512 /* find target frame to jump to */
24802513 while (RUBY_VM_VALID_CONTROL_FRAME_P (cfp , cfp_end ))
24812514 {
2515+ #ifdef HAVE_RB_ISEQ_T_LOCATION
2516+ if ((cfp -> iseq != NULL ) && (rb_str_cmp (file , cfp -> iseq -> location .path ) == 0 ))
2517+ #else
24822518 if ((cfp -> iseq != NULL ) && (rb_str_cmp (file , cfp -> iseq -> filename ) == 0 ))
2519+ #endif
24832520 {
2521+ #ifdef HAVE_RB_ISEQ_T_LINE_INFO_SIZE
2522+ for (i = 0 ; i < cfp -> iseq -> line_info_size ; i ++ )
2523+ #else
24842524 for (i = 0 ; i < cfp -> iseq -> insn_info_size ; i ++ )
2525+ #endif
24852526 {
2527+ #ifdef HAVE_RB_ISEQ_T_LINE_INFO_SIZE
2528+ if (cfp -> iseq -> line_info_table [i ].line_no != line )
2529+ #else
24862530 if (cfp -> iseq -> insn_info_table [i ].line_no != line )
2531+ #endif
2532+
24872533 continue ;
24882534
24892535 /* hijack the currently running code so that we can change the frame PC */
@@ -2493,8 +2539,13 @@ context_jump(VALUE self, VALUE line, VALUE file)
24932539 cfp_start -> pc [1 ] = (VALUE )do_jump ;
24942540
24952541 debug_context -> jump_cfp = cfp ;
2542+ #ifdef HAVE_RB_ISEQ_T_LINE_INFO_SIZE
2543+ debug_context -> jump_pc =
2544+ cfp -> iseq -> iseq_encoded + cfp -> iseq -> line_info_table [i ].position ;
2545+ #else
24962546 debug_context -> jump_pc =
24972547 cfp -> iseq -> iseq_encoded + cfp -> iseq -> insn_info_table [i ].position ;
2548+ #endif
24982549
24992550 return (INT2FIX (0 )); /* success */
25002551 }
0 commit comments