#include "ruby/ruby.h" #include "ruby/debug.h" #include "ruby/encoding.h" // static VALUE rb_mDebugger; // iseq typedef struct rb_iseq_struct rb_iseq_t; VALUE rb_iseq_realpath(const rb_iseq_t *iseq); static VALUE iseq_realpath(VALUE iseqw) { rb_iseq_t *iseq = DATA_PTR(iseqw); return rb_iseq_realpath(iseq); } static VALUE rb_cFrameInfo; static VALUE di_entry(VALUE loc, VALUE self, VALUE binding, VALUE iseq, VALUE klass, VALUE depth) { return rb_struct_new(rb_cFrameInfo, loc, self, binding, iseq, klass, depth, Qnil, Qnil, Qnil, Qnil, Qnil); } static int str_start_with(VALUE str, VALUE prefix) { StringValue(prefix); rb_enc_check(str, prefix); if (RSTRING_LEN(str) >= RSTRING_LEN(prefix) && memcmp(RSTRING_PTR(str), RSTRING_PTR(prefix), RSTRING_LEN(prefix)) == 0) { return 1; } else { return 0; } } static VALUE di_body(const rb_debug_inspector_t *dc, void *ptr) { VALUE skip_path_prefix = (VALUE)ptr; VALUE locs = rb_debug_inspector_backtrace_locations(dc); VALUE ary = rb_ary_new(); long len = RARRAY_LEN(locs); long i; for (i=1; i