 +        th->event_flags |= (RUBY_EVENT_VM | RUBY_EVENT_BRKPT);
      }
      else {
- 	th->event_flags &= (~RUBY_EVENT_VM);
-@@ -3785,15 +3797,39 @@
+-	th->event_flags &= (~RUBY_EVENT_VM);
++        th->event_flags &= (~RUBY_EVENT_VM);
+     }
+     return ST_CONTINUE;
+ }
+@@ -3772,9 +3784,9 @@
+ exec_event_hooks(const rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
+ {
+     for (; hook; hook = hook->next) {
+-	if (flag & hook->flag) {
+-	    (*hook->func)(flag, hook->data, self, id, klass);
+-	}
++        if (flag & hook->flag) {
++            (*hook->func)(flag, hook->data, self, id, klass);
++        }
+     }
+ }
+ 
+@@ -3785,16 +3797,40 @@
      const rb_event_flag_t wait_event = th->event_flags;
  
      if (self == rb_mRubyVMFrozenCore) return;
 -    if (wait_event & flag) {
 -	exec_event_hooks(th->event_hooks, flag, self, id, klass);
 +    if (wait_event & flag && th->tracing <= 0) {
-+	if (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, th->cfp)
-+	      && !(th->cfp->tracing & VM_FRAME_TRACE_OFF))
-+	    exec_event_hooks(th->event_hooks, flag, self, id, klass);
++        if (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, th->cfp)
++              && !(th->cfp->tracing & VM_FRAME_TRACE_OFF))
++            exec_event_hooks(th->event_hooks, flag, self, id, klass);
      }
 -    if (wait_event & RUBY_EVENT_VM) {
+-	if (th->vm->event_hooks == NULL) {
+-	    th->event_flags &= (~RUBY_EVENT_VM);
+-	}
+-	else {
+-	    exec_event_hooks(th->vm->event_hooks, flag, self, id, klass);
+-	}
 +    if (wait_event & RUBY_EVENT_VM && th->tracing <= 0) {
- 	if (th->vm->event_hooks == NULL) {
- 	    th->event_flags &= (~RUBY_EVENT_VM);
- 	}
- 	else {
--	    exec_event_hooks(th->vm->event_hooks, flag, self, id, klass);
-+	    if (0 == th->exec_event_tracing) {
-+		/* Modified from ruby_suppress_tracing */
-+		int state;
-+		volatile int raised = rb_threadptr_reset_raised(th);
-+		rb_block_t * base_block_save = th->base_block;
-+		th->exec_event_tracing = 1;
-+		
-+		PUSH_TAG();
-+		if ((state = EXEC_TAG()) == 0) {
-+		    exec_event_hooks(th->vm->event_hooks, flag, self, id, klass);
-+		}
-+		
-+		th->base_block = base_block_save;
-+		if (raised) {
-+		    rb_threadptr_set_raised(th);
-+		}
-+		POP_TAG();
-+		
-+		th->exec_event_tracing = 0;
-+		if (state) {
-+		    JUMP_TAG(state);
-+		}
-+	    }
- 	}
++        if (th->vm->event_hooks == NULL) {
++            th->event_flags &= (~RUBY_EVENT_VM);
++        }
++        else {
++            if (0 == th->exec_event_tracing) {
++                /* Modified from ruby_suppress_tracing */
++                int state;
++                volatile int raised = rb_threadptr_reset_raised(th);
++                rb_block_t * base_block_save = th->base_block;
++                th->exec_event_tracing = 1;
++                
++                PUSH_TAG();
++                if ((state = EXEC_TAG()) == 0) {
++                    exec_event_hooks(th->vm->event_hooks, flag, self, id, klass);
++                }
++                
++                th->base_block = base_block_save;
++                if (raised) {
++                    rb_threadptr_set_raised(th);
++                }
++                POP_TAG();
++                
++                th->exec_event_tracing = 0;
++                if (state) {
++                    JUMP_TAG(state);
++                }
++            }
++        }
      }
      th->errinfo = errinfo;
+ }
+@@ -3817,20 +3853,20 @@
+     rb_event_hook_t *prev = NULL, *hook = *root, *next;
+ 
+     while (hook) {
+-	next = hook->next;
+-	if (func == 0 || hook->func == func) {
+-	    if (prev) {
+-		prev->next = hook->next;
+-	    }
+-	    else {
+-		*root = hook->next;
+-	    }
+-	    xfree(hook);
+-	}
+-	else {
+-	    prev = hook;
+-	}
+-	hook = next;
++        next = hook->next;
++        if (func == 0 || hook->func == func) {
++            if (prev) {
++                prev->next = hook->next;
++            }
++            else {
++                *root = hook->next;
++            }
++            xfree(hook);
++        }
++        else {
++            prev = hook;
++        }
++        hook = next;
+     }
+     return -1;
+ }
+@@ -3857,7 +3893,7 @@
+     int ret = remove_event_hook(&vm->event_hooks, func);
+ 
+     if (hook != NULL && vm->event_hooks == NULL) {
+-	set_threads_event_flags(0);
++        set_threads_event_flags(0);
+     }
+ 
+     return ret;
 @@ -3872,19 +3908,49 @@
      return ST_CONTINUE;
  }

 
     /* init thread core */
     Init_native_thread();
Index: eval.c
===================================================================
--- eval.c	(revision 27874)

+      case RUBY_EVENT_VM:
+        return "vm";
       default:
-	return "unknown";
+        return "unknown";
     }
 }
 
@@ -4033,6 +4126,11 @@
     struct call_trace_func_args *p = (struct call_trace_func_args *)args;
     const char *srcfile = rb_sourcefile();
