Commit 6a65e6de authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] don't create negative location for isBlackboxed check

V8 provides ScriptCompiler::CompileFunctionInContext method which takes expression and compile it as anonymous function like (function() .. expression ..). To produce correct locations for stmts inside of this expression V8 compile this function with negative offset. Instead of stmt position blackboxing use function start position which is negative in described case.

Bug: chromium:705963
Change-Id: I86b113198fb59e77b3bbf523c8cd943e22f8a6ca
Reviewed-on: https://chromium-review.googlesource.com/519384
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45637}
parent 27f4b242
......@@ -1960,7 +1960,13 @@ namespace {
debug::Location GetDebugLocation(Handle<Script> script, int source_position) {
Script::PositionInfo info;
Script::GetPositionInfo(script, source_position, &info, Script::WITH_OFFSET);
return debug::Location(info.line, info.column);
// V8 provides ScriptCompiler::CompileFunctionInContext method which takes
// expression and compile it as anonymous function like (function() ..
// expression ..). To produce correct locations for stmts inside of this
// expression V8 compile this function with negative offset. Instead of stmt
// position blackboxing use function start position which is negative in
// described case.
return debug::Location(std::max(info.line, 0), std::max(info.column, 0));
}
} // namespace
......
Locations in script with negative offset.
[
[0] : {
columnNumber : 16
lineNumber : 0
scriptId : <scriptId>
type : debuggerStatement
}
[1] : {
columnNumber : 26
lineNumber : 0
scriptId : <scriptId>
type : return
}
]
foo (:-1:16)
(anonymous) (:0:0)
boo (:0:16)
(anonymous) (:0:0)
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} =
InspectorTest.start('Locations in script with negative offset.');
(async function test() {
contextGroup.addScript(`function foo() { debugger; }
function boo(){ debugger; }
`, -1, -1);
session.setupScriptMap();
Protocol.Debugger.enable();
let {params:{scriptId}} = await Protocol.Debugger.onceScriptParsed();
let {result:{locations}} = await Protocol.Debugger.getPossibleBreakpoints({
start: {scriptId, lineNumber: 0, columnNumber: 0}
});
InspectorTest.logMessage(locations);
Protocol.Runtime.evaluate({expression: 'foo()'});
var {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
await Protocol.Debugger.resume();
Protocol.Runtime.evaluate({expression: 'boo()'});
var {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
await Protocol.Debugger.resume();
InspectorTest.completeTest();
})();
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