Ejemplo n.º 1
0
extern void 
fill_stack(debug_context_t *context, const rb_debug_inspector_t *inspector) {
  debug_frame_t *frame;
  VALUE locations;
  VALUE location;
  VALUE path;
  VALUE lineno;
  const char *file;
  int line;
  int stack_size;
  int i;

  locations = rb_debug_inspector_backtrace_locations(inspector);
  stack_size = locations == Qnil ? 0 : RARRAY_LENINT(locations);
  context->stack_size = stack_size;

  for (i = 0; i < stack_size; i++) {
    frame = ALLOC(debug_frame_t);
    location = rb_ary_entry(locations, i);
    path = rb_funcall(location, rb_intern("path"), 0);
    lineno = rb_funcall(location, rb_intern("lineno"), 0);
    file = path != Qnil ? RSTRING_PTR(path) : "";
    line = FIX2INT(lineno);
    fill_frame(frame, file, line, rb_debug_inspector_frame_binding_get(inspector, i), rb_debug_inspector_frame_self_get(inspector, i));
    frame->prev = context->stack;
    context->stack = frame;
  }
}
Ejemplo n.º 2
0
static VALUE
load_backtrace(const rb_debug_inspector_t *inspector)
{
  VALUE backtrace = rb_ary_new();
  VALUE locs = rb_debug_inspector_backtrace_locations(inspector);
  int i;

  for (i=0; i<RARRAY_LENINT(locs); i++)
  {
    VALUE frame = rb_ary_new();
    rb_ary_push(frame, rb_ary_entry(locs, i));
    rb_ary_push(frame, rb_debug_inspector_frame_self_get(inspector, i));
    rb_ary_push(frame, rb_debug_inspector_frame_class_get(inspector, i));
    rb_ary_push(frame, rb_debug_inspector_frame_binding_get(inspector, i));

    rb_ary_push(backtrace, frame);
  }

  return backtrace;
}
Ejemplo n.º 3
0
static VALUE
di_binding(VALUE self, VALUE index)
{
    const rb_debug_inspector_t *dc = di_get_dc(self);
    return rb_debug_inspector_frame_binding_get(dc, NUM2INT(index));
}