Bytecode support for `mrdb`.
MODIFY
include/mruby/irep.h
include/mruby/irep.h
@@ -58,6 +58,15 @@ void mrb_irep_decref(mrb_state*, struct mrb_irep*);
void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
+struct mrb_insn_data {
+ uint8_t insn;
+ uint16_t a;
+ uint16_t b;
+ uint8_t c;
+};
+
+struct mrb_insn_data mrb_decode_insn(mrb_code *pc);
+
MRB_END_DECL
#endif /* MRUBY_IREP_H */

MODIFY
mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
@@ -510,6 +510,7 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value
mrb_sym sym;
int32_t bpno;
mrb_bool isCfunc;
+ struct mrb_insn_data insn;
mrb_debug_context *dbg = mrb_debug_context_get(mrb);
@@ -517,11 +518,12 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value
bpno = dbg->method_bpno;
dbg->method_bpno = 0;
- switch(*pc) {
+ insn = mrb_decode_insn(pc);
+ switch(insn.insn) {
case OP_SEND:
case OP_SENDB:
- c = mrb_class(mrb, regs[GETARG_A(*pc)]);
- sym = irep->syms[GETARG_B(*pc)];
+ c = mrb_class(mrb, regs[insn.a]);
+ sym = irep->syms[insn.b];
break;
case OP_SUPER:
c = mrb->c->ci->target_class->super;

MODIFY
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
@@ -296,15 +296,8 @@ on_eval(codegen_scope *s)
return FALSE;
}
-struct mrb_insn_data {
- uint8_t insn;
- uint16_t a;
- uint16_t b;
- uint8_t c;
-};
-
struct mrb_insn_data
-mrb_decode_insn(codegen_scope *s, mrb_code *pc)
+mrb_decode_insn(mrb_code *pc)
{
struct mrb_insn_data data = { 0 };
mrb_code insn = READ_B();
@@ -353,7 +346,7 @@ mrb_decode_insn(codegen_scope *s, mrb_code *pc)
return data;
}
-struct mrb_insn_data
+static struct mrb_insn_data
mrb_last_insn(codegen_scope *s)
{
if (s->pc == s->lastpc) {
@@ -362,7 +355,7 @@ mrb_last_insn(codegen_scope *s)
data.insn = OP_NOP;
return data;
}
- return mrb_decode_insn(s, &s->iseq[s->lastpc]);
+ return mrb_decode_insn(&s->iseq[s->lastpc]);
}
static mrb_bool

Bytecode support for `mrdb`.