Bug 12983: Web Inspector break on the debugger keyword
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jun 2008 22:48:52 +0000 (22:48 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jun 2008 22:48:52 +0000 (22:48 +0000)
<https://bugs.webkit.org/show_bug.cgi?id=12983>

Reviewed by Tim

Added a DebuggerStatementNode to handle codegen, and added a new
DidReachBreakPoint debug event (which will hopefully be useful
if we ever move breakpoint management into JSC proper).  Also
added didReachBreakpoint to Debugger to allow us to actually respond
to this event.

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

15 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/VM/CodeBlock.cpp
JavaScriptCore/VM/Machine.cpp
JavaScriptCore/VM/Machine.h
JavaScriptCore/kjs/debugger.h
JavaScriptCore/kjs/grammar.y
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/nodes.h
JavaScriptCore/kjs/nodes2string.cpp
WebCore/ChangeLog
WebCore/page/JavaScriptDebugServer.cpp
WebCore/page/JavaScriptDebugServer.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebScriptDebugger.h
WebKit/mac/WebView/WebScriptDebugger.mm

index 83020e9b2108827067116252091d7ef8d8040463..4ac61a4ec12cb9e9add235f6ebbe9608ddb07742 100644 (file)
@@ -1,3 +1,32 @@
+2008-06-03  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Tim.
+
+        Bug 12983: Web Inspector break on the debugger keyword
+        <https://bugs.webkit.org/show_bug.cgi?id=12983>
+
+        Added a DebuggerStatementNode to handle codegen, and added a new
+        DidReachBreakPoint debug event (which will hopefully be useful
+        if we ever move breakpoint management into JSC proper).  Also
+        added didReachBreakpoint to Debugger to allow us to actually respond
+        to this event.
+
+        * VM/CodeBlock.cpp:
+        (KJS::debugHookName):
+        * VM/Machine.cpp:
+        (KJS::Machine::debug):
+        * VM/Machine.h:
+        (KJS::):
+        * kjs/debugger.h:
+        * kjs/grammar.y:
+        * kjs/nodes.cpp:
+        (KJS::DebuggerStatementNode::emitCode):
+        (KJS::DebuggerStatementNode::execute):
+        * kjs/nodes.h:
+        (KJS::DebuggerStatementNode::):
+        * kjs/nodes2string.cpp:
+        (KJS::DebuggerStatementNode::streamTo):
+
 2008-06-03  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Oliver.
index 28c2661e4d59dfb9f0a80214a9e3600232954c67..45a49ce741028ee3f6635c7bb6d823127aeb3adb 100644 (file)
@@ -108,6 +108,8 @@ NEVER_INLINE static const char* debugHookName(int debugHookID)
         return "willExecuteProgram";
     case DidExecuteProgram:
         return "didExecuteProgram";
+    case DidReachBreakpoint:
+        return "didReachBreakpoint";
     }
     
     ASSERT_NOT_REACHED();
index e7cc55f4de8a9f79a0fc6e3e756fc2259180d4e5..ff4cf1bab5e84a0b958517f7f740753d294d8494 100644 (file)
@@ -861,6 +861,10 @@ NEVER_INLINE void Machine::debug(ExecState* exec, const Instruction* vPC, const
         debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode->sourceId(), lastLine);
         return;
     }
+    case DidReachBreakpoint: {
+        debugger->didReachBreakpoint(debuggerCallFrame, codeBlock->ownerNode->sourceId(), lastLine);
+        return;
+    }
     }
 }
 
index 19adece19a82113b052bb70f297d87bc3b75711f..61bfdf9afd195c8baaa05a5b307ac20df9072e44 100644 (file)
@@ -50,6 +50,7 @@ namespace KJS {
         WillExecuteProgram,
         DidExecuteProgram,
         DidEnterCallFrame,
+        DidReachBreakpoint,
         WillLeaveCallFrame,
         WillExecuteStatement
     };
index 1a8356f637ef5970d9e6aab92a7f663d7d24417c..d81c53c1b8c0a735f2340eb6d10732958549a115 100644 (file)
@@ -166,6 +166,7 @@ namespace KJS {
 
     virtual void willExecuteProgram(const DebuggerCallFrame&, int sourceId, int lineno) = 0;
     virtual void didExecuteProgram(const DebuggerCallFrame&, int sourceId, int lineno) = 0;
+    virtual void didReachBreakpoint(const DebuggerCallFrame&, int sourceId, int lineno) = 0;
 
   private:
     HashSet<JSGlobalObject*> m_globalObjects;
index 51bcc0335634e663e4243906753f31573cc1a462..55f4836983a8b5ecfaef1addcb0ee03c657fce54 100644 (file)
@@ -1020,9 +1020,9 @@ TryStatement:
 ;
 
 DebuggerStatement:
-    DEBUGGER ';'                        { $$ = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(), 0, 0, 0);
+    DEBUGGER ';'                        { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(), 0, 0, 0);
                                           DBG($$.m_node, @1, @2); }
-  | DEBUGGER error                      { $$ = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(), 0, 0, 0);
+  | DEBUGGER error                      { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(), 0, 0, 0);
                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
 ;
 
index 6bb34d95deb7c30a83e2ab7cf22689f2cd9c524d..d05b41e21f158587799e8fde7a5afe58ef4a92b3 100644 (file)
@@ -4844,6 +4844,19 @@ JSValue* EmptyStatementNode::execute(OldInterpreterExecState* exec)
     return exec->setNormalCompletion();
 }
 
