From 00e389d238846a67cbf01fb3a3ccf63212526bad Mon Sep 17 00:00:00 2001 From: Johannes Henkel Date: Tue, 25 Jun 2019 17:45:46 -0700 Subject: [PATCH] [DevTools] V8StackTrace: Add the ability to limit the max async depth... ... when building inspector objects. This is useful in Chromium, when recording the initiator information for navigations. See https://chromium-review.googlesource.com/c/chromium/src/+/1674885 Change-Id: Ib9ddcaf05586ca1f48a31921a20ab11a703ec7b0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1677381 Reviewed-by: Yang Guo Reviewed-by: Alexei Filippov Commit-Queue: Johannes Henkel Cr-Commit-Position: refs/heads/master@{#62389} --- include/v8-inspector.h | 2 ++ src/inspector/v8-stack-trace-impl.cc | 6 ++++++ src/inspector/v8-stack-trace-impl.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/include/v8-inspector.h b/include/v8-inspector.h index a5eab4fafa..cfa2aaba96 100644 --- a/include/v8-inspector.h +++ b/include/v8-inspector.h @@ -109,6 +109,8 @@ class V8_EXPORT V8StackTrace { virtual ~V8StackTrace() = default; virtual std::unique_ptr buildInspectorObject() const = 0; + virtual std::unique_ptr + buildInspectorObject(int maxAsyncDepth) const = 0; virtual std::unique_ptr toString() const = 0; // Safe to pass between threads, drops async chain. diff --git a/src/inspector/v8-stack-trace-impl.cc b/src/inspector/v8-stack-trace-impl.cc index 09177481f5..e2be811069 100644 --- a/src/inspector/v8-stack-trace-impl.cc +++ b/src/inspector/v8-stack-trace-impl.cc @@ -285,6 +285,12 @@ V8StackTraceImpl::buildInspectorObject() const { return buildInspectorObjectImpl(nullptr); } +std::unique_ptr +V8StackTraceImpl::buildInspectorObject(int maxAsyncDepth) const { + return buildInspectorObjectImpl(nullptr, + std::min(maxAsyncDepth, m_maxAsyncDepth)); +} + std::unique_ptr V8StackTraceImpl::toString() const { String16Builder stackTrace; for (size_t i = 0; i < m_frames.size(); ++i) { diff --git a/src/inspector/v8-stack-trace-impl.h b/src/inspector/v8-stack-trace-impl.h index 1142cfaa82..681b3c2aba 100644 --- a/src/inspector/v8-stack-trace-impl.h +++ b/src/inspector/v8-stack-trace-impl.h @@ -78,6 +78,8 @@ class V8StackTraceImpl : public V8StackTrace { StringView topFunctionName() const override; std::unique_ptr buildInspectorObject() const override; + std::unique_ptr buildInspectorObject( + int maxAsyncDepth) const override; std::unique_ptr toString() const override; bool isEqualIgnoringTopFrame(V8StackTraceImpl* stackTrace) const;