Revision: 4890
Author: [email protected]
Date: Thu Jun 17 05:47:08 2010
Log: Fix a bug when top level break points fall into the last function in
script.
Review URL: http://codereview.chromium.org/2824007
http://code.google.com/p/v8/source/detail?r=4890
Modified:
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/cctest/test-debug.cc
/branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed Jun 16 07:50:07 2010
+++ /branches/bleeding_edge/src/runtime.cc Thu Jun 17 05:47:08 2010
@@ -9081,8 +9081,6 @@
// The current candidate for the source position:
int target_start_position = RelocInfo::kNoPosition;
Handle<SharedFunctionInfo> target;
- // The current candidate for the last function in script:
- Handle<SharedFunctionInfo> last;
while (!done) {
HeapIterator iterator;
for (HeapObject* obj = iterator.next();
@@ -9123,25 +9121,12 @@
}
}
}
-
- // Keep track of the last function in the script.
- if (last.is_null() ||
- shared->end_position() > last->start_position()) {
- last = shared;
- }
}
}
}
- // Make sure some candidate is selected.
if (target.is_null()) {
- if (!last.is_null()) {
- // Position after the last function - use last.
- target = last;
- } else {
- // Unable to find function - possibly script without any function.
- return Heap::undefined_value();
- }
+ return Heap::undefined_value();
}
// If the candidate found is compiled we are done. NOTE: when lazy
=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Wed Jun 16 07:50:07
2010
+++ /branches/bleeding_edge/test/cctest/test-debug.cc Thu Jun 17 05:47:08
2010
@@ -2026,6 +2026,51 @@
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
+
+
+// Test top level script break points set on lines.
+TEST(ScriptBreakPointLineTopLevel) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+ env.ExposeDebug();
+
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
+ v8::Undefined());
+
+ v8::Local<v8::String> script = v8::String::New(
+ "function f() {\n"
+ " a = 1; // line 1\n"
+ "}\n"
+ "a = 2; // line 3\n");
+ v8::Local<v8::Function> f;
+ {
+ v8::HandleScope scope;
+ v8::Script::Compile(script, v8::String::New("test.html"))->Run();
+ }
+ f =
v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+
+ Heap::CollectAllGarbage(false);
+
+ SetScriptBreakPointByNameFromJS("test.html", 3, -1);
+
+ // Call f and check that there was no break points.
+ break_point_hit_count = 0;
+ f->Call(env->Global(), 0, NULL);
+ CHECK_EQ(0, break_point_hit_count);
+
+ // Recompile and run script and check that break point was hit.
+ break_point_hit_count = 0;
+ v8::Script::Compile(script, v8::String::New("test.html"))->Run();
+ CHECK_EQ(1, break_point_hit_count);
+
+ // Call f and check that there are still no break points.
+ break_point_hit_count = 0;
+ f =
v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
+ CHECK_EQ(0, break_point_hit_count);
+
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
// Test that it is possible to remove the last break point for a function
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js Wed Jun 16
07:50:07 2010
+++ /branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js Thu Jun 17
05:47:08 2010
@@ -116,7 +116,7 @@
mirror = debug.MakeMirror(o.a);
testArguments(dcp, '{"type":"handle","target":' + mirror.handle()
+ '}', true, false);
-
testArguments(dcp, '{"type":"script","target":"sourceUrlScript","line":1}',
true, true);
+
testArguments(dcp, '{"type":"script","target":"sourceUrlScript","line":0}',
true, true);
// Indicate that all was processed.
listenerComplete = true;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev