Emit the WillExecuteStatement debugger hook before the for loop body when the stateme...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Oct 2008 18:49:52 +0000 (18:49 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Oct 2008 18:49:52 +0000 (18:49 +0000)
JavaScriptCore:

2008-10-31  Timothy Hatcher  <timothy@apple.com>

        Emit the WillExecuteStatement debugger hook before the for loop body
        when the statement node for the body isn't a block. This allows
        breakpoints on those statements in the Web Inspector.

        https://bugs.webkit.org/show_bug.cgi?id=22004

        Reviewed by Darin Adler.

        * kjs/nodes.cpp:
        (JSC::ForNode::emitCode): Emit the WillExecuteStatement
        debugger hook before the statement node if isn't a block.
        Also emit the WillExecuteStatement debugger hook for the
        loop as the first op-code.
        (JSC::ForInNode::emitCode): Ditto.

WebCore:

2008-10-31  Timothy Hatcher  <timothy@apple.com>

        Add manual tests that check breakpoints on a blockless body of "for" loops.

        https://bugs.webkit.org/show_bug.cgi?id=22004

        Reviewed by Darin Adler.

        * manual-tests/inspector/debugger-pause-on-for-in-statements.html: Added.
        * manual-tests/inspector/debugger-pause-on-for-statements.html: Added.

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

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/nodes.cpp
WebCore/ChangeLog
WebCore/manual-tests/inspector/debugger-pause-on-for-in-statements.html [new file with mode: 0644]
WebCore/manual-tests/inspector/debugger-pause-on-for-statements.html [new file with mode: 0644]

index 779d422..8b8f19e 100644 (file)
 
 2008-10-31  Timothy Hatcher  <timothy@apple.com>
 
+        Emit the WillExecuteStatement debugger hook before the for loop body
+        when the statement node for the body isn't a block. This allows
+        breakpoints on those statements in the Web Inspector.
+
+        https://bugs.webkit.org/show_bug.cgi?id=22004
+
+        Reviewed by Darin Adler.
+
+        * kjs/nodes.cpp:
+        (JSC::ForNode::emitCode): Emit the WillExecuteStatement
+        debugger hook before the statement node if isn't a block.
+        Also emit the WillExecuteStatement debugger hook for the
+        loop as the first op-code.
+        (JSC::ForInNode::emitCode): Ditto.
+
+2008-10-31  Timothy Hatcher  <timothy@apple.com>
+
         Fixes console warnings about not having an autorelease pool.
         Also fixes the build for Snow Leopard, by including individual
         Foundation headers instead of Foundation.h.
index fa4c047..b68b453 100644 (file)
@@ -1247,6 +1247,8 @@ RegisterID* ForNode::emitCode(CodeGenerator& generator, RegisterID* dst)
 
     generator.emitLabel(topOfLoop.get());
     generator.pushJumpContext(&m_labelStack, continueTarget.get(), breakTarget.get(), true);
+    if (!m_statement->isBlock())
+        generator.emitDebugHook(WillExecuteStatement, m_statement->firstLine(), m_statement->lastLine());
     RefPtr<RegisterID> result = generator.emitNode(dst, m_statement.get());
     generator.popJumpContext();
     generator.emitLabel(continueTarget.get());
@@ -1261,9 +1263,6 @@ RegisterID* ForNode::emitCode(CodeGenerator& generator, RegisterID* dst)
         generator.emitJump(topOfLoop.get());
     }
 
-    if (!m_statement->isBlock())
-        generator.emitDebugHook(WillExecuteStatement, m_statement->firstLine(), m_statement->lastLine());
-
     generator.emitLabel(breakTarget.get());
     
     return result.get();
@@ -1305,6 +1304,8 @@ RegisterID* ForInNode::emitCode(CodeGenerator& generator, RegisterID* dst)
     RefPtr<LabelID> continueTarget = generator.newLabel(); 
     RefPtr<LabelID> breakTarget = generator.newLabel(); 
 
+    generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
+
     if (m_init)
         generator.emitNode(ignoredResult(), m_init.get());
     RegisterID* forInBase = generator.emitNode(m_expr.get());
@@ -1343,15 +1344,12 @@ RegisterID* ForInNode::emitCode(CodeGenerator& generator, RegisterID* dst)
         generator.emitExpressionInfo(assignNode->divot(), assignNode->startOffset(), assignNode->endOffset());
         generator.emitPutByVal(base.get(), subscript, propertyName);
     }   
-    
-    generator.pushJumpContext(&m_labelStack, continueTarget.get(), breakTarget.get(), true);
-    generator.emitNode(dst, m_statement.get());
-    generator.popJumpContext();
-
-    generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
 
+    generator.pushJumpContext(&m_labelStack, continueTarget.get(), breakTarget.get(), true);
     if (!m_statement->isBlock())
         generator.emitDebugHook(WillExecuteStatement, m_statement->firstLine(), m_statement->lastLine());
+    generator.emitNode(dst, m_statement.get());
+    generator.popJumpContext();
 
     generator.emitLabel(continueTarget.get());
     generator.emitNextPropertyName(propertyName, iter.get(), loopStart.get());
index 7bea01e..a66de10 100644 (file)
@@ -1,3 +1,14 @@
+2008-10-31  Timothy Hatcher  <timothy@apple.com>
+
+        Add manual tests that check breakpoints on a blockless body of "for" loops.
+
+        https://bugs.webkit.org/show_bug.cgi?id=22004
+
+        Reviewed by Darin Adler.
+
+        * manual-tests/inspector/debugger-pause-on-for-in-statements.html: Added.
+        * manual-tests/inspector/debugger-pause-on-for-statements.html: Added.
+
 2008-10-31  Darin Adler  <darin@apple.com>
 
         - fix build
diff --git a/WebCore/manual-tests/inspector/debugger-pause-on-for-in-statements.html b/WebCore/manual-tests/inspector/debugger-pause-on-for-in-statements.html
new file mode 100644 (file)
index 0000000..c0c24e0
--- /dev/null
@@ -0,0 +1,18 @@
+<script>
+function test()
+{
+    debugger;
+}
+
+var object = { test: 1 };
+
+for (var property in object)
+    test();
+</script>
+
+Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=22004">Bug 22004: Can't set a breakpoint on the statement after a single line "for"</a>.
+<br><br>
+Start a debugging session in the Web Inspector and open this file. When the debugger breaks, select the (program) node
+in the call stack, you should see the execution line on the call to test().
+<br><br>
+Also set a breakpoint on the call to test(), and reload. It should break before the test() function is called.
diff --git a/WebCore/manual-tests/inspector/debugger-pause-on-for-statements.html b/WebCore/manual-tests/inspector/debugger-pause-on-for-statements.html
new file mode 100644 (file)
index 0000000..43a63e2
--- /dev/null
@@ -0,0 +1,16 @@
+<script>
+function test()
+{
+    debugger;
+}
+
+for (var i = 0; i < 1; ++i)
+    test();
+</script>
+
+Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=22004">Bug 22004: Can't set a breakpoint on the statement after a single line "for"</a>.
+<br><br>
+Start a debugging session in the Web Inspector and open this file. When the debugger breaks, select the (program) node
+in the call stack, you should see the execution line on the call to test().
+<br><br>
+Also set a breakpoint on the call to test(), and reload. It should break before the test() function is called.