Beispiel #1
0
static void
raise_event(VALUE trace_point, void *data)
{
  VALUE expn_class, ancestors;
  VALUE path, lineno, binding, post_mortem_context;
  int i;
  debug_context_t *new_dc;

  EVENT_SETUP;

  path = rb_tracearg_path(trace_arg);
  lineno = rb_tracearg_lineno(trace_arg);
  binding = rb_tracearg_binding(trace_arg);
  raised_exception = rb_tracearg_raised_exception(trace_arg);

  if (post_mortem == Qtrue)
  {
    post_mortem_context = context_dup(dc);
    rb_ivar_set(raised_exception, rb_intern("@__bb_file"), path);
    rb_ivar_set(raised_exception, rb_intern("@__bb_line"), lineno);
    rb_ivar_set(raised_exception, rb_intern("@__bb_binding"), binding);
    rb_ivar_set(raised_exception, rb_intern("@__bb_context"),
                post_mortem_context);

    Data_Get_Struct(post_mortem_context, debug_context_t, new_dc);
    rb_debug_inspector_open(context_backtrace_set, (void *)new_dc);
  }

  if (catchpoints == Qnil || dc->calced_stack_size == 0
      || RHASH_TBL(catchpoints)->num_entries == 0)
  {
    EVENT_TEARDOWN;
    return;
  }

  expn_class = rb_obj_class(raised_exception);
  ancestors = rb_mod_ancestors(expn_class);
  for (i = 0; i < RARRAY_LENINT(ancestors); i++)
  {
    VALUE ancestor_class, module_name, hit_count;

    ancestor_class = rb_ary_entry(ancestors, i);
    module_name = rb_mod_name(ancestor_class);
    hit_count = rb_hash_aref(catchpoints, module_name);

    /* increment exception */
    if (hit_count != Qnil)
    {
      rb_hash_aset(catchpoints, module_name, INT2FIX(FIX2INT(hit_count) + 1));
      call_at_catchpoint(context, dc, raised_exception);
      call_at_line(context, dc, path, lineno);
      break;
    }
  }

  EVENT_TEARDOWN;
}
Beispiel #2
0
/*
 * Value from exception raised on the +:raise+ event
 */
static VALUE
tracepoint_attr_raised_exception(VALUE tpval)
{
    return rb_tracearg_raised_exception(get_trace_arg());
}