From 79aae815ddc430bb405b12dea00ea07c194753e8 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Thu, 12 Mar 2009 14:03:05 +0000 Subject: [PATCH] During the refactoring in r1461 and adding of script ids in r1468 the propagation of a boolean flag was missing. This caused the line numbers retreived through ScriptMirror objects to ignore the resource line offset information in the script. Added an explicit false parameter where the parameter was previously left out. Added a test case for this. Review URL: http://codereview.chromium.org/43130 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/debug-delay.js | 2 +- src/messages.js | 4 ++-- src/mirror-delay.js | 5 +++-- test/cctest/test-debug.cc | 11 +++++++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/debug-delay.js b/src/debug-delay.js index 11796ad..3b7a4de 100644 --- a/src/debug-delay.js +++ b/src/debug-delay.js @@ -521,7 +521,7 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { source_position += %FunctionGetScriptSourcePosition(func); // Find line and column for the position in the script and set a script // break point from that. - var location = script.locationFromPosition(source_position); + var location = script.locationFromPosition(source_position, false); return this.setScriptBreakPointById(script.id, location.line, location.column, opt_condition); diff --git a/src/messages.js b/src/messages.js index c2fc5fc..cd9a1e8 100644 --- a/src/messages.js +++ b/src/messages.js @@ -302,7 +302,7 @@ Script.prototype.locationFromLine = function (opt_line, opt_column, opt_offset_p var offset_position = opt_offset_position || 0; if (line < 0 || column < 0 || offset_position < 0) return null; if (line == 0) { - return this.locationFromPosition(offset_position + column); + return this.locationFromPosition(offset_position + column, false); } else { // Find the line where the offset position is located var lineCount = this.lineCount(); @@ -519,7 +519,7 @@ SourceSlice.prototype.sourceText = function () { // Returns the offset of the given position within the containing // line. function GetPositionInLine(message) { - var location = message.script.locationFromPosition(message.startPos); + var location = message.script.locationFromPosition(message.startPos, false); if (location == null) return -1; location.restrict(); return message.startPos - location.start; diff --git a/src/mirror-delay.js b/src/mirror-delay.js index d5da445..916bc27 100644 --- a/src/mirror-delay.js +++ b/src/mirror-delay.js @@ -1592,8 +1592,9 @@ ScriptMirror.prototype.lineCount = function() { }; -ScriptMirror.prototype.locationFromPosition = function(position) { - return this.script_.locationFromPosition(position); +ScriptMirror.prototype.locationFromPosition = function( + position, include_resource_offset) { + return this.script_.locationFromPosition(position, include_resource_offset); } diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 280d507..de4a78f 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -3720,6 +3720,17 @@ TEST(CallFunctionInDebugger) { // Test that a function with closure can be run in the debugger. v8::Script::Compile(v8::String::New("CheckClosure()"))->Run(); + + + // Test that the source line is correct when there is a line offset. + v8::ScriptOrigin origin(v8::String::New("test"), + v8::Integer::New(7)); + v8::Script::Compile(v8::String::New("CheckSourceLine(7)"), &origin)->Run(); + v8::Script::Compile(v8::String::New("function f() {\n" + " CheckSourceLine(8)\n" + " CheckSourceLine(9)\n" + " CheckSourceLine(10)\n" + "}; f()"), &origin)->Run(); } -- 2.7.4