Exemple #1
0
static void
exc_debug_info(mrb_state *mrb, struct RObject *exc)
{
  mrb_callinfo *ci = mrb->c->ci;
  mrb_code *pc = ci->pc;

  mrb_obj_iv_set(mrb, exc, mrb_intern_lit(mrb, "ciidx"), mrb_fixnum_value((mrb_int)(ci - mrb->c->cibase)));
  while (ci >= mrb->c->cibase) {
    mrb_code *err = ci->err;

    if (!err && pc) err = pc - 1;
    if (err && ci->proc && !MRB_PROC_CFUNC_P(ci->proc)) {
      mrb_irep *irep = ci->proc->body.irep;

      int32_t const line = mrb_debug_get_line(irep, (uint32_t)(err - irep->iseq));
      char const* file = mrb_debug_get_filename(irep, (uint32_t)(err - irep->iseq));
      if (line != -1 && file) {
        mrb_obj_iv_set(mrb, exc, mrb_intern_lit(mrb, "file"), mrb_str_new_cstr(mrb, file));
        mrb_obj_iv_set(mrb, exc, mrb_intern_lit(mrb, "line"), mrb_fixnum_value(line));
        return;
      }
    }
    pc = ci->pc;
    ci--;
  }
}
Exemple #2
0
static mrb_value
mrb_proc_inspect(mrb_state *mrb, mrb_value self)
{
  struct RProc *p = mrb_proc_ptr(self);
  mrb_value str = mrb_str_new_lit(mrb, "#<Proc:");
  mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_cptr(self)));

  if (!MRB_PROC_CFUNC_P(p)) {
    mrb_irep *irep = p->body.irep;
    const char *filename;
    int32_t line;
    mrb_str_cat_lit(mrb, str, "@");

    filename = mrb_debug_get_filename(irep, 0);
    mrb_str_cat_cstr(mrb, str, filename ? filename : "-");
    mrb_str_cat_lit(mrb, str, ":");

    line = mrb_debug_get_line(irep, 0);
    if (line != -1) {
      mrb_str_append(mrb, str, mrb_fixnum_value(line));
    }
    else {
      mrb_str_cat_lit(mrb, str, "-");
    }
  }

  if (MRB_PROC_STRICT_P(p)) {
    mrb_str_cat_lit(mrb, str, " (lambda)");
  }

  mrb_str_cat_lit(mrb, str, ">");
  return str;
}
Exemple #3
0
static void exc_debug_info(mrb_state *mrb, RObject *exc)
{
    mrb_callinfo *ci = mrb->m_ctx->m_ci;
    mrb_code *pc = ci->pc;

    exc->iv_set(mrb_intern(mrb, "ciidx", 5), mrb_fixnum_value(ci - mrb->m_ctx->cibase));

    while (ci >= mrb->m_ctx->cibase) {
        mrb_code *err = ci->err;

        if (!err && pc) err = pc - 1;
        if (err && ci->proc && !ci->proc->is_cfunc()) {
            mrb_irep *irep = ci->proc->ireps();
            int32_t const line = mrb_debug_get_line(irep, err - irep->iseq);
            char const* file = mrb_debug_get_filename(irep, err - irep->iseq);
            if (line != -1 && file) {
                exc->iv_set(mrb->intern2("file", 4), mrb_str_new_cstr(mrb, file)->wrap());
                exc->iv_set(mrb->intern2("line", 4), mrb_fixnum_value(line));
                return;
            }
        }
        pc = ci->pc;
        ci--;
    }
}
static mrb_bool
check_start_pc_for_line( mrb_irep *irep, mrb_code *pc, uint16_t line )
{
  if( pc > irep->iseq ) {
    if( line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
      return FALSE;
    }
  }
  return TRUE;
}
Exemple #5
0
static void
each_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, each_backtrace_func func, void *data)
{
  int i;

  if (ciidx >= mrb->c->ciend - mrb->c->cibase)
    ciidx = 10; /* ciidx is broken... */

  for (i = ciidx; i >= 0; i--) {
    struct backtrace_location_raw loc;
    mrb_callinfo *ci;
    mrb_irep *irep;
    mrb_code *pc;

    ci = &mrb->c->cibase[i];

    if (!ci->proc) continue;
    if (MRB_PROC_CFUNC_P(ci->proc)) continue;

    irep = ci->proc->body.irep;
    if (!irep) continue;

    if (mrb->c->cibase[i].err) {
      pc = mrb->c->cibase[i].err;
    }
    else if (i+1 <= ciidx) {
      pc = mrb->c->cibase[i+1].pc - 1;
    }
    else {
      pc = pc0;
    }
    loc.filename = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
    loc.lineno = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));

    if (loc.lineno == -1) continue;

    if (ci->target_class == ci->proc->target_class) {
      loc.sep = '.';
    }
    else {
      loc.sep = '#';
    }

    if (!loc.filename) {
      loc.filename = "(unknown)";
    }

    loc.method_id = ci->mid;
    loc.klass = ci->proc->target_class;
    loc.i = i;
    func(mrb, &loc, data);
  }
}
Exemple #6
0
static void
print_header(mrb_state *mrb, mrb_irep *irep, ptrdiff_t i)
{
  int32_t line;

  line = mrb_debug_get_line(mrb, irep, i);
  if (line < 0) {
    printf("      ");
  }
  else {
    printf("%5d ", line);
  }

  printf("%03d ", (int)i);
}
Exemple #7
0
static mrb_value
mrb_proc_source_location(mrb_state *mrb, mrb_value self)
{
    struct RProc *p = mrb_proc_ptr(self);

    if (MRB_PROC_CFUNC_P(p)) {
        return mrb_nil_value();
    }
    else {
        mrb_irep *irep = p->body.irep;
        int32_t line;
        const char *filename;

        filename = mrb_debug_get_filename(irep, 0);
        line = mrb_debug_get_line(irep, 0);

        return (!filename && line == -1)? mrb_nil_value()
               : mrb_assoc_new(mrb, mrb_str_new_cstr(mrb, filename), mrb_fixnum_value(line));
    }
}
Exemple #8
0
static void
output_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, output_stream_func func, void *stream)
{
  mrb_callinfo *ci;
  const char *filename, *method, *sep;
  int i, lineno, tracehead = 1;

  if (ciidx >= mrb->c->ciend - mrb->c->cibase)
    ciidx = 10; /* ciidx is broken... */

  for (i = ciidx; i >= 0; i--) {
    ci = &mrb->c->cibase[i];
    filename = NULL;
    lineno = -1;

    if (!ci->proc) continue;
    if (MRB_PROC_CFUNC_P(ci->proc)) {
      continue;
    }
    else {
      mrb_irep *irep = ci->proc->body.irep;
      mrb_code *pc;

      if (mrb->c->cibase[i].err) {
        pc = mrb->c->cibase[i].err;
      }
      else if (i+1 <= ciidx) {
        pc = mrb->c->cibase[i+1].pc - 1;
      }
      else {
        pc = pc0;
      }
      filename = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
      lineno = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));
    }
    if (lineno == -1) continue;
    if (ci->target_class == ci->proc->target_class)
      sep = ".";
    else
      sep = "#";

    if (!filename) {
      filename = "(unknown)";
    }

    if (tracehead) {
      func(mrb, stream, 1, "trace:\n");
      tracehead = 0;
    }
    method = mrb_sym2name(mrb, ci->mid);
    if (method) {
      const char *cn = mrb_class_name(mrb, ci->proc->target_class);

      if (cn) {
        func(mrb, stream, 1, "\t[%d] ", i);
        func(mrb, stream, 0, "%s:%d:in %s%s%s", filename, lineno, cn, sep, method);
        func(mrb, stream, 1, "\n");
      }
      else {
        func(mrb, stream, 1, "\t[%d] ", i);
        func(mrb, stream, 0, "%s:%d:in %s", filename, lineno, method);
        func(mrb, stream, 1, "\n");
      }
    }
    else {
        func(mrb, stream, 1, "\t[%d] ", i);
        func(mrb, stream, 0, "%s:%d", filename, lineno);
        func(mrb, stream, 1, "\n");
    }
  }
}
Exemple #9
0
static void
mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *regs)
{
  const char *file;
  int32_t line;
  int32_t bpno;

  mrb_debug_context *dbg = mrb_debug_context_get(mrb);

  mrb_assert(dbg);

  dbg->irep = irep;
  dbg->pc   = pc;
  dbg->regs = regs;

  if(dbg->xphase == DBG_PHASE_RESTART) {
    dbg->root_irep = irep;
    dbg->prvfile = NULL;
    dbg->prvline = 0;
    dbg->xm = DBG_RUN;
    dbg->xphase = DBG_PHASE_RUNNING;
  }

  file = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
  line = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));

  switch (dbg->xm) {
  case DBG_STEP:
  case DBG_NEXT:  // temporary
    if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
      return;
    }
    dbg->method_bpno = 0;
    dbg->bm = BRK_STEP;
    break;

  case DBG_RUN:
    bpno = check_method_breakpoint(mrb, irep, pc, regs);
    if (bpno > 0) {
      dbg->stopped_bpno = bpno;
      dbg->bm = BRK_BREAK;
      break;
    }
    if (dbg->prvfile != file || dbg->prvline != line) {
      bpno = mrb_debug_check_breakpoint_line(mrb, dbg, file, line);
      if (bpno > 0) {
        dbg->stopped_bpno = bpno;
        dbg->bm = BRK_BREAK;
        break;
      }
    }
    dbg->prvfile = file;
    dbg->prvline = line;
    return;
  case DBG_INIT:
    dbg->root_irep = irep;
    dbg->bm = BRK_INIT;
    if (!file || line < 0) {
      puts("Cannot get debugging information.");
    }
    break;

  default:
    return;
  }

  dbg->prvfile = file;
  dbg->prvline = line;

  if(dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
    return;
  }
  dbg->break_hook(mrb, dbg);

  dbg->xphase = DBG_PHASE_RUNNING;
}
Exemple #10
0
static void
codedump(mrb_state *mrb, mrb_irep *irep)
{
#ifndef MRB_DISABLE_STDIO
  int i;
  int ai;
  mrb_code c;
  const char *file = NULL, *next_file;
  int32_t line;

  if (!irep) return;
  printf("irep %p nregs=%d nlocals=%d pools=%d syms=%d reps=%d\n", (void*)irep,
         irep->nregs, irep->nlocals, (int)irep->plen, (int)irep->slen, (int)irep->rlen);

  for (i = 0; i < (int)irep->ilen; i++) {
    ai = mrb_gc_arena_save(mrb);

    next_file = mrb_debug_get_filename(irep, i);
    if (next_file && file != next_file) {
      printf("file: %s\n", next_file);
      file = next_file;
    }
    line = mrb_debug_get_line(irep, i);
    if (line < 0) {
      printf("      ");
    }
    else {
      printf("%5d ", line);
    }

    printf("%03d ", i);
    c = irep->iseq[i];
    switch (GET_OPCODE(c)) {
    case OP_NOP:
      printf("OP_NOP\n");
      break;
    case OP_MOVE:
      printf("OP_MOVE\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_LOADL:
      {
        mrb_value v = irep->pool[GETARG_Bx(c)];
        mrb_value s = mrb_inspect(mrb, v);
        printf("OP_LOADL\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));
      }
      print_lv(mrb, irep, c, RA);
      break;
    case OP_LOADI:
      printf("OP_LOADI\tR%d\t%d\t", GETARG_A(c), GETARG_sBx(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_LOADSYM:
      printf("OP_LOADSYM\tR%d\t:%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_LOADNIL:
      printf("OP_LOADNIL\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_LOADSELF:
      printf("OP_LOADSELF\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_LOADT:
      printf("OP_LOADT\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_LOADF:
      printf("OP_LOADF\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_GETGLOBAL:
      printf("OP_GETGLOBAL\tR%d\t:%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_SETGLOBAL:
      printf("OP_SETGLOBAL\t:%s\tR%d\t",
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
             GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_GETCONST:
      printf("OP_GETCONST\tR%d\t:%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_SETCONST:
      printf("OP_SETCONST\t:%s\tR%d\t",
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
             GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_GETMCNST:
      printf("OP_GETMCNST\tR%d\tR%d::%s", GETARG_A(c), GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_SETMCNST:
      printf("OP_SETMCNST\tR%d::%s\tR%d", GETARG_A(c)+1,
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
             GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_GETIV:
      printf("OP_GETIV\tR%d\t%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_SETIV:
      printf("OP_SETIV\t%s\tR%d",
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
             GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_GETUPVAR:
      printf("OP_GETUPVAR\tR%d\t%d\t%d",
             GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_SETUPVAR:
      printf("OP_SETUPVAR\tR%d\t%d\t%d",
             GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_GETCV:
      printf("OP_GETCV\tR%d\t%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_SETCV:
      printf("OP_SETCV\t%s\tR%d",
             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
             GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_JMP:
      printf("OP_JMP\t%03d\n", i+GETARG_sBx(c));
      break;
    case OP_JMPIF:
      printf("OP_JMPIF\tR%d\t%03d\n", GETARG_A(c), i+GETARG_sBx(c));
      break;
    case OP_JMPNOT:
      printf("OP_JMPNOT\tR%d\t%03d\n", GETARG_A(c), i+GETARG_sBx(c));
      break;
    case OP_SEND:
      printf("OP_SEND\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_SENDB:
      printf("OP_SENDB\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_TAILCALL:
      printf("OP_TAILCALL\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_SUPER:
      printf("OP_SUPER\tR%d\t%d\n", GETARG_A(c),
             GETARG_C(c));
      break;
    case OP_ARGARY:
      printf("OP_ARGARY\tR%d\t%d:%d:%d:%d", GETARG_A(c),
             (GETARG_Bx(c)>>10)&0x3f,
             (GETARG_Bx(c)>>9)&0x1,
             (GETARG_Bx(c)>>4)&0x1f,
             (GETARG_Bx(c)>>0)&0xf);
      print_lv(mrb, irep, c, RA);
      break;

    case OP_ENTER:
      printf("OP_ENTER\t%d:%d:%d:%d:%d:%d:%d\n",
             (GETARG_Ax(c)>>18)&0x1f,
             (GETARG_Ax(c)>>13)&0x1f,
             (GETARG_Ax(c)>>12)&0x1,
             (GETARG_Ax(c)>>7)&0x1f,
             (GETARG_Ax(c)>>2)&0x1f,
             (GETARG_Ax(c)>>1)&0x1,
             GETARG_Ax(c) & 0x1);
      break;
    case OP_RETURN:
      printf("OP_RETURN\tR%d", GETARG_A(c));
      switch (GETARG_B(c)) {
      case OP_R_NORMAL:
      case OP_R_RETURN:
        printf("\treturn\t"); break;
      case OP_R_BREAK:
        printf("\tbreak\t"); break;
      default:
        printf("\tbroken\t"); break;
        break;
      }
      print_lv(mrb, irep, c, RA);
      break;
    case OP_BLKPUSH:
      printf("OP_BLKPUSH\tR%d\t%d:%d:%d:%d", GETARG_A(c),
             (GETARG_Bx(c)>>10)&0x3f,
             (GETARG_Bx(c)>>9)&0x1,
             (GETARG_Bx(c)>>4)&0x1f,
             (GETARG_Bx(c)>>0)&0xf);
      print_lv(mrb, irep, c, RA);
      break;

    case OP_LAMBDA:
      printf("OP_LAMBDA\tR%d\tI(%+d)\t%d", GETARG_A(c), GETARG_b(c)+1, GETARG_c(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_RANGE:
      printf("OP_RANGE\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_METHOD:
      printf("OP_METHOD\tR%d\t:%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
      print_lv(mrb, irep, c, RA);
      break;

    case OP_ADD:
      printf("OP_ADD\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_ADDI:
      printf("OP_ADDI\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_SUB:
      printf("OP_SUB\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_SUBI:
      printf("OP_SUBI\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_MUL:
      printf("OP_MUL\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_DIV:
      printf("OP_DIV\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_LT:
      printf("OP_LT\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_LE:
      printf("OP_LE\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_GT:
      printf("OP_GT\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_GE:
      printf("OP_GE\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;
    case OP_EQ:
      printf("OP_EQ\tR%d\t:%s\t%d\n", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
             GETARG_C(c));
      break;

    case OP_STOP:
      printf("OP_STOP\n");
      break;

    case OP_ARRAY:
      printf("OP_ARRAY\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_ARYCAT:
      printf("OP_ARYCAT\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_ARYPUSH:
      printf("OP_ARYPUSH\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_AREF:
      printf("OP_AREF\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_APOST:
      printf("OP_APOST\tR%d\t%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_STRING:
      {
        mrb_value v = irep->pool[GETARG_Bx(c)];
        mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
        printf("OP_STRING\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));
      }
      print_lv(mrb, irep, c, RA);
      break;
    case OP_STRCAT:
      printf("OP_STRCAT\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_HASH:
      printf("OP_HASH\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
      print_lv(mrb, irep, c, RAB);
      break;

    case OP_OCLASS:
      printf("OP_OCLASS\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_CLASS:
      printf("OP_CLASS\tR%d\t:%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_MODULE:
      printf("OP_MODULE\tR%d\t:%s", GETARG_A(c),
             mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_EXEC:
      printf("OP_EXEC\tR%d\tI(%+d)", GETARG_A(c), GETARG_Bx(c)+1);
      print_lv(mrb, irep, c, RA);
      break;
    case OP_SCLASS:
      printf("OP_SCLASS\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
      print_lv(mrb, irep, c, RAB);
      break;
    case OP_TCLASS:
      printf("OP_TCLASS\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_ERR:
      {
        mrb_value v = irep->pool[GETARG_Bx(c)];
        mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
        printf("OP_ERR\t%s\n", RSTRING_PTR(s));
      }
      break;
    case OP_EPUSH:
      printf("OP_EPUSH\t:I(%+d)\n", GETARG_Bx(c)+1);
      break;
    case OP_ONERR:
      printf("OP_ONERR\t%03d\n", i+GETARG_sBx(c));
      break;
    case OP_RESCUE:
      printf("OP_RESCUE\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_RAISE:
      printf("OP_RAISE\tR%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_POPERR:
      printf("OP_POPERR\t%d\t\t", GETARG_A(c));
      print_lv(mrb, irep, c, RA);
      break;
    case OP_EPOP:
      printf("OP_EPOP\t%d\n", GETARG_A(c));
      break;

    default:
      printf("OP_unknown %d\t%d\t%d\t%d\n", GET_OPCODE(c),
             GETARG_A(c), GETARG_B(c), GETARG_C(c));
      break;
    }
    mrb_gc_arena_restore(mrb, ai);
  }
  printf("\n");
#endif
}