From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/ext/-test-/debug/profile_frames.c | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 jni/ruby/ext/-test-/debug/profile_frames.c (limited to 'jni/ruby/ext/-test-/debug/profile_frames.c') diff --git a/jni/ruby/ext/-test-/debug/profile_frames.c b/jni/ruby/ext/-test-/debug/profile_frames.c new file mode 100644 index 0000000..1656ff7 --- /dev/null +++ b/jni/ruby/ext/-test-/debug/profile_frames.c @@ -0,0 +1,43 @@ +#include "ruby/ruby.h" +#include "ruby/debug.h" + +#define MAX_BUF_SIZE 0x100 + +static VALUE +profile_frames(VALUE self, 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_frames(start, buff_size, buff, lines); + + for (i=0; i