Revision: 5131
Author: [email protected]
Date: Fri Jul 23 10:21:55 2010
Log: Fix break position not to be outside of the script
Review URL: http://codereview.chromium.org/3017021
http://code.google.com/p/v8/source/detail?r=5131
Modified:
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Jul 23 03:15:21 2010
+++ /branches/bleeding_edge/src/runtime.cc Fri Jul 23 10:21:55 2010
@@ -9381,6 +9381,13 @@
}
Debug::SetBreakPoint(shared, break_point_object_arg, &position);
position += shared->start_position();
+
+ // The result position may become beyond script source end.
+ // This is expected when the function is toplevel. This may become
+ // a problem later when actual position gets converted into
line/column.
+ if (shared->is_toplevel() && position == shared->end_position()) {
+ position = shared->end_position() - 1;
+ }
return Smi::FromInt(position);
}
return Heap::undefined_value();
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js Mon Jun 28
05:09:29 2010
+++ /branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js Fri Jul 23
10:21:55 2010
@@ -192,3 +192,26 @@
sourceUrlFunc();
assertTrue(breakListenerCalled, "Break listener not called on breakpoint
set by sourceURL");
+
+
+// Breakpoint in a script with no statements test case. If breakpoint is
set
+// to the script body, its actual position is taken from the nearest
statement
+// below or like in this case is reset to the very end of the script.
+// Unless some precautions made, this position becomes out-of-range and
+// we get an exception.
+
+// Gets a script of 'i1' function and sets the breakpoint at line #4 which
+// should be empty.
+function SetBreakpointInI1Script() {
+ var i_script = Debug.findScript(i1);
+ assertTrue(!!i_script, "invalid script for i1");
+ Debug.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
+ i_script.id, 4);
+}
+
+// Creates the eval script and tries to set the breakpoint.
+// The tricky part is that the script function must be strongly reachable
at the
+// moment. Since there's no way of simply getting the pointer to the
function,
+// we run this code while the script function is being activated on stack.
+eval('SetBreakpointInI1Script()\nfunction i1(){}\n\n\n\nfunction
i2(){}\n');
+
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev