v8/test/inspector/debugger/set-async-call-stack-depth.js
kozyatinskiy 38be4a17c1 [inspector] avoid cloning of async call chains
- separated V8StackTraceImpl and AsyncStackTrace,
- V8Debugger owns all AsyncStackTrace and cleanup half of them when limit is reached (first created - first cleaned),
- V8StackTraceImpl, AsyncStackTrace and async-task-related tables in V8Debugger have weak reference to other async stack traces.
- async tasks are cleared with related async stacks.

BUG=v8:6189
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2816043006
Cr-Original-Commit-Position: refs/heads/master@{#44670}
Committed: 1bca73bc83
Review-Url: https://codereview.chromium.org/2816043006
Cr-Commit-Position: refs/heads/master@{#44694}
2017-04-18 15:53:08 +00:00

78 lines
2.5 KiB
JavaScript

// 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.
InspectorTest.log('Checks that we report not more then maxDepth call chains.');
InspectorTest.addScript(`
function promisesChain(num) {
var p = Promise.resolve();
for (var i = 0; i < num - 1; ++i) {
p = p.then(() => 42);
}
return p;
}
`);
Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([
async function testPaused() {
let callback = '() => { debugger; }';
startTest({ generated: 8, limit: 16, callback});
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
startTest({ generated: 8, limit: 8, callback});
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
startTest({ generated: 8, limit: 7, callback});
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
startTest({ generated: 8, limit: 0, callback});
dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
await Protocol.Debugger.resume();
},
async function testConsoleTrace() {
await Protocol.Runtime.enable();
let callback = '() => { console.trace(42); }';
startTest({ generated: 8, limit: 16, callback});
let msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
startTest({ generated: 8, limit: 8, callback});
msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
startTest({ generated: 8, limit: 7, callback});
msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
startTest({ generated: 8, limit: 0, callback});
msg = await Protocol.Runtime.onceConsoleAPICalled();
dumpCaptured(msg.params.stackTrace.parent);
await Protocol.Runtime.disable();
}
]);
function startTest(params) {
InspectorTest.log('Actual call chain length: ' + params.generated);
InspectorTest.log('setAsyncCallStackDepth(maxDepth): ' + params.limit);
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: params.limit});
Protocol.Runtime.evaluate({expression:
`promisesChain(${params.generated}).then(${params.callback})`});
}
function dumpCaptured(stack) {
let count = 0;
while (stack) {
++count;
stack = stack.parent;
}
InspectorTest.log('reported: ' + count + '\n');
}