Commit f69527ee authored by Hidy Han's avatar Hidy Han Committed by Commit Bot

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: 's avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53466}
parent 60a858de
......@@ -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 @@
]
}
]
}
\ No newline at end of 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
......
......@@ -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();
......
......@@ -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
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
}
}
// 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);
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