diff --git a/ext/debug/debug.c b/ext/debug/debug.c index b27263d46..e1ae28148 100644 --- a/ext/debug/debug.c +++ b/ext/debug/debug.c @@ -56,15 +56,23 @@ static VALUE di_body(const rb_debug_inspector_t *dc, void *ptr) { VALUE skip_path_prefix = (VALUE)ptr; +#if defined(HAVE_RB_DEBUG_INSPECTOR_FRAME_COUNT) && defined(HAVE_RB_DEBUG_INSPECTOR_FRAME_LOC_GET) + long len = rb_debug_inspector_frame_count(dc); +#else VALUE locs = rb_debug_inspector_backtrace_locations(dc); - VALUE ary = rb_ary_new(); long len = RARRAY_LEN(locs); +#endif + VALUE ary = rb_ary_new(); long i; for (i=1; i= '3.1.0' $defs << '-DHAVE_RB_ISEQ_TYPE' @@ -22,6 +24,11 @@ # from Ruby 3.1 have_func "rb_iseq_type(NULL)", [["VALUE rb_iseq_type(void *);"]] + # from Ruby 3.5 + have_func "rb_debug_inspector_frame_count(NULL)", + [["VALUE rb_debug_inspector_frame_count(void *);"]] + have_func "rb_debug_inspector_frame_loc_get(NULL, 0)", + [["VALUE rb_debug_inspector_frame_loc_get(void *, int index);"]] end create_makefile 'debug/debug' diff --git a/test/console/nested_break_test.rb b/test/console/nested_break_test.rb index d7e2437e5..f038d0fa6 100644 --- a/test/console/nested_break_test.rb +++ b/test/console/nested_break_test.rb @@ -83,7 +83,7 @@ def test_multiple_nested_break assert_line_num 2 type 'p foo(142)' type 'bt' - assert_line_text(/\#7\s+
/) # TODO: can be changed + assert_line_text(/\#11\s+
/) # TODO: can be changed type 'c' assert_line_text(/143/) diff --git a/test/console/trap_test.rb b/test/console/trap_test.rb index 17c4ccfa7..0f18e14ac 100644 --- a/test/console/trap_test.rb +++ b/test/console/trap_test.rb @@ -16,7 +16,6 @@ def test_sigint debug_code program, remote: false do type 'b 3' type 'c' - assert_line_num 2 assert_line_text(/is registered as SIGINT handler/) type 'sigint' assert_line_num 3