Reviewers: Søren Gjesse,

Message:
Hi Sorren

This CL has one TODO, which may be resolved before committing. I need you advice
here.

Peter

Description:
Make debugger unloading deferred operation

This CL should make debugger handler setting an asynchronous operation for real.

Please review this at http://codereview.chromium.org/548045

Affected files:
  M src/debug.h
  M src/debug.cc
  M test/cctest/test-debug.cc


Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index fbe09391e27fabe4c9934adb79463a57288565ab..c4608d58e2fb1d13e09462fa29376c4a97929633 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -2379,17 +2379,12 @@ void Debugger::ListenersChanged() {
   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;
   }
 }

Index: src/debug.h
diff --git a/src/debug.h b/src/debug.h
index c37e08b38f357dd3070ec866360b6bf9cb24aaa2..000077b0dce006a090d9ce0ebf831b16564c1ed0 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -654,7 +654,12 @@ class Debugger {

     // Check whether the message handler was been cleared.
     if (debugger_unload_pending_) {
-      UnloadDebugger();
+ // TODO(peter.rybin): should we check that we pending unload is still actual?
+      // Should we check EnterDebugger is on stack?
+      // Or else Debug::ClearMirrorCache() will fail in first line.
+      if (Debug::debugger_entry() == NULL) {
+        UnloadDebugger();
+      }
     }

     // Currently argument event is not used.
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index cad1ba3ae5122d9a6b3590ba56f45a92885db6a7..bba7bf5903ed8083b15727366f5703931c7135aa 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -443,6 +443,9 @@ void CheckDebuggerUnloaded(bool check_functions) {

 // 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);
 }



-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to