Expose Runtime.setAsyncCallStackDepth API for async stack collection.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I4a29336a585bb690f915c876b3b07eb2601d027b
Reviewed-on: https://chromium-review.googlesource.com/1080225
Commit-Queue: Hidy Han <hidyhan@chromium.org>
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53466}
This commit is contained in:
Hidy Han 2018-05-31 18:20:27 -07:00 committed by Commit Bot
parent 60a858deb1
commit f69527ee49
6 changed files with 77 additions and 3 deletions

View File

@ -2858,6 +2858,18 @@
}
]
},
{
"name": "setAsyncCallStackDepth",
"description": "Enables or disables async call stacks tracking.",
"parameters": [
{
"name": "maxDepth",
"description": "Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async\ncall stacks (default).",
"type": "integer"
}
],
"redirect": "Debugger"
},
{
"name": "setCustomObjectFormatterEnabled",
"experimental": true,
@ -3093,4 +3105,4 @@
]
}
]
}
}

View File

@ -1314,6 +1314,14 @@ domain Runtime
# Exception details.
optional ExceptionDetails exceptionDetails
# Enables or disables async call stacks tracking.
command setAsyncCallStackDepth
redirect Debugger
parameters
# Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async
# call stacks (default).
integer maxDepth
experimental command setCustomObjectFormatterEnabled
parameters
boolean enabled

View File

@ -1213,7 +1213,9 @@ Response V8DebuggerAgentImpl::setReturnValue(
}
Response V8DebuggerAgentImpl::setAsyncCallStackDepth(int depth) {
if (!enabled()) return Response::Error(kDebuggerNotEnabled);
if (!enabled() && !m_session->runtimeAgent()->enabled()) {
return Response::Error(kDebuggerNotEnabled);
}
m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth);
m_debugger->setAsyncCallStackDepth(this, depth);
return Response::OK();

View File

@ -760,6 +760,9 @@ Response V8RuntimeAgentImpl::disable() {
reset();
m_inspector->client()->endEnsureAllContextsInGroup(
m_session->contextGroupId());
if (m_session->debuggerAgent() && !m_session->debuggerAgent()->enabled()) {
m_session->debuggerAgent()->setAsyncCallStackDepth(0);
}
return Response::OK();
}
@ -816,5 +819,4 @@ bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message,
m_frontend.flush();
return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId());
}
} // namespace v8_inspector

View File

@ -0,0 +1,31 @@
Checks that async stack is captured when Runtime.setAsyncCallStackDepth is called with an argument greater than zero.
{
callFrames : [
[0] : {
columnNumber : 8
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
parent : {
callFrames : [
[0] : {
columnNumber : 2
functionName : test
lineNumber : 2
scriptId : <scriptId>
url : test.js
}
[1] : {
columnNumber : 0
functionName :
lineNumber : 0
scriptId : <scriptId>
url : expr.js
}
]
description : setTimeout
}
}

View File

@ -0,0 +1,19 @@
// Copyright 2018 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('Checks that async stack is captured when Runtime.setAsyncCallStackDepth is called with an argument greater than zero.');
Protocol.Runtime.enable();
Protocol.Runtime.onConsoleAPICalled(
message => InspectorTest.logMessage(message.params.stackTrace));
contextGroup.addScript(`
async function test() {
setTimeout('console.log("async")', 0);
}
//# sourceURL=test.js`);
Protocol.Runtime.setAsyncCallStackDepth({maxDepth: 10});
Protocol.Runtime.evaluate({ expression: 'test()//# sourceURL=expr.js'})
.then(InspectorTest.completeTest);