Title: [183319] trunk/Source/_javascript_Core
Revision
183319
Author
[email protected]
Date
2015-04-25 18:06:59 -0700 (Sat, 25 Apr 2015)

Log Message

Allow for pausing a JSContext when opening a Web Inspector
<rdar://problem/20564788>

Reviewed by Timothy Hatcher.

* inspector/remote/RemoteInspector.mm:
(Inspector::RemoteInspector::receivedSetupMessage):
* inspector/remote/RemoteInspectorConstants.h:
* inspector/remote/RemoteInspectorDebuggable.h:
* inspector/remote/RemoteInspectorDebuggableConnection.h:
* inspector/remote/RemoteInspectorDebuggableConnection.mm:
(Inspector::RemoteInspectorDebuggableConnection::setup):
On any incoming setup message, we may want to automatically
pause the debuggable. If requested, pause the debuggable
after we have setup the frontend connection.

* runtime/JSGlobalObjectDebuggable.h:
* runtime/JSGlobalObjectDebuggable.cpp:
(JSC::JSGlobalObjectDebuggable::pause):
Pass through to the inspector controller.

* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::pause):
Enable pause on next statement.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (183318 => 183319)


--- trunk/Source/_javascript_Core/ChangeLog	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-04-26 01:06:59 UTC (rev 183319)
@@ -1,3 +1,31 @@
+2015-04-25  Joseph Pecoraro  <[email protected]>
+
+        Allow for pausing a JSContext when opening a Web Inspector
+        <rdar://problem/20564788>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/remote/RemoteInspector.mm:
+        (Inspector::RemoteInspector::receivedSetupMessage):
+        * inspector/remote/RemoteInspectorConstants.h:
+        * inspector/remote/RemoteInspectorDebuggable.h:
+        * inspector/remote/RemoteInspectorDebuggableConnection.h:
+        * inspector/remote/RemoteInspectorDebuggableConnection.mm:
+        (Inspector::RemoteInspectorDebuggableConnection::setup):
+        On any incoming setup message, we may want to automatically
+        pause the debuggable. If requested, pause the debuggable
+        after we have setup the frontend connection.
+
+        * runtime/JSGlobalObjectDebuggable.h:
+        * runtime/JSGlobalObjectDebuggable.cpp:
+        (JSC::JSGlobalObjectDebuggable::pause):
+        Pass through to the inspector controller.
+
+        * inspector/JSGlobalObjectInspectorController.h:
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::pause):
+        Enable pause on next statement.
+
 2015-04-23  Ryosuke Niwa  <[email protected]>
 
         class methods should be non-enumerable

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2015-04-26 01:06:59 UTC (rev 183319)
@@ -147,6 +147,16 @@
         m_backendDispatcher->dispatch(message);
 }
 
