Version 1.2.8.1.
Merge bleeding_edge@2206 to fix unloading the debugger with active breakpoints.
Review URL: http://codereview.chromium.org/126275
git-svn-id: http://v8.googlecode.com/svn/trunk@2208 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/api.cc b/src/api.cc
index 097c2ea..1001847 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3384,6 +3384,7 @@
void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) {
EnsureInitialized("v8::Debug::SetMessageHandler");
ENTER_V8;
+ HandleScope scope;
i::Debugger::SetMessageHandler(handler);
}
diff --git a/src/version.cc b/src/version.cc
index caf033b..c109060 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 1
#define MINOR_VERSION 2
#define BUILD_NUMBER 8
-#define PATCH_LEVEL 0
+#define PATCH_LEVEL 1
#define CANDIDATE_VERSION false
// Define SONAME to have the SCons build the put a specific SONAME into the
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 7669b43..342994e 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -4235,57 +4235,83 @@
}
+// Debugger message handler which counts the number of breaks.
+static void SendContinueCommand();
+static void MessageHandlerBreakPointHitCount(
+ const v8::Debug::Message& message) {
+ if (message.IsEvent() && message.GetEvent() == v8::Break) {
+ // Count the number of breaks.
+ break_point_hit_count++;
+
+ SendContinueCommand();
+ }
+}
+
+
// Test that clearing the debug event listener actually clears all break points
// and related information.
TEST(DebuggerUnload) {
- v8::HandleScope scope;
DebugLocalContext env;
// Check debugger is unloaded before it is used.
CheckDebuggerUnloaded();
- // Add debug event listener.
+ // Set a debug event listener.
+ break_point_hit_count = 0;
v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
v8::Undefined());
- // Create a couple of functions for the test.
- v8::Local<v8::Function> foo =
- CompileFunction(&env, "function foo(){x=1}", "foo");
- v8::Local<v8::Function> bar =
- CompileFunction(&env, "function bar(){y=2}", "bar");
+ {
+ v8::HandleScope scope;
+ // Create a couple of functions for the test.
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){x=1}", "foo");
+ v8::Local<v8::Function> bar =
+ CompileFunction(&env, "function bar(){y=2}", "bar");
- // Set some break points.
- SetBreakPoint(foo, 0);
- SetBreakPoint(foo, 4);
- SetBreakPoint(bar, 0);
- SetBreakPoint(bar, 4);
+ // Set some break points.
+ SetBreakPoint(foo, 0);
+ SetBreakPoint(foo, 4);
+ SetBreakPoint(bar, 0);
+ SetBreakPoint(bar, 4);
- // Make sure that the break points are there.
- break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
- CHECK_EQ(2, break_point_hit_count);
- bar->Call(env->Global(), 0, NULL);
- CHECK_EQ(4, break_point_hit_count);
-
- // Remove the debug event listener without clearing breakpoints.
+ // Make sure that the break points are there.
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(2, break_point_hit_count);
+ bar->Call(env->Global(), 0, NULL);
+ CHECK_EQ(4, break_point_hit_count);
+ }
+
+ // Remove the debug event listener without clearing breakpoints. Do this
+ // outside a handle scope.
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded(true);
- // Set a new debug event listener.
- v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
- v8::Undefined());
- // Check that the break points was actually cleared.
+ // Now set a debug message handler.
break_point_hit_count = 0;
- foo->Call(env->Global(), 0, NULL);
- CHECK_EQ(0, break_point_hit_count);
+ v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount);
+ {
+ v8::HandleScope scope;
- // Set break points and run again.
- SetBreakPoint(foo, 0);
- SetBreakPoint(foo, 4);
- foo->Call(env->Global(), 0, NULL);
- CHECK_EQ(2, break_point_hit_count);
+ // Get the test functions again.
+ v8::Local<v8::Function> foo =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+ v8::Local<v8::Function> bar =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
- // Remove the debug event listener without clearing breakpoints again.
- v8::Debug::SetDebugEventListener(NULL);
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(0, break_point_hit_count);
+
+ // Set break points and run again.
+ SetBreakPoint(foo, 0);
+ SetBreakPoint(foo, 4);
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(2, break_point_hit_count);
+ }
+
+ // Remove the debug message handler without clearing breakpoints. Do this
+ // outside a handle scope.
+ v8::Debug::SetMessageHandler2(NULL);
CheckDebuggerUnloaded(true);
}