Created hook at VM code fetch. It's for debugger

This commit is contained in:
Yuichiro MASUI
2013-02-17 00:13:42 +09:00
parent 92cf2a0ced
commit bc44d06c73
3 changed files with 17 additions and 3 deletions
+4
View File
@@ -50,6 +50,7 @@
//#define DISABLE_TIME /* Time class */
//#define DISABLE_STRUCT /* Struct class */
//#define DISABLE_STDIO /* use of stdio */
//#define DISABLE_DEBUG /* hooks for debugger */
/* Now DISABLE_GEMS is added as a command line flag in Rakefile, */
/* we do not need to set it here. */
@@ -118,6 +119,9 @@ typedef short mrb_sym;
#ifndef DISABLE_STDIO
#define ENABLE_STDIO
#endif
#ifndef DISABLE_DEBUG
#define ENABLE_DEBUG
#endif
#ifndef FALSE
# define FALSE 0
+4
View File
@@ -133,6 +133,10 @@ typedef struct mrb_state {
struct RNode *local_svar;/* regexp */
#endif
#ifdef ENABLE_DEBUG
void (*hook_vm_fetch_code)(struct mrb_state* mrb, struct mrb_irep *irep, mrb_code *pc, mrb_value *regs);
#endif
struct RClass *eException_class;
struct RClass *eStandardError_class;
+9 -3
View File
@@ -480,13 +480,19 @@ argnum_error(mrb_state *mrb, int num)
mrb->exc = (struct RObject*)mrb_object(exc);
}
#ifdef ENABLE_DEBUG
#define HOOK_MRB_VM_FETCH_CODE(mrb, irep, pc, regs) ((mrb)->hook_vm_fetch_code ? (mrb)->hook_vm_fetch_code((mrb), (irep), (pc), (regs)) : NULL)
#else
#define HOOK_MRB_VM_FETCH_CODE(mrb, irep, pc, regs)
#endif
#ifdef __GNUC__
#define DIRECT_THREADED
#endif
#ifndef DIRECT_THREADED
#define INIT_DISPATCH for (;;) { i = *pc; switch (GET_OPCODE(i)) {
#define INIT_DISPATCH for (;;) { i = *pc; HOOK_MRB_VM_FETCH_CODE(mrb, irep, pc, regs); switch (GET_OPCODE(i)) {
#define CASE(op) case op:
#define NEXT pc++; break
#define JUMP break
@@ -496,8 +502,8 @@ argnum_error(mrb_state *mrb, int num)
#define INIT_DISPATCH JUMP; return mrb_nil_value();
#define CASE(op) L_ ## op:
#define NEXT i=*++pc; goto *optable[GET_OPCODE(i)]
#define JUMP i=*pc; goto *optable[GET_OPCODE(i)]
#define NEXT i=*++pc; HOOK_MRB_VM_FETCH_CODE(mrb, irep, pc, regs); goto *optable[GET_OPCODE(i)]
#define JUMP i=*pc; HOOK_MRB_VM_FETCH_CODE(mrb, irep, pc, regs); goto *optable[GET_OPCODE(i)]
#define END_DISPATCH