Title: [177585] trunk/Source
Revision
177585
Author
[email protected]
Date
2014-12-19 11:37:19 -0800 (Fri, 19 Dec 2014)

Log Message

Web Inspector: CRASH inspector-protocol/debugger/breakpoint-action-detach.html
https://bugs.webkit.org/show_bug.cgi?id=139797

Patch by Joseph Pecoraro <[email protected]> on 2014-12-19
Reviewed by Mark Lam.

Source/_javascript_Core:

* debugger/Debugger.h:
* debugger/Debugger.cpp:
(JSC::Debugger::isAttached):
Check if we are the debugger for a particular global object.
(JSC::Debugger::pauseIfNeeded):
Pass the global object on when hitting a brekapoint.

* inspector/ScriptDebugServer.h:
* inspector/ScriptDebugServer.cpp:
(Inspector::ScriptDebugServer::handleBreakpointHit):
Stop evaluting breakpoint actions if a previous action caused the
debugger to detach from this global object.
(Inspector::ScriptDebugServer::handlePause):
Standardize on passing JSGlobalObject parameter first.

Source/WebKit/mac:

* WebView/WebScriptDebugger.h:
* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::handlePause):
Standardize on passing JSGlobalObject parameter first.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (177584 => 177585)


--- trunk/Source/_javascript_Core/ChangeLog	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-12-19 19:37:19 UTC (rev 177585)
@@ -1,3 +1,25 @@
+2014-12-19  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: CRASH inspector-protocol/debugger/breakpoint-action-detach.html
+        https://bugs.webkit.org/show_bug.cgi?id=139797
+
+        Reviewed by Mark Lam.
+
+        * debugger/Debugger.h:
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::isAttached):
+        Check if we are the debugger for a particular global object.
+        (JSC::Debugger::pauseIfNeeded):
+        Pass the global object on when hitting a brekapoint.
+
+        * inspector/ScriptDebugServer.h:
+        * inspector/ScriptDebugServer.cpp:
+        (Inspector::ScriptDebugServer::handleBreakpointHit):
+        Stop evaluting breakpoint actions if a previous action caused the
+        debugger to detach from this global object.
+        (Inspector::ScriptDebugServer::handlePause):
+        Standardize on passing JSGlobalObject parameter first.
+
 2014-12-19  Mark Lam  <[email protected]>
 
         [Win] Endless compiler warnings created by DFGEdge.h.

Modified: trunk/Source/_javascript_Core/debugger/Debugger.cpp (177584 => 177585)


--- trunk/Source/_javascript_Core/debugger/Debugger.cpp	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/_javascript_Core/debugger/Debugger.cpp	2014-12-19 19:37:19 UTC (rev 177585)
@@ -206,6 +206,11 @@
         m_vm = nullptr;
 }
 
+bool Debugger::isAttached(JSGlobalObject* globalObject)
+{
+    return globalObject->debugger() == this;
+}
+
 class Debugger::SetSteppingModeFunctor {
 public:
     SetSteppingModeFunctor(Debugger* debugger, SteppingMode mode)
@@ -660,14 +665,14 @@
     m_pauseOnNextStatement = false;
 
     if (didHitBreakpoint) {
-        handleBreakpointHit(breakpoint);
+        handleBreakpointHit(vmEntryGlobalObject, breakpoint);
         // Note that the actions can potentially stop the debugger, so we need to check that
         // we still have a current call frame when we get back.
         if (breakpoint.autoContinue || !m_currentCallFrame)
             return;
     }
 
-    handlePause(m_reasonForPause, vmEntryGlobalObject);
+    handlePause(vmEntryGlobalObject, m_reasonForPause);
 
     if (!m_pauseOnNextStatement && !m_pauseOnCallFrame) {
         setSteppingMode(SteppingModeDisabled);

Modified: trunk/Source/_javascript_Core/debugger/Debugger.h (177584 => 177585)


--- trunk/Source/_javascript_Core/debugger/Debugger.h	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/_javascript_Core/debugger/Debugger.h	2014-12-19 19:37:19 UTC (rev 177585)
@@ -60,12 +60,13 @@
 
     bool needsExceptionCallbacks() const { return m_pauseOnExceptionsState != DontPauseOnExceptions; }
 
-    void attach(JSGlobalObject*);
     enum ReasonForDetach {
         TerminatingDebuggingSession,
         GlobalObjectIsDestructing
     };
-    virtual void detach(JSGlobalObject*, ReasonForDetach);
+    void attach(JSGlobalObject*);
+    void detach(JSGlobalObject*, ReasonForDetach);
+    bool isAttached(JSGlobalObject*);
 
     BreakpointID setBreakpoint(Breakpoint, unsigned& actualLine, unsigned& actualColumn);
     void removeBreakpoint(BreakpointID);
@@ -89,7 +90,7 @@
     void stepOverStatement();
     void stepOutOfFunction();
 
-    bool isPaused() { return m_isPaused; }
+    bool isPaused() const { return m_isPaused; }
     bool isStepping() const { return m_steppingMode == SteppingModeEnabled; }
 
     virtual void sourceParsed(ExecState*, SourceProvider*, int errorLineNumber, const WTF::String& errorMessage) = 0;
@@ -108,7 +109,7 @@
 
 protected:
     virtual bool needPauseHandling(JSGlobalObject*) { return false; }
-    virtual void handleBreakpointHit(const Breakpoint&) { }
+    virtual void handleBreakpointHit(JSGlobalObject*, const Breakpoint&) { }
     virtual void handleExceptionInBreakpointCondition(ExecState*, JSValue exception) const { UNUSED_PARAM(exception); }
 
     enum ReasonForPause {
@@ -124,7 +125,7 @@
 
     ReasonForPause reasonForPause() const { return m_reasonForPause; }
 
-    virtual void handlePause(ReasonForPause, JSGlobalObject*) { }
+    virtual void handlePause(JSGlobalObject*, ReasonForPause) { }
     virtual void notifyDoneProcessingDebuggerEvents() { }
 
 private:

Modified: trunk/Source/_javascript_Core/inspector/ScriptDebugServer.cpp (177584 => 177585)


--- trunk/Source/_javascript_Core/inspector/ScriptDebugServer.cpp	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/_javascript_Core/inspector/ScriptDebugServer.cpp	2014-12-19 19:37:19 UTC (rev 177585)
@@ -286,15 +286,20 @@
     m_doneProcessingDebuggerEvents = true;
 }
 
-void ScriptDebugServer::handleBreakpointHit(const JSC::Breakpoint& breakpoint)
+void ScriptDebugServer::handleBreakpointHit(JSC::JSGlobalObject* globalObject, const JSC::Breakpoint& breakpoint)
 {
+    ASSERT(isAttached(globalObject));
+
     m_currentProbeBatchId++;
+
     BreakpointIDToActionsMap::iterator it = m_breakpointIDToActions.find(breakpoint.id);
     if (it != m_breakpointIDToActions.end()) {
-        BreakpointActions& actions = it->value;
+        BreakpointActions actions = it->value;
         for (size_t i = 0; i < actions.size(); ++i) {
             if (!evaluateBreakpointAction(actions[i]))
                 return;
+            if (!isAttached(globalObject))
+                return;
         }
     }
 }
@@ -304,7 +309,7 @@
     reportException(exec, exception);
 }
 
-void ScriptDebugServer::handlePause(Debugger::ReasonForPause, JSGlobalObject* vmEntryGlobalObject)
+void ScriptDebugServer::handlePause(JSGlobalObject* vmEntryGlobalObject, Debugger::ReasonForPause)
 {
     dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause);
     didPause(vmEntryGlobalObject);

Modified: trunk/Source/_javascript_Core/inspector/ScriptDebugServer.h (177584 => 177585)


--- trunk/Source/_javascript_Core/inspector/ScriptDebugServer.h	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/_javascript_Core/inspector/ScriptDebugServer.h	2014-12-19 19:37:19 UTC (rev 177585)
@@ -100,9 +100,9 @@
 
     virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const String& errorMsg) override final;
     virtual bool needPauseHandling(JSC::JSGlobalObject*) override final { return true; }
