Title: [165008] trunk
Revision
165008
Author
mark....@apple.com
Date
2014-03-03 14:12:10 -0800 (Mon, 03 Mar 2014)

Log Message

Web Inspector: debugger statements do not break.
<https://webkit.org/b/129524>

Reviewed by Geoff Garen.

Source/_javascript_Core: 

Since we no longer call op_debug hooks unless there is a debugger request
made on the CodeBlock, the op_debug for the debugger statement never gets
serviced.

With this fix, we check in the CodeBlock constructor if any debugger
statements are present.  If so, we set a m_hasDebuggerStatement flag that
causes the CodeBlock to show as having debugger requests.  Hence,
breaking at debugger statements is now restored.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::hasDebuggerRequests):
(JSC::CodeBlock::clearDebuggerRequests):

LayoutTests: 

* inspector-protocol/debugger/debugger-statement-expected.txt: Added.
* inspector-protocol/debugger/debugger-statement.html: Added.
* inspector-protocol/debugger/resources/breakpoint.js:
(debuggerStatement):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (165007 => 165008)


--- trunk/LayoutTests/ChangeLog	2014-03-03 21:52:31 UTC (rev 165007)
+++ trunk/LayoutTests/ChangeLog	2014-03-03 22:12:10 UTC (rev 165008)
@@ -1,3 +1,15 @@
+2014-03-03  Mark Lam  <mark....@apple.com>
+
+        Web Inspector: debugger statements do not break.
+        <https://webkit.org/b/129524>
+
+        Reviewed by Geoff Garen.
+
+        * inspector-protocol/debugger/debugger-statement-expected.txt: Added.
+        * inspector-protocol/debugger/debugger-statement.html: Added.
+        * inspector-protocol/debugger/resources/breakpoint.js:
+        (debuggerStatement):
+
 2014-03-03  Brian Burg  <bb...@apple.com>
 
         Inspector test dom/dom-search-crash.html times out in release builds

Added: trunk/LayoutTests/inspector-protocol/debugger/debugger-statement-expected.txt (0 => 165008)


--- trunk/LayoutTests/inspector-protocol/debugger/debugger-statement-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/debugger-statement-expected.txt	2014-03-03 22:12:10 UTC (rev 165008)
@@ -0,0 +1,9 @@
+Debugger statement should break in debugger.
+
+Found breakpoint.js
+In function with debugger statement
+Broke at debugger statement
+
+After debugger statement
+PASS
+

Added: trunk/LayoutTests/inspector-protocol/debugger/debugger-statement.html (0 => 165008)


--- trunk/LayoutTests/inspector-protocol/debugger/debugger-statement.html	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/debugger-statement.html	2014-03-03 22:12:10 UTC (rev 165008)
@@ -0,0 +1,46 @@
+<html>
+<head>
+<script src=""
+<script src=""
+
+<script>
+// Put this here instead of on <body onload> to prevent an extra Debugger.scriptParsed event.
+window._onload_ = runTest;
+
+function test()
+{
+    // This test setting 2 breakpoints in DFG compiled functions: one inlined,
+    // and one not inlined.
+
+    InspectorTest.sendCommand("Debugger.enable", {});
+
+    var breakpointFound = false;
+
+    InspectorTest.eventHandler["Debugger.scriptParsed"] = function(messageObject)
+    {
+        if (/resources\/breakpoint\.js$/.test(messageObject.params.url)) {
+            InspectorTest.log("Found breakpoint.js");
+
+            InspectorTest.sendCommand("Runtime.evaluate", {
+                _expression_: "debuggerStatement();"
+            }, function(responseObject) {
+                if (breakpointFound)
+                    InspectorTest.log("PASS");
+                InspectorTest.completeTest();
+            });
+        }
+    }
+
+    InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
+    {
+        InspectorTest.log("Broke at debugger statement\n");
+        breakpointFound = true;
+        InspectorTest.sendCommand("Debugger.resume", {});
+    }
+}
+</script>
+</head>
+<body>
+<p>Debugger statement should break in debugger.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js (165007 => 165008)


--- trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js	2014-03-03 21:52:31 UTC (rev 165007)
+++ trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js	2014-03-03 22:12:10 UTC (rev 165008)
@@ -82,3 +82,12 @@
     else
         log("FAIL: result is " + result + ", expecting 20003");
 }