+// ------------------------------ DebuggerStatementNode ---------------------------
+
+RegisterID* DebuggerStatementNode::emitCode(CodeGenerator& generator, RegisterID* dst)
+{
+    generator.emitDebugHook(DidReachBreakpoint, firstLine(), lastLine());
+    return dst;
+}
+
+JSValue* DebuggerStatementNode::execute(OldInterpreterExecState* exec)
+{
+    return exec->setNormalCompletion();
+}
+
 // ------------------------------ ExprStatementNode ----------------------------
 
 RegisterID* ExprStatementNode::emitCode(CodeGenerator& generator, RegisterID* dst)
index 7a07565a2e9497051d3c1fb05aa4b3388b68dcf5..3fa4e8f9973022a28ed37b6d01dc945d0b8b24b6 100644 (file)
@@ -2638,6 +2638,18 @@ namespace KJS {
         virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
         virtual bool isEmptyStatement() const KJS_FAST_CALL { return true; }
     };
+    
+    class DebuggerStatementNode : public StatementNode {
+    public:
+        DebuggerStatementNode() KJS_FAST_CALL
+        {
+        }
+        
+        virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
+
+        virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
+        virtual JSValue* execute(OldInterpreterExecState*) KJS_FAST_CALL;
+    };
 
     class ExprStatementNode : public StatementNode {
     public:
index 906822e71ee12fcfc75e6d4f98527a65eb8cec82..1b815e1dfbcaf0a06acc7b4d203e70596a055f8a 100644 (file)
@@ -820,6 +820,11 @@ void EmptyStatementNode::streamTo(SourceStream& s) const
     s << Endl << ';';
 }
 
+void DebuggerStatementNode::streamTo(SourceStream& s) const
+{
+    s << Endl << "debugger;";
+}
+
 void ExprStatementNode::streamTo(SourceStream& s) const
 {
     s << Endl << m_expr << ';';
index ce7f0d96883092ab4e783aa72556059ee67aedaa..4f73b3dacf46fb0e97c22ce955704454c170094b 100644 (file)
@@ -1,3 +1,18 @@
+2008-06-03  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Tim.
+
+        Bug 12983: Web Inspector break on the debugger keyword
+        <https://bugs.webkit.org/show_bug.cgi?id=12983>
+
+        Added support for the new debugger didReachBreakpoint 
+        callback so that WebInspector receives the debugger event
+        and breaks.
+
+        * page/JavaScriptDebugServer.cpp:
+        (WebCore::JavaScriptDebugServer::didReachBreakpoint):
+        * page/JavaScriptDebugServer.h:
+
 2008-06-03  Darin Adler  <darin@apple.com>
 
         Fix build with GCC.
index aa26ca1cc3697b4d62d09a60d3110717000e701a..7808722d9df3b4510d9fa055192bd741fa7ae19e 100644 (file)
@@ -499,4 +499,18 @@ void JavaScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerC
     m_currentCallFrame = m_currentCallFrame->caller();
 }
 
+void JavaScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame& debuggerCallFrame, int sourceID, int lineNumber)
+{
+    if (m_paused)
+        return;
+    
+    ASSERT(m_currentCallFrame);
+    if (!m_currentCallFrame)
+        return;
+
+    m_pauseOnNextStatement = true;
+    m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
+    pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
+}
+
 } // namespace WebCore
index 1515b6cc5d97307512d2770703a1847cd9b491c4..ac8edb79ff092720f481e1a89564fb8d13fbc102 100644 (file)
@@ -102,6 +102,7 @@ namespace WebCore {
         virtual void exception(const KJS::DebuggerCallFrame&, int sourceID, int lineNumber);
         virtual void willExecuteProgram(const KJS::DebuggerCallFrame&, int sourceId, int lineno);
         virtual void didExecuteProgram(const KJS::DebuggerCallFrame&, int sourceId, int lineno);
+        virtual void didReachBreakpoint(const KJS::DebuggerCallFrame&, int sourceId, int lineno);
 
         typedef HashMap<Page*, ListenerSet*> PageListenersMap;
         PageListenersMap m_pageListenersMap;
index ff891ec5aa1a3783bfca10907248c116d84c9285..a3069c89f1d253a14da9cca7afde779e676cf0d2 100644 (file)
@@ -1,3 +1,15 @@
+2008-06-03  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Tim.
+
+        Bug 12983: Web Inspector break on the debugger keyword
+        <https://bugs.webkit.org/show_bug.cgi?id=12983>
+
+        Add stubs to allow old webkit debugger interface to build.
+
+        * WebView/WebScriptDebugger.h:
+        * WebView/WebScriptDebugger.mm:
+
 2008-06-03  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin.
index 3e98582283497f4e05f5004d49cab3329b7a03f0..a080b2cfc643f60c13fe8415330dd2c20ca5a9d1 100644 (file)
@@ -58,6 +58,7 @@ public:
     virtual void exception(const KJS::DebuggerCallFrame&, int sourceID, int lineNumber);
     virtual void willExecuteProgram(const KJS::DebuggerCallFrame&, int sourceId, int lineno);
     virtual void didExecuteProgram(const KJS::DebuggerCallFrame&, int sourceId, int lineno);
+    virtual void didReachBreakpoint(const KJS::DebuggerCallFrame&, int sourceId, int lineno);
 
 private:
     bool m_callingDelegate;
index 28870e7a1746decb030eab63302d74f298c3158a..7ef3382102140b98d1ebce719a86e5984fb7a693 100644 (file)
@@ -188,3 +188,8 @@ void WebScriptDebugger::didExecuteProgram(const DebuggerCallFrame& debuggerCallF
 {
     [m_topCallFrame.get() _clearDebuggerCallFrame];
 }
+
+void WebScriptDebugger::didReachBreakpoint(const DebuggerCallFrame&, int, int)
+{
+    return;
+}