312a3fbec0
This adds a call to re-compile top level functions in case no shared function info could be found. We ran into a bug where it was not possible to set a breakpoint on the top-level function since it was already removed by the GC. Bug: chromium:1137141 Change-Id: I5bb6984825eee8ebcb44619e15b3acf3d118b9bb Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2672181 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Kim-Anh Tran <kimanh@chromium.org> Cr-Commit-Position: refs/heads/master@{#72738}
53 lines
1.8 KiB
JavaScript
53 lines
1.8 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.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start(
|
|
'Checks if we keep alive breakpoint information for top-level functions.');
|
|
|
|
session.setupScriptMap();
|
|
var executionContextId;
|
|
|
|
const callGarbageCollector = `
|
|
%CollectGarbage("");
|
|
%CollectGarbage("");
|
|
%CollectGarbage("");
|
|
%CollectGarbage("");
|
|
`;
|
|
|
|
const topLevelFunction = `console.log('This is a top level function')`;
|
|
const moduleFunction =
|
|
`function testFunc() { console.log('This is a module function') }`;
|
|
|
|
Protocol.Debugger.enable().then(onDebuggerEnabled);
|
|
|
|
function onDebuggerEnabled() {
|
|
Protocol.Runtime.enable();
|
|
Protocol.Runtime.onExecutionContextCreated(onExecutionContextCreated);
|
|
}
|
|
|
|
async function onExecutionContextCreated(messageObject) {
|
|
executionContextId = messageObject.params.context.id;
|
|
await testSetBreakpoint(executionContextId, topLevelFunction, 'topLevel.js');
|
|
await testSetBreakpoint(executionContextId, moduleFunction, 'moduleFunc.js');
|
|
InspectorTest.completeTest();
|
|
}
|
|
|
|
async function testSetBreakpoint(executionContextId, func, url) {
|
|
const obj = await Protocol.Runtime.compileScript({
|
|
expression: func,
|
|
sourceURL: url,
|
|
persistScript: true,
|
|
executionContextId: executionContextId
|
|
});
|
|
const scriptId = obj.result.scriptId;
|
|
await Protocol.Runtime.runScript({scriptId});
|
|
await Protocol.Runtime.evaluate({expression: `${callGarbageCollector}`});
|
|
const {result: {locations}} =
|
|
await Protocol.Debugger.setBreakpointByUrl({lineNumber: 0, url});
|
|
InspectorTest.log(`Result of setting breakpoint in ${url}`);
|
|
InspectorTest.log(JSON.stringify(locations));
|
|
}
|