Commit 38986c47 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[inspector] Do not report async stack for console.log messages

That saves some bytes on the frontend side and some cycles when generating and parsing protocol JSON for stacks.
BUG=chromium:946411

Change-Id: I36b3a48b5d8246a05b877bc21f36c08803a1c304
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1542800
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60532}
parent 6f24e4d1
...@@ -1416,7 +1416,9 @@ domain Runtime ...@@ -1416,7 +1416,9 @@ domain Runtime
ExecutionContextId executionContextId ExecutionContextId executionContextId
# Call timestamp. # Call timestamp.
Timestamp timestamp Timestamp timestamp
# Stack trace captured when the call was made. # Stack trace captured when the call was made. The async stack chain is automatically reported for
# the following call types: `assert`, `error`, `trace`, `warning`. For other types the async call
# chain can be retrieved using `Debugger.getStackTrace` and `stackTrace.parentId` field.
optional StackTrace stackTrace optional StackTrace stackTrace
# Console context descriptor for calls on non-default console context (not console.*): # Console context descriptor for calls on non-default console context (not console.*):
# 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call # 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call
......
...@@ -353,13 +353,25 @@ void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, ...@@ -353,13 +353,25 @@ void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend,
} }
Maybe<String16> consoleContext; Maybe<String16> consoleContext;
if (!m_consoleContext.isEmpty()) consoleContext = m_consoleContext; if (!m_consoleContext.isEmpty()) consoleContext = m_consoleContext;
std::unique_ptr<protocol::Runtime::StackTrace> stackTrace;
if (m_stackTrace) {
switch (m_type) {
case ConsoleAPIType::kAssert:
case ConsoleAPIType::kError:
case ConsoleAPIType::kTrace:
case ConsoleAPIType::kWarning:
stackTrace =
m_stackTrace->buildInspectorObjectImpl(inspector->debugger());
break;
default:
stackTrace =
m_stackTrace->buildInspectorObjectImpl(inspector->debugger(), 0);
break;
}
}
frontend->consoleAPICalled( frontend->consoleAPICalled(
consoleAPITypeValue(m_type), std::move(arguments), m_contextId, consoleAPITypeValue(m_type), std::move(arguments), m_contextId,
m_timestamp, m_timestamp, std::move(stackTrace), std::move(consoleContext));
m_stackTrace
? m_stackTrace->buildInspectorObjectImpl(inspector->debugger())
: nullptr,
std::move(consoleContext));
return; return;
} }
UNREACHABLE(); UNREACHABLE();
......
...@@ -29,3 +29,17 @@ Checks that async stack is captured when Runtime.setAsyncCallStackDepth is calle ...@@ -29,3 +29,17 @@ Checks that async stack is captured when Runtime.setAsyncCallStackDepth is calle
description : setTimeout description : setTimeout
} }
} }
{
callFrames : [
[0] : {
columnNumber : 32
functionName :
lineNumber : 0
scriptId : <scriptId>
url :
}
]
parentId : {
id : <id>
}
}
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
// 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.
let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async stack is captured when Runtime.setAsyncCallStackDepth is called with an argument greater than zero.'); const {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.enable();
Protocol.Runtime.onConsoleAPICalled( Protocol.Runtime.onConsoleAPICalled(
...@@ -10,7 +11,7 @@ Protocol.Runtime.onConsoleAPICalled( ...@@ -10,7 +11,7 @@ Protocol.Runtime.onConsoleAPICalled(
contextGroup.addScript(` contextGroup.addScript(`
async function test() { async function test() {
setTimeout('console.log("async")', 0); setTimeout('console.trace("async"); console.log("no-async");', 0);
} }
//# sourceURL=test.js`); //# sourceURL=test.js`);
......
...@@ -9,7 +9,7 @@ Test with max size 0. ...@@ -9,7 +9,7 @@ Test with max size 0.
] ]
executionContextId : <executionContextId> executionContextId : <executionContextId>
timestamp : <timestamp> timestamp : <timestamp>
type : log type : trace
} }
Test with max size 1. Test with max size 1.
{ {
...@@ -44,7 +44,7 @@ Test with max size 1. ...@@ -44,7 +44,7 @@ Test with max size 1.
} }
} }
timestamp : <timestamp> timestamp : <timestamp>
type : log type : trace
} }
Test with max size 2. Test with max size 2.
{ {
...@@ -93,5 +93,5 @@ Test with max size 2. ...@@ -93,5 +93,5 @@ Test with max size 2.
} }
} }
timestamp : <timestamp> timestamp : <timestamp>
type : log type : trace
} }
...@@ -10,7 +10,7 @@ Protocol.Runtime.onConsoleAPICalled( ...@@ -10,7 +10,7 @@ Protocol.Runtime.onConsoleAPICalled(
contextGroup.addScript(` contextGroup.addScript(`
function bar() { function bar() {
console.log("Nested call."); console.trace("Nested call.");
} }
function foo() { function foo() {
......
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