Revision: 4997
Author: [email protected]
Date: Thu Jul 1 04:48:45 2010
Log: Clear function breakpoints in Debug::HandleWeakDebugInfo callback.
When removing debug_info from SharedFunctionInfo, clear all breakpoints
associated with that debug_info.
This is needed because function will live in heap until next gc, and
therefore can be found
by Runtime::FindSharedFunctionInfoInScript.
Review URL: http://codereview.chromium.org/2848032
http://code.google.com/p/v8/source/detail?r=4997
Modified:
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/test/cctest/test-debug.cc
=======================================
--- /branches/bleeding_edge/src/debug.cc Wed Jun 30 10:29:00 2010
+++ /branches/bleeding_edge/src/debug.cc Thu Jul 1 04:48:45 2010
@@ -684,6 +684,12 @@
void Debug::HandleWeakDebugInfo(v8::Persistent<v8::Value> obj, void* data)
{
DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data);
+ // We need to clear all breakpoints associated with the function to
restore
+ // original code and avoid patching the code twice later because
+ // the function will live in the heap until next gc, and can be found by
+ // Runtime::FindSharedFunctionInfoInScript.
+ BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS);
+ it.ClearAllDebugBreak();
RemoveDebugInfo(node->debug_info());
#ifdef DEBUG
node = Debug::debug_info_list_;
=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Fri Jun 18 03:52:59
2010
+++ /branches/bleeding_edge/test/cctest/test-debug.cc Thu Jul 1 04:48:45
2010
@@ -2073,6 +2073,39 @@
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
+
+
+// Test that it is possible to add and remove break points in a top level
+// function which has no references but has not been collected yet.
+TEST(ScriptBreakPointTopLevelCrash) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+ env.ExposeDebug();
+
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
+ v8::Undefined());
+
+ v8::Local<v8::String> script_source = v8::String::New(
+ "function f() {\n"
+ " return 0;\n"
+ "}\n"
+ "f()");
+
+ int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 3, -1);
+ {
+ v8::HandleScope scope;
+ break_point_hit_count = 0;
+ v8::Script::Compile(script_source,
v8::String::New("test.html"))->Run();
+ CHECK_EQ(1, break_point_hit_count);
+ }
+
+ int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 3, -1);
+ ClearBreakPointFromJS(sbp1);
+ ClearBreakPointFromJS(sbp2);
+
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
// Test that it is possible to remove the last break point for a function
@@ -2129,7 +2162,7 @@
}
-// Test setting a breakpoint on the debugger statement.
+// Test setting a breakpoint on the debugger statement.
TEST(DebuggerStatementBreakpoint) {
break_point_hit_count = 0;
v8::HandleScope scope;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev