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 a65bebf..43fc9c0 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 9db5dff..9084862 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 d3dcb32..f17a1e0 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 6c77981..04e50db 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 d87edbe..55ca4d5 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 32d4e30..fb8c5c8 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 117fbef..229a5ed 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 2d2a6c9..0965b96 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 a107dc4..91e7825 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 21602e6..7c02527 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 2eb62e8..24d7b21 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 80f89d4..648cf87 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 0158dad..6179f85 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 4529c2d..d9cf06b 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 006e520..dcf057d 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));