if (IsDebuggerActive()) {
// Disable the compilation cache when the debugger is active.
CompilationCache::Disable();
+ debugger_unload_pending_ = false;
} else {
CompilationCache::Enable();
-
// Unload the debugger if event listener and message handler cleared.
- if (Debug::InDebugger()) {
- // If we are in debugger set the flag to unload the debugger when last
- // EnterDebugger on the current stack is destroyed.
- debugger_unload_pending_ = true;
- } else {
- UnloadDebugger();
- }
+ // Schedule this for later, because we may be in non-V8 thread.
+ debugger_unload_pending_ = true;
}
}
// Check whether the message handler was been cleared.
if (debugger_unload_pending_) {
- UnloadDebugger();
+ if (Debug::debugger_entry() == NULL) {
+ UnloadDebugger();
+ }
}
// Currently argument event is not used.
// Check that the debugger has been fully unloaded.
static void CheckDebuggerUnloaded(bool check_functions = false) {
+ // Let debugger to unload itself synchronously
+ v8::Debug::ProcessDebugMessages();
+
v8::internal::CheckDebuggerUnloaded(check_functions);
}