diff --git a/ext/-test-/debug/profile_frames.c b/ext/-test-/debug/profile_frames.c index d2bba7d183..f9a77a5a78 100644 --- a/ext/-test-/debug/profile_frames.c +++ b/ext/-test-/debug/profile_frames.c @@ -37,8 +37,29 @@ profile_frames(VALUE self, VALUE start_v, VALUE num_v) return result; } +static VALUE +profile_thread_frames(VALUE self, VALUE thread, VALUE start_v, VALUE num_v) +{ + int i, collected_size; + int start = NUM2INT(start_v); + int buff_size = NUM2INT(num_v); + VALUE buff[MAX_BUF_SIZE]; + int lines[MAX_BUF_SIZE]; + VALUE result = rb_ary_new(); + + if (buff_size > MAX_BUF_SIZE) rb_raise(rb_eRuntimeError, "too long buff_size"); + + collected_size = rb_profile_thread_frames(thread, start, buff_size, buff, lines); + for (i=0; ibacktrace; } -int -rb_profile_frames(int start, int limit, VALUE *buff, int *lines) +static int +thread_profile_frames(rb_execution_context_t *ec, int start, int limit, VALUE *buff, int *lines) { int i; - const rb_execution_context_t *ec = GET_EC(); const rb_control_frame_t *cfp = ec->cfp, *end_cfp = RUBY_VM_END_CONTROL_FRAME(ec); const rb_control_frame_t *top = cfp; const rb_callable_method_entry_t *cme; @@ -1650,6 +1649,20 @@ rb_profile_frames(int start, int limit, VALUE *buff, int *lines) return i; } +int +rb_profile_frames(int start, int limit, VALUE *buff, int *lines) +{ + rb_execution_context_t *ec = GET_EC(); + return thread_profile_frames(ec, start, limit, buff, lines); +} + +int +rb_profile_thread_frames(VALUE thread, int start, int limit, VALUE *buff, int *lines) +{ + rb_thread_t *th = rb_thread_ptr(thread); + return thread_profile_frames(th->ec, start, limit, buff, lines); +} + static const rb_iseq_t * frame2iseq(VALUE frame) {