Commit 9fef8fd2 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] fixed getPossibleBreakpoints

BytecodeArrayBreakIterator doesn't iterate through locations in position() order. SkipToPosition is looking for closest break_index to passed one. So we should iterate through all breakable locations in function to get all of them.

R=jgruber@chromium.org

Bug: v8:6469
Change-Id: Ida0b849e9df40458a13e0a0f7af6a00349088228
Reviewed-on: https://chromium-review.googlesource.com/527135Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45765}
parent 90c3a2d5
......@@ -1363,10 +1363,10 @@ namespace {
template <typename Iterator>
void GetBreakablePositions(Iterator* it, int start_position, int end_position,
std::vector<BreakLocation>* locations) {
it->SkipToPosition(start_position, BREAK_POSITION_ALIGNED);
while (!it->Done() && it->position() < end_position &&
it->position() >= start_position) {
locations->push_back(it->GetBreakLocation());
while (!it->Done()) {
if (it->position() >= start_position && it->position() < end_position) {
locations->push_back(it->GetBreakLocation());
}
it->Next();
}
}
......
Break locations around function calls
Running test: testFunctionCallAsArgument
Break locations in expression:
function test() {
|C|foo2(|C|foo1())
}
Breakpoint at:
function test() {
#foo2(foo1())
}
Break at:
function test() {
#foo2(foo1())
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at:
function test() {
foo2(#foo1())
}
Break at:
function test() {
foo2(#foo1())
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at expression line.
function test() {
#foo2(foo1())
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Running test: testFunctionCallAsArgument
Break locations in expression:
function test() {
|C|foo2(|C|foo1());
}
Breakpoint at:
function test() {
#foo2(foo1());
}
Break at:
function test() {
#foo2(foo1());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at:
function test() {
foo2(#foo1());
}
Break at:
function test() {
foo2(#foo1());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at expression line.
function test() {
#foo2(foo1());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Running test: testFunctionCallAsArguments
Break locations in expression:
function test() {
|C|foo3(|C|foo1(), |C|foo2());
}
Breakpoint at:
function test() {
#foo3(foo1(), foo2());
}
Break at:
function test() {
#foo3(foo1(), foo2());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at:
function test() {
foo3(#foo1(), foo2());
}
Break at:
function test() {
foo3(#foo1(), foo2());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at:
function test() {
foo3(foo1(), #foo2());
}
Break at:
function test() {
foo3(foo1(), #foo2());
}
Debugger.stepInto called
function foo1() {}
function foo2() {#}
function foo3() {}
Breakpoint at expression line.
function test() {
#foo3(foo1(), foo2());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Running test: testFunctionCallInBinaryExpression
Break locations in expression:
function test() {
|C|foo3(|C|foo1() + |C|foo2());
}
Breakpoint at:
function test() {
#foo3(foo1() + foo2());
}
Break at:
function test() {
#foo3(foo1() + foo2());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at:
function test() {
foo3(#foo1() + foo2());
}
Break at:
function test() {
foo3(#foo1() + foo2());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
Breakpoint at:
function test() {
foo3(foo1() + #foo2());
}
Break at:
function test() {
foo3(foo1() + #foo2());
}
Debugger.stepInto called
function foo1() {}
function foo2() {#}
function foo3() {}
Breakpoint at expression line.
function test() {
#foo3(foo1() + foo2());
}
Debugger.stepInto called
function foo1() {#}
function foo2() {}
// 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('Break locations around function calls');
contextGroup.addScript(`
function foo1() {}
function foo2() {}
function foo3() {}
//# sourceURL=test.js`);
InspectorTest.logProtocolCommandCalls('Debugger.stepInto');
session.setupScriptMap();
InspectorTest.runAsyncTestSuite([
async function testFunctionCallAsArgument() {
await testExpression('foo2(foo1())');
},
async function testFunctionCallAsArgument() {
await testExpression('foo2(foo1());');
},
async function testFunctionCallAsArguments() {
await testExpression('foo3(foo1(), foo2());');
},
async function testFunctionCallInBinaryExpression() {
await testExpression('foo3(foo1() + foo2());');
},
]);
async function logPauseLocation() {
let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logSourceLocation(callFrames[0].location);
}
async function testExpression(expression) {
await Protocol.Debugger.enable();
let wrapper = `function test() {
${expression}
}
//# sourceURL=test-function.js`;
Protocol.Runtime.evaluate({expression: wrapper});
let {params:{scriptId}} = await Protocol.Debugger.onceScriptParsed();
let {result:{locations}} = await Protocol.Debugger.getPossibleBreakpoints({
start: {lineNumber: 0, columnNumber : 0, scriptId}});
locations = locations.filter(location => location.lineNumber === 1);
InspectorTest.log('Break locations in expression:');
await session.logBreakLocations(locations);
for (let location of locations) {
InspectorTest.log('Breakpoint at:');
await session.logSourceLocation(location);
let {result:{breakpointId}} = await Protocol.Debugger.setBreakpoint({
location});
let evaluate = Protocol.Runtime.evaluate({
expression: 'test();\n//# sourceURL=expr.js'});
InspectorTest.log('Break at:');
await logPauseLocation();
Protocol.Debugger.stepInto();
await logPauseLocation();
await Protocol.Debugger.removeBreakpoint({breakpointId});
Protocol.Debugger.resume();
await evaluate;
}
InspectorTest.log('Breakpoint at expression line.')
let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({
lineNumber: 1, url: 'test-function.js'});
let evaluate = Protocol.Runtime.evaluate({
expression: 'test();\n//# sourceURL=expr.js'});
await logPauseLocation();
Protocol.Debugger.stepInto();
await logPauseLocation();
await Protocol.Debugger.removeBreakpoint({breakpointId});
Protocol.Debugger.resume();
await evaluate;
await Protocol.Debugger.disable();
}
......@@ -95,7 +95,7 @@ function testForLoop() {
|R|}
function testForOfLoop() {
for (var |_|k of []) {}
for (var |_|k of |_|[]) {}
for (var |_|k of |_|[1]) |_|k;
var a = |_|[];
for (var |_|k of |_|a) {}
......
......@@ -243,7 +243,8 @@ InspectorTest.Session = class {
return this.logSourceLocation(locations[0]).then(() => this.logSourceLocations(locations.splice(1)));
}
async logBreakLocations(locations) {
async logBreakLocations(inputLocations) {
let locations = inputLocations.slice();
let scriptId = locations[0].scriptId;
let script = this._scriptMap.get(scriptId);
if (!script.scriptSource) {
......@@ -262,7 +263,7 @@ InspectorTest.Session = class {
}
lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1);
InspectorTest.log(lines.join('\n') + '\n');
return locations;
return inputLocations;
function locationMark(type) {
if (type === 'return') return '|R|';
......
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