22
22
23
23
int rb_vm_get_sourceline (const rb_control_frame_t * cfp ); /* from vm.c */
24
24
/* 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
26
28
VALUE rb_iseq_compile_with_option (VALUE src , VALUE file , VALUE filepath , VALUE line , VALUE opt );
27
29
#else
28
30
VALUE 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
502
504
debug_frame -> arg_ary = Qnil ;
503
505
debug_frame -> argc = GET_THREAD ()-> cfp -> iseq -> argc ;
504
506
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
505
510
debug_frame -> info .runtime .bp = GET_THREAD ()-> cfp -> bp ;
511
+ #endif
506
512
debug_frame -> info .runtime .block_iseq = GET_THREAD ()-> cfp -> block_iseq ;
507
513
debug_frame -> info .runtime .block_pc = NULL ;
508
514
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)
705
711
GET_THREAD ()-> parse_in_eval ++ ;
706
712
GET_THREAD ()-> mild_compile_error ++ ;
707
713
/* 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
709
718
catch_table -> iseq = rb_iseq_compile_with_option (
710
719
rb_str_new_cstr ("begin\nend" ), rb_str_new_cstr ("(exception catcher)" ), Qnil , INT2FIX (1 ), Qfalse );
711
720
#else
@@ -724,6 +733,7 @@ create_catch_table(debug_context_t *debug_context, unsigned long cont)
724
733
return (catch_table );
725
734
}
726
735
736
+ #ifdef RUBY_EVENT_VM
727
737
static int
728
738
set_thread_event_flag_i (st_data_t key , st_data_t val , st_data_t flag )
729
739
{
@@ -734,6 +744,7 @@ set_thread_event_flag_i(st_data_t key, st_data_t val, st_data_t flag)
734
744
735
745
return (ST_CONTINUE );
736
746
}
747
+ #endif
737
748
738
749
static void
739
750
debug_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
758
769
mid = iseq -> defined_method_id ;
759
770
klass = iseq -> klass ;
760
771
}
761
-
772
+ #ifdef ID_ALLOCATOR
762
773
if (mid == ID_ALLOCATOR ) return ;
774
+ #endif
763
775
764
776
/* return if thread is marked as 'ignored'.
765
777
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
806
818
debug_context -> old_iseq_catch = NULL ;
807
819
}
808
820
821
+ #ifdef RUBY_EVENT_VM
809
822
/* make sure all threads have event flag set so we'll get its events */
810
823
st_foreach (thread -> vm -> living_threads , set_thread_event_flag_i , 0 );
824
+ #endif
811
825
812
826
/* remove any frames that are now out of scope */
813
827
while (debug_context -> stack_size > 0 )
814
828
{
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
815
832
if (debug_context -> frames [debug_context -> stack_size - 1 ].info .runtime .bp <= thread -> cfp -> bp )
833
+ #endif
816
834
break ;
817
835
debug_context -> stack_size -- ;
818
836
}
@@ -988,7 +1006,11 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
988
1006
while (debug_context -> stack_size > 0 )
989
1007
{
990
1008
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
991
1012
if (debug_context -> frames [debug_context -> stack_size ].info .runtime .bp <= GET_THREAD ()-> cfp -> bp )
1013
+ #endif
992
1014
break ;
993
1015
}
994
1016
CTX_FL_SET (debug_context , CTX_FL_ENABLE_BKPT );
@@ -1932,8 +1954,11 @@ copy_scalar_args(debug_frame_t *debug_frame)
1932
1954
for (i = 0 ; i < iseq -> argc ; i ++ )
1933
1955
{
1934
1956
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
1936
1960
val = * (cfp -> dfp - iseq -> local_size + i );
1961
+ #endif
1937
1962
1938
1963
if (arg_value_is_small (val ))
1939
1964
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,
1994
2019
{
1995
2020
VALUE str = rb_id2str (iseq -> local_table [i ]);
1996
2021
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
1997
2025
rb_hash_aset (hash , str , * (cfp -> dfp - iseq -> local_size + i ));
2026
+ #endif
1998
2027
}
1999
2028
}
2000
2029
@@ -2012,7 +2041,11 @@ context_copy_locals(debug_context_t *debug_context, debug_frame_t *debug_frame,
2012
2041
{
2013
2042
VALUE str = rb_id2str (iseq -> local_table [i ]);
2014
2043
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
2015
2047
rb_hash_aset (hash , str , * (block_frame -> dfp - iseq -> local_table_size + i - 1 ));
2048
+ #endif
2016
2049
}
2017
2050
return (hash );
2018
2051
}
@@ -2479,11 +2512,24 @@ context_jump(VALUE self, VALUE line, VALUE file)
2479
2512
/* find target frame to jump to */
2480
2513
while (RUBY_VM_VALID_CONTROL_FRAME_P (cfp , cfp_end ))
2481
2514
{
2515
+ #ifdef HAVE_RB_ISEQ_T_LOCATION
2516
+ if ((cfp -> iseq != NULL ) && (rb_str_cmp (file , cfp -> iseq -> location .path ) == 0 ))
2517
+ #else
2482
2518
if ((cfp -> iseq != NULL ) && (rb_str_cmp (file , cfp -> iseq -> filename ) == 0 ))
2519
+ #endif
2483
2520
{
2521
+ #ifdef HAVE_RB_ISEQ_T_LINE_INFO_SIZE
2522
+ for (i = 0 ; i < cfp -> iseq -> line_info_size ; i ++ )
2523
+ #else
2484
2524
for (i = 0 ; i < cfp -> iseq -> insn_info_size ; i ++ )
2525
+ #endif
2485
2526
{
2527
+ #ifdef HAVE_RB_ISEQ_T_LINE_INFO_SIZE
2528
+ if (cfp -> iseq -> line_info_table [i ].line_no != line )
2529
+ #else
2486
2530
if (cfp -> iseq -> insn_info_table [i ].line_no != line )
2531
+ #endif
2532
+
2487
2533
continue ;
2488
2534
2489
2535
/* 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)
2493
2539
cfp_start -> pc [1 ] = (VALUE )do_jump ;
2494
2540
2495
2541
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
2496
2546
debug_context -> jump_pc =
2497
2547
cfp -> iseq -> iseq_encoded + cfp -> iseq -> insn_info_table [i ].position ;
2548
+ #endif
2498
2549
2499
2550
return (INT2FIX (0 )); /* success */
2500
2551
}
0 commit comments