[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: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#45637}
This commit is contained in:
parent
27f4b242ea
commit
6a65e6deef
@ -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
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
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)
|
31
test/inspector/debugger/script-with-negative-offset.js
Normal file
31
test/inspector/debugger/script-with-negative-offset.js
Normal file
@ -0,0 +1,31 @@
|
||||
// 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();
|
||||
})();
|
Loading…
Reference in New Issue
Block a user