+
+function debuggerStatement(x)
+{
+    log("In function with debugger statement");
+    debugger;
+    log("After debugger statement");
+    return x + 3;
+}
+

Modified: trunk/Source/_javascript_Core/ChangeLog (165007 => 165008)


--- trunk/Source/_javascript_Core/ChangeLog	2014-03-03 21:52:31 UTC (rev 165007)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-03-03 22:12:10 UTC (rev 165008)
@@ -1,5 +1,27 @@
 2014-03-03  Mark Lam  <mark....@apple.com>
 
+        Web Inspector: debugger statements do not break.
+        <https://webkit.org/b/129524>
+
+        Reviewed by Geoff Garen.
+
+        Since we no longer call op_debug hooks unless there is a debugger request
+        made on the CodeBlock, the op_debug for the debugger statement never gets
+        serviced.
+
+        With this fix, we check in the CodeBlock constructor if any debugger
+        statements are present.  If so, we set a m_hasDebuggerStatement flag that
+        causes the CodeBlock to show as having debugger requests.  Hence,
+        breaking at debugger statements is now restored.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::CodeBlock):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::hasDebuggerRequests):
+        (JSC::CodeBlock::clearDebuggerRequests):
+
+2014-03-03  Mark Lam  <mark....@apple.com>
+
         ASSERTION FAILED: m_numBreakpoints >= numBreakpoints when deleting breakpoints.
         <https://webkit.org/b/129393>
 

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (165007 => 165008)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2014-03-03 21:52:31 UTC (rev 165007)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2014-03-03 22:12:10 UTC (rev 165008)
@@ -1420,6 +1420,7 @@
     , m_didFailFTLCompilation(false)
     , m_hasBeenCompiledWithFTL(false)
     , m_unlinkedCode(*other.m_vm, other.m_ownerExecutable.get(), other.m_unlinkedCode.get())
+    , m_hasDebuggerStatement(false)
     , m_steppingMode(SteppingModeDisabled)
     , m_numBreakpoints(0)
     , m_ownerExecutable(*other.m_vm, other.m_ownerExecutable.get(), other.m_ownerExecutable.get())
@@ -1477,6 +1478,7 @@
     , m_didFailFTLCompilation(false)
     , m_hasBeenCompiledWithFTL(false)
     , m_unlinkedCode(m_globalObject->vm(), ownerExecutable, unlinkedCodeBlock)
+    , m_hasDebuggerStatement(false)
     , m_steppingMode(SteppingModeDisabled)
     , m_numBreakpoints(0)
     , m_ownerExecutable(m_globalObject->vm(), ownerExecutable, ownerExecutable)
@@ -1779,6 +1781,12 @@
             break;
         }
 
+        case op_debug: {
+            if (pc[1].u.index == DidReachBreakpoint)
+                m_hasDebuggerStatement = true;
+            break;
+        }
+
         default:
             break;
         }

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (165007 => 165008)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2014-03-03 21:52:31 UTC (rev 165007)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2014-03-03 22:12:10 UTC (rev 165008)
@@ -877,7 +877,7 @@
 
     bool hasOpDebugForLineAndColumn(unsigned line, unsigned column);
 
-    bool hasDebuggerRequests() const { return !!m_debuggerRequests; }
+    bool hasDebuggerRequests() const { return m_debuggerRequests; }
     void* debuggerRequestsAddress() { return &m_debuggerRequests; }
 
     void addBreakpoint(unsigned numBreakpoints);
@@ -893,7 +893,11 @@
     };
     void setSteppingMode(SteppingMode);
 
-    void clearDebuggerRequests() { m_debuggerRequests = 0; }
+    void clearDebuggerRequests()
+    {
+        m_steppingMode = SteppingModeDisabled;
+        m_numBreakpoints = 0;
+    }
     
     // FIXME: Make these remaining members private.
 
@@ -1027,8 +1031,9 @@
     union {
         unsigned m_debuggerRequests;
         struct {
+            unsigned m_hasDebuggerStatement : 1;
             unsigned m_steppingMode : 1;
-            unsigned m_numBreakpoints : 31;
+            unsigned m_numBreakpoints : 30;
         };
     };
     WriteBarrier<ScriptExecutable> m_ownerExecutable;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to