Commit 30b85b39 authored by peter.rybin@gmail.com's avatar peter.rybin@gmail.com

Fix break position not to be outside of the script

Review URL: http://codereview.chromium.org/3017021

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5131 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 79e33201
......@@ -9381,6 +9381,13 @@ static Object* Runtime_SetScriptBreakPoint(Arguments args) {
}
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();
......
......@@ -192,3 +192,26 @@ Debug.setListener(breakListener);
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');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment