Web Inspector: make ScriptCallStack::maxCallStackSizeToCapture the default value...
authorwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2017 18:34:25 +0000 (18:34 +0000)
committerwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2017 18:34:25 +0000 (18:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179048

Reviewed by Mark Lam.

Source/JavaScriptCore:

* inspector/ScriptCallStackFactory.h:
* inspector/ScriptCallStackFactory.cpp:
(createScriptCallStack):
(createScriptCallStackForConsole):
(createScriptCallStackFromException):

* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::autogenerateMetadata):
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::reportAPIException):
* inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::count):
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
(Inspector::JSGlobalObjectDebuggerAgent::breakpointActionLog):

Source/WebCore:

No change in functionality.

* bindings/js/JSDOMExceptionHandling.cpp:
(WebCore::reportException):
* dom/RejectedPromiseTracker.cpp:
(WebCore::createScriptCallStackFromReason):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::compileShader):
(WebCore::WebGLRenderingContextBase::printToConsole):
* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::buildInitiatorObject):
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::breakpointActionLog):
* inspector/WorkerDebuggerAgent.cpp:
(WebCore::WorkerDebuggerAgent::breakpointActionLog):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::postMessage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224236 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/ConsoleMessage.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp
Source/JavaScriptCore/inspector/ScriptCallStackFactory.h
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp
Source/WebCore/dom/RejectedPromiseTracker.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/inspector/PageDebuggerAgent.cpp
Source/WebCore/inspector/WorkerDebuggerAgent.cpp
Source/WebCore/page/DOMWindow.cpp

index a65bebf8cb10910a2bbd940225bb7bbea3ce6821..43fc9c0645fef4443e2eb21e2079e19e8735515b 100644 (file)
@@ -1,3 +1,25 @@
+2017-10-31  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: make ScriptCallStack::maxCallStackSizeToCapture the default value when capturing backtraces
+        https://bugs.webkit.org/show_bug.cgi?id=179048
+
+        Reviewed by Mark Lam.
+
+        * inspector/ScriptCallStackFactory.h:
+        * inspector/ScriptCallStackFactory.cpp:
+        (createScriptCallStack):
+        (createScriptCallStackForConsole):
+        (createScriptCallStackFromException):
+
+        * inspector/ConsoleMessage.cpp:
+        (Inspector::ConsoleMessage::autogenerateMetadata):
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::reportAPIException):
+        * inspector/agents/InspectorConsoleAgent.cpp:
+        (Inspector::InspectorConsoleAgent::count):
+        * inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
+        (Inspector::JSGlobalObjectDebuggerAgent::breakpointActionLog):
+
 2017-10-31  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix GTK+ make distcheck.
index 9db5dff4619ef59015d5ee936f81a8789053e6af..9084862d271b95664012a31522abf75ca968bc42 100644 (file)
@@ -109,7 +109,7 @@ void ConsoleMessage::autogenerateMetadata(JSC::ExecState* state)
         return;
 
     // FIXME: Should this really be using "for console" in the generic ConsoleMessage autogeneration? This can skip the first frame.
-    m_callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture);
+    m_callStack = createScriptCallStackForConsole(state);
 
     if (const ScriptCallFrame* frame = m_callStack->firstNonNativeCallFrame()) {
         m_url = frame->sourceURL();
index d3dcb32884b33c5139133c3d281cca2970cfd58a..f17a1e0a8d7657f246643faae0a7e8059e44fe3b 100644 (file)
@@ -211,7 +211,7 @@ void JSGlobalObjectInspectorController::reportAPIException(ExecState* exec, Exce
     auto scope = DECLARE_CATCH_SCOPE(vm);
     ErrorHandlingScope errorScope(vm);
 
-    Ref<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture);
+    Ref<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception);
     if (includesNativeCallStackWhenReportingExceptions())
         appendAPIBacktrace(callStack.get());
 
index 6c77981f7f77b92392bbb03b485d2ea9581f74ce..04e50dbd62b7d13735686d86c872f92264d61a63 100644 (file)
@@ -41,7 +41,6 @@
 #include "JSCInlines.h"
 #include "ScriptArguments.h"
 #include "ScriptCallFrame.h"
-#include "ScriptCallStack.h"
 #include "ScriptValue.h"
 #include "StackVisitor.h"
 #include <wtf/text/WTFString.h>
index d87edbe31a733ee93517e3d6a5845fae3332eff0..55ca4d578f037b447008177fdc95be78d19c2c37 100644 (file)
@@ -31,6 +31,7 @@
 
 #pragma once
 
+#include "ScriptCallStack.h"
 #include <wtf/Forward.h>
 
 namespace JSC {
@@ -42,12 +43,11 @@ class JSValue;
 namespace Inspector {
 
 class ScriptArguments;
-class ScriptCallStack;
 
 // FIXME: The subtle differences between these should be eliminated.
-JS_EXPORT_PRIVATE Ref<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize);
-JS_EXPORT_PRIVATE Ref<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState*, size_t maxStackSize);
-JS_EXPORT_PRIVATE Ref<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState*, JSC::Exception*, size_t maxStackSize);
+JS_EXPORT_PRIVATE Ref<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
+JS_EXPORT_PRIVATE Ref<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
+JS_EXPORT_PRIVATE Ref<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState*, JSC::Exception*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
 JS_EXPORT_PRIVATE Ref<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount);
 
 } // namespace Inspector
index 32d4e30ff061ce6623e81429bf750a219fb36e08..fb8c5c802d2750de55e5f23ce4a7cadc027afe34 100644 (file)
@@ -182,7 +182,7 @@ void InspectorConsoleAgent::takeHeapSnapshot(const String& title)
 
 void InspectorConsoleAgent::count(JSC::ExecState* state, Ref<ScriptArguments>&& arguments)
 {
-    Ref<ScriptCallStack> callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture);
+    Ref<ScriptCallStack> callStack = createScriptCallStackForConsole(state);
 
     String title;
     String identifier;
index 117fbefe6f91a58054f677ff99f6dffbe9031194..229a5ed3bf7e274317c49bacf79a31e76d1835ba 100644 (file)
@@ -58,7 +58,7 @@ InjectedScript JSGlobalObjectDebuggerAgent::injectedScriptForEval(ErrorString& e
 
 void JSGlobalObjectDebuggerAgent::breakpointActionLog(JSC::ExecState& state, const String& message)
 {
-    m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture), 0));
+    m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(&state), 0));
 }
 
 } // namespace Inspector
index 2d2a6c9682c54f1f0f0d8cd11e89086bbc1f931a..0965b96b59a4a70078f84791379a5624e088b62d 100644 (file)
@@ -1,3 +1,28 @@
+2017-10-31  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: make ScriptCallStack::maxCallStackSizeToCapture the default value when capturing backtraces
+        https://bugs.webkit.org/show_bug.cgi?id=179048
+
+        Reviewed by Mark Lam.
+
+        No change in functionality.
+
+        * bindings/js/JSDOMExceptionHandling.cpp:
+        (WebCore::reportException):
+        * dom/RejectedPromiseTracker.cpp:
+        (WebCore::createScriptCallStackFromReason):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::compileShader):
+        (WebCore::WebGLRenderingContextBase::printToConsole):
+        * inspector/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::buildInitiatorObject):
+        * inspector/PageDebuggerAgent.cpp:
+        (WebCore::PageDebuggerAgent::breakpointActionLog):
+        * inspector/WorkerDebuggerAgent.cpp:
+        (WebCore::WorkerDebuggerAgent::breakpointActionLog):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::postMessage):
+
 2017-10-31  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Build more files under WebCore as unified sources
index a107dc4ed151bd1c21da7a87e9b4d14f7d953e85..91e782532487018788f29952b9915ac80f8fffb1 100644 (file)
@@ -83,7 +83,7 @@ void reportException(ExecState* exec, JSC::Exception* exception, CachedScript* c
 
     ErrorHandlingScope errorScope(exec->vm());
 
-    auto callStack = Inspector::createScriptCallStackFromException(exec, exception, Inspector::ScriptCallStack::maxCallStackSizeToCapture);
+    auto callStack = Inspector::createScriptCallStackFromException(exec, exception);
     scope.clearException();
     vm.clearLastException();
 
index 21602e61c03c880c37471ce0037312eb6daaa78a..7c025274a21d0abde3ad88d15f6162eb8a32df30 100644 (file)
@@ -93,12 +93,12 @@ static RefPtr<ScriptCallStack> createScriptCallStackFromReason(ExecState& state,
     // Always capture a stack from the exception if this rejection was an exception.
     if (auto* exception = vm.lastException()) {
         if (exception->value() == reason)
-            return createScriptCallStackFromException(&state, exception, ScriptCallStack::maxCallStackSizeToCapture);
+            return createScriptCallStackFromException(&state, exception);
     }
 
     // Otherwise, only capture a stack if a debugger is open.
     if (state.lexicalGlobalObject()->debugger())
-        return createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture);
+        return createScriptCallStack(&state);
 
     return nullptr;
 }
index 2eb62e83c0b546705816d276c5500fda618328b6..24d7b21841a72f2b28f04bde33a5c6e8c5736289 100644 (file)
@@ -1309,7 +1309,7 @@ void WebGLRenderingContextBase::compileShader(WebGLShader* shader)
     shader->setValid(value);
 
     if (m_synthesizedErrorsToConsole && !value) {
-        Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState(), Inspector::ScriptCallStack::maxCallStackSizeToCapture);
+        Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState());
 
         Vector<String> errors;
         getShaderInfoLog(shader).split("\n", errors);
@@ -5278,7 +5278,7 @@ void WebGLRenderingContextBase::printToConsole(MessageLevel level, const String&
 
     // Error messages can occur during function calls, so show stack traces for them.
     if (level == MessageLevel::Error) {
-        Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState(), Inspector::ScriptCallStack::maxCallStackSizeToCapture);
+        Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState());
         consoleMessage = std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, level, message, WTFMove(stackTrace));
     } else
         consoleMessage = std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, level, message);
index 80f89d4748a40e64d90e6ceed3c13270cf6af1ad..648cf87a307e79c60c92953d76e21f14e7adf716 100644 (file)
@@ -608,7 +608,7 @@ void InspectorNetworkAgent::didScheduleStyleRecalculation(Document& document)
 
 RefPtr<Inspector::Protocol::Network::Initiator> InspectorNetworkAgent::buildInitiatorObject(Document* document)
 {
-    Ref<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture);
+    Ref<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState());
     if (stackTrace->size() > 0) {
         auto initiatorObject = Inspector::Protocol::Network::Initiator::create()
             .setType(Inspector::Protocol::Network::Initiator::Type::Script)
index 0158dad409b6289209fed8c0a2bd0de32e43235d..6179f8529be9441010015292000847b5862ed20d 100644 (file)
@@ -117,7 +117,7 @@ void PageDebuggerAgent::unmuteConsole()
 
 void PageDebuggerAgent::breakpointActionLog(JSC::ExecState& state, const String& message)
 {
-    m_pageAgent->page().console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture));
+    m_pageAgent->page().console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(&state));
 }
 
 InjectedScript PageDebuggerAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
index 4529c2d959c985906c6bd53d2601d11e2baf3ac3..d9cf06bac569efe9b1d73762b37cbdd2c08783b9 100644 (file)
@@ -49,7 +49,7 @@ WorkerDebuggerAgent::~WorkerDebuggerAgent() = default;
 
 void WorkerDebuggerAgent::breakpointActionLog(ExecState& state, const String& message)
 {
-    m_workerGlobalScope.addConsoleMessage(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture)));
+    m_workerGlobalScope.addConsoleMessage(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(&state)));
 }
 
 InjectedScript WorkerDebuggerAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
index 006e520f3086900a627f916f2b59703103729ac1..dcf057d34c5bcd2374df22c471dfec51586cd514 100644 (file)
@@ -938,7 +938,7 @@ ExceptionOr<void> DOMWindow::postMessage(JSC::ExecState& state, DOMWindow& incum
     // Capture stack trace only when inspector front-end is loaded as it may be time consuming.
     RefPtr<ScriptCallStack> stackTrace;
     if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument))
-        stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture);
+        stackTrace = createScriptCallStack(JSMainThreadExecState::currentState());
 
     // Schedule the message.
     auto* timer = new PostMessageTimer(*this, message.releaseReturnValue(), sourceOrigin, incumbentWindow, channels.releaseReturnValue(), WTFMove(target), WTFMove(stackTrace));