-    virtual void handleBreakpointHit(const JSC::Breakpoint&) override final;
+    virtual void handleBreakpointHit(JSC::JSGlobalObject*, const JSC::Breakpoint&) override final;
     virtual void handleExceptionInBreakpointCondition(JSC::ExecState*, JSC::JSValue exception) const override final;
-    virtual void handlePause(JSC::Debugger::ReasonForPause, JSC::JSGlobalObject*) override final;
+    virtual void handlePause(JSC::JSGlobalObject*, JSC::Debugger::ReasonForPause) override final;
     virtual void notifyDoneProcessingDebuggerEvents() override final;
 
     Deprecated::ScriptValue exceptionOrCaughtValue(JSC::ExecState*);

Modified: trunk/Source/WebKit/mac/ChangeLog (177584 => 177585)


--- trunk/Source/WebKit/mac/ChangeLog	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-12-19 19:37:19 UTC (rev 177585)
@@ -1,3 +1,15 @@
+2014-12-19  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: CRASH inspector-protocol/debugger/breakpoint-action-detach.html
+        https://bugs.webkit.org/show_bug.cgi?id=139797
+
+        Reviewed by Mark Lam.
+
+        * WebView/WebScriptDebugger.h:
+        * WebView/WebScriptDebugger.mm:
+        (WebScriptDebugger::handlePause):
+        Standardize on passing JSGlobalObject parameter first.
+
 2014-12-19  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r177574.

Modified: trunk/Source/WebKit/mac/WebView/WebScriptDebugger.h (177584 => 177585)


--- trunk/Source/WebKit/mac/WebView/WebScriptDebugger.h	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/WebKit/mac/WebView/WebScriptDebugger.h	2014-12-19 19:37:19 UTC (rev 177585)
@@ -56,7 +56,7 @@
 
 private:
     virtual void sourceParsed(JSC::ExecState*, JSC::SourceProvider*, int errorLine, const WTF::String& errorMsg) override;
-    virtual void handlePause(JSC::Debugger::ReasonForPause, JSC::JSGlobalObject*) override;
+    virtual void handlePause(JSC::JSGlobalObject*, JSC::Debugger::ReasonForPause) override;
     virtual bool needPauseHandling(JSC::JSGlobalObject*) override { return true; }
 
     bool m_callingDelegate;

Modified: trunk/Source/WebKit/mac/WebView/WebScriptDebugger.mm (177584 => 177585)


--- trunk/Source/WebKit/mac/WebView/WebScriptDebugger.mm	2014-12-19 19:34:19 UTC (rev 177584)
+++ trunk/Source/WebKit/mac/WebView/WebScriptDebugger.mm	2014-12-19 19:37:19 UTC (rev 177585)
@@ -118,7 +118,7 @@
     m_callingDelegate = false;
 }
 
-void WebScriptDebugger::handlePause(Debugger::ReasonForPause reason, JSGlobalObject* globalObject)
+void WebScriptDebugger::handlePause(JSGlobalObject* globalObject, Debugger::ReasonForPause reason)
 {
     if (m_callingDelegate)
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to