Commit b3452045 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by V8 LUCI CQ

[inspector] Make inspector tests independent of `Debugger.CallFrame.url`.

This is the second step towards moving away from sending `url` with
every call frame when emitting the `Debugger.paused` event.

Bug: chromium:1270316, chromium:1271078
Change-Id: Ib4f996024b5200cded155bd8a564d01d36856400
Doc: https://bit.ly/devtools-debugger-callframe-url
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3431485
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78906}
parent 4ad20bff
Tests super long async stacks. Tests super long async stacks.
Running test: test
(anonymous) (expr.js:0:26) (anonymous) (expr.js:0:26)
callWithAsyncStack (utils.js:3:4) callWithAsyncStack (utils.js:3:4)
call1 (wrapper.js:0:20) call1 (wrapper.js:0:20)
......
...@@ -15,7 +15,9 @@ function callWithAsyncStack(f, depth) { ...@@ -15,7 +15,9 @@ function callWithAsyncStack(f, depth) {
} }
//# sourceURL=utils.js`); //# sourceURL=utils.js`);
(async function test() { session.setupScriptMap();
InspectorTest.runAsyncTestSuite([async function test() {
Protocol.Debugger.enable(); Protocol.Debugger.enable();
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 4}); Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 4});
Protocol.Runtime.evaluate({ Protocol.Runtime.evaluate({
...@@ -40,5 +42,4 @@ function callWithAsyncStack(f, depth) { ...@@ -40,5 +42,4 @@ function callWithAsyncStack(f, depth) {
break; break;
} }
} }
InspectorTest.completeTest(); }]);
})()
...@@ -27,6 +27,7 @@ const {session, contextGroup, Protocol} = InspectorTest.start( ...@@ -27,6 +27,7 @@ const {session, contextGroup, Protocol} = InspectorTest.start(
const contextGroup = new InspectorTest.ContextGroup(); const contextGroup = new InspectorTest.ContextGroup();
const session2 = contextGroup.connect(); const session2 = contextGroup.connect();
const Protocol2 = session2.Protocol; const Protocol2 = session2.Protocol;
session2.setupScriptMap();
Protocol2.Runtime.enable(); Protocol2.Runtime.enable();
Protocol2.Debugger.enable(); Protocol2.Debugger.enable();
...@@ -40,7 +41,8 @@ const {session, contextGroup, Protocol} = InspectorTest.start( ...@@ -40,7 +41,8 @@ const {session, contextGroup, Protocol} = InspectorTest.start(
}); });
const paused = (await Protocol2.Debugger.oncePaused()).params; const paused = (await Protocol2.Debugger.oncePaused()).params;
InspectorTest.log(`paused in: ${paused.callFrames[0].url}`); InspectorTest.log(
`paused in: ${session2.getCallFrameUrl(paused.callFrames[0])}`);
// Now if we're paused in the wrong place, we will likely crash. // Now if we're paused in the wrong place, we will likely crash.
session2.disconnect(); session2.disconnect();
......
...@@ -11,6 +11,9 @@ let contextGroup2 = new InspectorTest.ContextGroup(); ...@@ -11,6 +11,9 @@ let contextGroup2 = new InspectorTest.ContextGroup();
let session2 = contextGroup2.connect(); let session2 = contextGroup2.connect();
let Protocol2 = session2.Protocol; let Protocol2 = session2.Protocol;
session1.setupScriptMap();
session2.setupScriptMap();
let utilsScript = ` let utilsScript = `
function store(description) { function store(description) {
let buffer = inspector.storeCurrentStackTrace(description); let buffer = inspector.storeCurrentStackTrace(description);
...@@ -23,11 +26,10 @@ function started(id) { ...@@ -23,11 +26,10 @@ function started(id) {
function finished(id) { function finished(id) {
inspector.externalAsyncTaskFinished(Int32Array.from(JSON.parse(id)).buffer); inspector.externalAsyncTaskFinished(Int32Array.from(JSON.parse(id)).buffer);
} }`;
//# sourceURL=utils.js`;
contextGroup1.addScript(utilsScript); contextGroup1.addScript(utilsScript, 0, 0, 'utils.js');
contextGroup2.addScript(utilsScript); contextGroup2.addScript(utilsScript, 0, 0, 'utils.js');
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function testDebuggerId() { async function testDebuggerId() {
......
Checks pause inside blackboxed optimized function call. Checks pause inside blackboxed optimized function call.
Running test: test
bar (test.js:2:4) bar (test.js:2:4)
foo (framework.js:2:15) foo (framework.js:2:15)
(anonymous) (expr.js:1:12) (anonymous) (expr.js:1:12)
...@@ -26,7 +26,9 @@ contextGroup.addScript(` ...@@ -26,7 +26,9 @@ contextGroup.addScript(`
//# sourceURL=test.js //# sourceURL=test.js
`); `);
(async function test(){ session.setupScriptMap();
InspectorTest.runAsyncTestSuite([async function test() {
Protocol.Debugger.enable(); Protocol.Debugger.enable();
Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}); Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
Protocol.Runtime.evaluate({expression: ` Protocol.Runtime.evaluate({expression: `
...@@ -35,5 +37,4 @@ contextGroup.addScript(` ...@@ -35,5 +37,4 @@ contextGroup.addScript(`
`}); `});
const {params:{callFrames}} = await Protocol.Debugger.oncePaused(); const {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames); session.logCallFrames(callFrames);
InspectorTest.completeTest(); }]);
})();
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
let {session, contextGroup, Protocol} = let {session, contextGroup, Protocol} =
InspectorTest.start('Test for Debugger.stepInto with breakOnAsyncCall.'); InspectorTest.start('Test for Debugger.stepInto with breakOnAsyncCall.');
session.setupScriptMap();
InspectorTest.runAsyncTestSuite([ InspectorTest.runAsyncTestSuite([
async function testSetTimeout() { async function testSetTimeout() {
Protocol.Debugger.enable(); Protocol.Debugger.enable();
......
Test for step-into remote async task Test for step-into remote async task
Running test: test
Setup debugger agents.. Setup debugger agents..
Pause before stack trace is captured.. Pause before stack trace is captured..
Run stepInto with breakOnAsyncCall flag Run stepInto with breakOnAsyncCall flag
......
// Copyright 2017 the V8 project authors. All rights reserved. // Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
//
// Flags: --no-compilation-cache
InspectorTest.log('Test for step-into remote async task'); InspectorTest.log('Test for step-into remote async task');
...@@ -18,11 +20,8 @@ function store(description) { ...@@ -18,11 +20,8 @@ function store(description) {
} }
//# sourceURL=utils.js`; //# sourceURL=utils.js`;
// TODO(rmcilroy): This has to be in this order since the i::Script object gets
// reused via the CompilationCache, and we want OnAfterCompile to be called
// for contextGroup1 last on this script.
contextGroup2.addScript(utilsScript);
contextGroup1.addScript(utilsScript); contextGroup1.addScript(utilsScript);
contextGroup2.addScript(utilsScript);
let frameworkScript = ` let frameworkScript = `
function call(id, f) { function call(id, f) {
...@@ -38,7 +37,7 @@ contextGroup2.addScript(frameworkScript); ...@@ -38,7 +37,7 @@ contextGroup2.addScript(frameworkScript);
session1.setupScriptMap(); session1.setupScriptMap();
session2.setupScriptMap(); session2.setupScriptMap();
(async function test() { InspectorTest.runAsyncTestSuite([async function test() {
InspectorTest.log('Setup debugger agents..'); InspectorTest.log('Setup debugger agents..');
let debuggerId1 = (await Protocol1.Debugger.enable()).result.debuggerId; let debuggerId1 = (await Protocol1.Debugger.enable()).result.debuggerId;
let debuggerId2 = (await Protocol2.Debugger.enable()).result.debuggerId; let debuggerId2 = (await Protocol2.Debugger.enable()).result.debuggerId;
...@@ -77,7 +76,7 @@ session2.setupScriptMap(); ...@@ -77,7 +76,7 @@ session2.setupScriptMap();
let debuggers = new Map( let debuggers = new Map(
[[debuggerId1, Protocol1.Debugger], [debuggerId2, Protocol2.Debugger]]); [[debuggerId1, Protocol1.Debugger], [debuggerId2, Protocol2.Debugger]]);
let sessions = new Map([[debuggerId1, session1], [debuggerId2, session2]]); let sessions = new Map([[debuggerId1, session1], [debuggerId2, session2]]);
let currentDebuggerId = debuggerId1; let currentDebuggerId = debuggerId2;
while (true) { while (true) {
sessions.get(currentDebuggerId).logCallFrames(callFrames); sessions.get(currentDebuggerId).logCallFrames(callFrames);
if (asyncStackTraceId) { if (asyncStackTraceId) {
...@@ -98,6 +97,4 @@ session2.setupScriptMap(); ...@@ -98,6 +97,4 @@ session2.setupScriptMap();
Protocol2.Debugger.setAsyncCallStackDepth({maxDepth: 0}); Protocol2.Debugger.setAsyncCallStackDepth({maxDepth: 0});
await Protocol1.Debugger.disable(); await Protocol1.Debugger.disable();
await Protocol2.Debugger.disable(); await Protocol2.Debugger.disable();
}]);
InspectorTest.completeTest();
})()
...@@ -174,7 +174,7 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -174,7 +174,7 @@ Protocol.Debugger.onPaused(async msg => {
var lineNumber = frame.location.lineNumber; var lineNumber = frame.location.lineNumber;
var columnNumber = frame.location.columnNumber; var columnNumber = frame.location.columnNumber;
InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`); InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`);
if (!/^wasm/.test(frame.url)) { if (!/^wasm/.test(session.getCallFrameUrl(frame))) {
InspectorTest.log(' -- skipped'); InspectorTest.log(' -- skipped');
continue; continue;
} }
......
...@@ -12,8 +12,9 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -12,8 +12,9 @@ Protocol.Debugger.onPaused(async msg => {
let top_frame = msg.params.callFrames[0]; let top_frame = msg.params.callFrames[0];
let reason = msg.params.reason; let reason = msg.params.reason;
let hitBreakpoints = msg.params.hitBreakpoints; let hitBreakpoints = msg.params.hitBreakpoints;
InspectorTest.log(`Paused at ${top_frame.url} with reason "${reason}".`); const url = session.getCallFrameUrl(top_frame);
if (!top_frame.url.startsWith('v8://test/')) { InspectorTest.log(`Paused at ${url} with reason "${reason}".`);
if (!url.startsWith('v8://test/')) {
await session.logSourceLocation(top_frame.location); await session.logSourceLocation(top_frame.location);
} }
// Report the hit breakpoints to make sure that it is empty, as // Report the hit breakpoints to make sure that it is empty, as
......
...@@ -58,7 +58,8 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -58,7 +58,8 @@ Protocol.Debugger.onPaused(async msg => {
var lineNumber = frame.location.lineNumber; var lineNumber = frame.location.lineNumber;
var columnNumber = frame.location.columnNumber; var columnNumber = frame.location.columnNumber;
InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`); InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`);
if (!/^wasm/.test(frame.url)) { var url = session.getCallFrameUrl(frame);
if (!/^wasm/.test(url)) {
InspectorTest.log(' -- skipped'); InspectorTest.log(' -- skipped');
continue; continue;
} }
...@@ -73,10 +74,10 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -73,10 +74,10 @@ Protocol.Debugger.onPaused(async msg => {
if (first_iteration && loc.columnNumber == func_a.body_offset) { if (first_iteration && loc.columnNumber == func_a.body_offset) {
// Check that setting breakpoints on active instances of A and B takes // Check that setting breakpoints on active instances of A and B takes
// effect immediately. // effect immediately.
setBreakpoint(func_a.body_offset + 1, loc.scriptId, frame.url); setBreakpoint(func_a.body_offset + 1, loc.scriptId, url);
// All of the following breakpoints are in reachable code, except offset 17. // All of the following breakpoints are in reachable code, except offset 17.
for (offset of [18, 17, 11, 10, 8, 6, 2, 4]) { for (offset of [18, 17, 11, 10, 8, 6, 2, 4]) {
setBreakpoint(func_b.body_offset + offset, loc.scriptId, frame.url); setBreakpoint(func_b.body_offset + offset, loc.scriptId, url);
} }
first_iteration = false; first_iteration = false;
} }
......
...@@ -34,7 +34,8 @@ Protocol.Debugger.onPaused(async msg => { ...@@ -34,7 +34,8 @@ Protocol.Debugger.onPaused(async msg => {
for (let [nr, frame] of msg.params.callFrames.entries()) { for (let [nr, frame] of msg.params.callFrames.entries()) {
InspectorTest.log(`--- ${nr} ---`); InspectorTest.log(`--- ${nr} ---`);
await session.logSourceLocation(frame.location); await session.logSourceLocation(frame.location);
if (/^wasm/.test(frame.url)) await printLocalScope(frame); if (/^wasm/.test(session.getCallFrameUrl(frame)))
await printLocalScope(frame);
} }
InspectorTest.log('-------------'); InspectorTest.log('-------------');
let action = actions.shift(); let action = actions.shift();
......
...@@ -264,11 +264,15 @@ InspectorTest.Session = class { ...@@ -264,11 +264,15 @@ InspectorTest.Session = class {
this._scriptMap = new Map(); this._scriptMap = new Map();
} }
getCallFrameUrl(frame) {
const {scriptId} = frame.location ? frame.location : frame;
return (this._scriptMap.get(scriptId) ?? frame).url;
}
logCallFrames(callFrames) { logCallFrames(callFrames) {
for (var frame of callFrames) { for (var frame of callFrames) {
var functionName = frame.functionName || '(anonymous)'; var functionName = frame.functionName || '(anonymous)';
var scriptId = frame.location ? frame.location.scriptId : frame.scriptId; var url = this.getCallFrameUrl(frame);
var url = frame.url ? frame.url : this._scriptMap.get(scriptId).url;
var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumber; var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumber;
var columnNumber = frame.location ? frame.location.columnNumber : frame.columnNumber; var columnNumber = frame.location ? frame.location.columnNumber : frame.columnNumber;
InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`); InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`);
......
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