+void JSGlobalObjectInspectorController::pause()
+{
+    if (!m_frontendChannel)
+        return;
+
+    ErrorString dummyError;
+    m_debuggerAgent->enable(dummyError);
+    m_debuggerAgent->pause(dummyError);
+}
+
 void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack* callStack)
 {
 #if OS(DARWIN) || (OS(LINUX) && !PLATFORM(GTK))

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h	2015-04-26 01:06:59 UTC (rev 183319)
@@ -80,6 +80,7 @@
     bool includesNativeCallStackWhenReportingExceptions() const { return m_includeNativeCallStackWithExceptions; }
     void setIncludesNativeCallStackWhenReportingExceptions(bool includesNativeCallStack) { m_includeNativeCallStackWithExceptions = includesNativeCallStack; }
 
+    void pause();
     void reportAPIException(JSC::ExecState*, JSC::JSValue exception);
 
     JSC::ConsoleClient* consoleClient() const;

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm	2015-04-26 01:06:59 UTC (rev 183319)
@@ -568,7 +568,8 @@
     RemoteInspectorDebuggableInfo debuggableInfo = it->value.second;
     RefPtr<RemoteInspectorDebuggableConnection> connection = adoptRef(new RemoteInspectorDebuggableConnection(debuggable, connectionIdentifier, sender, debuggableInfo.type));
     bool isAutomaticInspection = m_automaticInspectionCandidateIdentifier == debuggable->identifier();
-    if (!connection->setup(isAutomaticInspection)) {
+    bool automaticallyPause = [[userInfo objectForKey:WIRAutomaticallyPause] boolValue];
+    if (!connection->setup(isAutomaticInspection, automaticallyPause)) {
         connection->close();
         return;
     }

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h	2015-04-26 01:06:59 UTC (rev 183319)
@@ -72,6 +72,7 @@
 #define WIRTypeKey                              @"WIRTypeKey"
 #define WIRTypeJavaScript                       @"WIRTypeJavaScript"
 #define WIRTypeWeb                              @"WIRTypeWeb"
+#define WIRAutomaticallyPause                   @"WIRAutomaticallyPause"
 
 #define WIRAutomaticInspectionEnabledKey           @"WIRAutomaticInspectionEnabledKey"
 #define WIRAutomaticInspectionSessionIdentifierKey @"WIRAutomaticInspectionSessionIdentifierKey"

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggable.h (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggable.h	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggable.h	2015-04-26 01:06:59 UTC (rev 183319)
@@ -67,6 +67,7 @@
     virtual void disconnect() = 0;
     virtual void dispatchMessageFromRemoteFrontend(const String& message) = 0;
     virtual void setIndicating(bool) { } // Default is to do nothing.
+    virtual void pause() { };
 
     virtual bool automaticInspectionAllowed() const { return false; }
     virtual void pauseWaitingForAutomaticInspection();

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.h (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.h	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.h	2015-04-26 01:06:59 UTC (rev 183319)
@@ -83,7 +83,7 @@
     NSString *connectionIdentifier() const;
     unsigned identifier() const { return m_identifier; }
 
-    bool setup(bool isAutomaticInspection);
+    bool setup(bool isAutomaticInspection, bool automaticallyPause);
 
     void close();
     void closeFromDebuggable();

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.mm (183318 => 183319)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.mm	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.mm	2015-04-26 01:06:59 UTC (rev 183319)
@@ -150,7 +150,7 @@
     RemoteInspectorQueueTaskOnGlobalQueue(block);
 }
 
-bool RemoteInspectorDebuggableConnection::setup(bool isAutomaticInspection)
+bool RemoteInspectorDebuggableConnection::setup(bool isAutomaticInspection, bool automaticallyPause)
 {
     std::lock_guard<std::mutex> lock(m_debuggableMutex);
 
@@ -167,6 +167,9 @@
             } else {
                 m_debuggable->connect(this, isAutomaticInspection);
                 m_connected = true;
+
+                if (automaticallyPause)
+                    m_debuggable->pause();
             }
         }
         deref();

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectDebuggable.cpp (183318 => 183319)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectDebuggable.cpp	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectDebuggable.cpp	2015-04-26 01:06:59 UTC (rev 183319)
@@ -63,6 +63,13 @@
     m_globalObject.inspectorController().disconnectFrontend(DisconnectReason::InspectorDestroyed);
 }
 
+void JSGlobalObjectDebuggable::pause()
+{
+    JSLockHolder locker(&m_globalObject.vm());
+
+    m_globalObject.inspectorController().pause();
+}
+
 void JSGlobalObjectDebuggable::dispatchMessageFromRemoteFrontend(const String& message)
 {
     JSLockHolder locker(&m_globalObject.vm());

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectDebuggable.h (183318 => 183319)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectDebuggable.h	2015-04-26 00:59:47 UTC (rev 183318)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectDebuggable.h	2015-04-26 01:06:59 UTC (rev 183319)
@@ -56,6 +56,7 @@
     virtual void connect(Inspector::FrontendChannel*, bool automaticInspection) override;
     virtual void disconnect() override;
     virtual void dispatchMessageFromRemoteFrontend(const String& message) override;
+    virtual void pause() override;
 
     virtual bool automaticInspectionAllowed() const override { return true; }
     virtual void pauseWaitingForAutomaticInspection() override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to