Skip to content

Commit 3f4cae4

Browse files
committed
use rb_debug_inspector_frame_depth
Use `rb_debug_inspector_frame_depth()` from Ruby 3.2.
1 parent 3e3f374 commit 3f4cae4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ext/debug/debug.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ di_body(const rb_debug_inspector_t *dc, void *ptr)
7676
rb_debug_inspector_frame_binding_get(dc, i),
7777
iseq,
7878
rb_debug_inspector_frame_class_get(dc, i),
79-
INT2FIX(len - i));
79+
#ifdef RB_DEBUG_INSPECTOR_FRAME_DEPTH
80+
rb_debug_inspector_frame_depth(dc, i)
81+
#else
82+
INT2FIX(len - i)
83+
#endif
84+
);
8085
rb_ary_push(ary, e);
8186
}
8287

@@ -89,13 +94,22 @@ capture_frames(VALUE self, VALUE skip_path_prefix)
8994
return rb_debug_inspector_open(di_body, (void *)skip_path_prefix);
9095
}
9196

97+
#ifdef RB_DEBUG_INSPECTOR_FRAME_DEPTH
98+
static VALUE
99+
frame_depth(VALUE self)
100+
{
101+
return rb_debug_inspector_current_depth();
102+
}
103+
#else
92104
static VALUE
93105
frame_depth(VALUE self)
94106
{
95107
// TODO: more efficient API
96108
VALUE bt = rb_make_backtrace();
97109
return INT2FIX(RARRAY_LEN(bt));
98110
}
111+
#endif
112+
99113

100114
// iseq
101115

0 commit comments

Comments
 (0)