4739535d71
This aligns the breakpoint behavior of YieldExpression and AwaitExpression with the behavior of AssignmentExpression in V8. It basically boils down to not reporting expression positions on SuspendGenerator bytecodes as breakable locations. In particular the initial implicit yield of any generator function is no longer a breakable position. In light of this changes we also refine https://crrev.com/c/2949099 to not be able to step to the initial implicit yield either, which would otherwise be really odd. Before: https://imgur.com/KYy9F1S.png After: https://imgur.com/gCnWU8J.png Doc: https://goo.gle/devtools-reliable-await-breakpoints Bug: chromium:901814, chromium:1319019, chromium:1246869 Fixed: chromium:1319019, chromium:1357501 Change-Id: I0c5f83e279918eb392d8f77a8a04c4c0285f938e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3909688 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> Auto-Submit: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#83392}
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
// Copyright 2021 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('Generator stepping');
|
|
|
|
const url = 'stepping-generator.js';
|
|
contextGroup.addScript(`
|
|
function* generator() {
|
|
var a = 42;
|
|
yield a;
|
|
}
|
|
function callGenerator() {
|
|
return generator();
|
|
}
|
|
`, 0, 0, url);
|
|
|
|
session.setupScriptMap();
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
async function testStepIntoInitialYield() {
|
|
await Promise.all([Protocol.Debugger.enable(), Protocol.Runtime.enable()]);
|
|
InspectorTest.log(`Setting breakpoint on call to generator()`);
|
|
const {result: {breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({
|
|
url,
|
|
lineNumber: 5,
|
|
columnNumber: 0,
|
|
})
|
|
InspectorTest.log(`Calling callGenerator()`);
|
|
const pausedPromise = Protocol.Debugger.oncePaused();
|
|
const evalPromise = Protocol.Runtime.evaluate({expression: 'callGenerator()'});
|
|
const {method, params} = await Promise.race([pausedPromise, evalPromise]);
|
|
if (method === 'Debugger.paused') {
|
|
await session.logSourceLocation(params.callFrames[0].location);
|
|
|
|
InspectorTest.log('Stepping into the generator()');
|
|
let [{params: {callFrames:[{location}]}}] = await Promise.all([
|
|
Protocol.Debugger.oncePaused(),
|
|
Protocol.Debugger.stepInto(),
|
|
]);
|
|
await session.logSourceLocation(location);
|
|
|
|
await Promise.all([Protocol.Debugger.resume(), evalPromise]);
|
|
} else {
|
|
InspectorTest.log('Did not pause');
|
|
}
|
|
await Protocol.Debugger.removeBreakpoint({breakpointId});
|
|
await Promise.all([Protocol.Debugger.disable(), Protocol.Runtime.disable()]);
|
|
}
|
|
]);
|