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 83020e9..4ac61a4 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 28c2661..45a49ce 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 e7cc55f..ff4cf1b 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 19adece..61bfdf9 100644 (file)
@@ -50,6 +50,7 @@ namespace KJS {
         WillExecuteProgram,
         DidExecuteProgram,
         DidEnterCallFrame,
+        DidReachBreakpoint,
         WillLeaveCallFrame,
         WillExecuteStatement
     };
index 1a8356f..d81c53c 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 51bcc03..55f4836 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 6bb34d9..d05b41e 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 7a07565..3fa4e8f 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 906822e..1b815e1 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 ce7f0d9..4f73b3d 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 aa26ca1..7808722 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 1515b6c..ac8edb7 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 ff891ec..a3069c8 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 3e98582..a080b2c 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 28870e7..7ef3382 100644 (file)
@@ -188,3 +188,8 @@ void WebScriptDebugger::didExecuteProgram(const DebuggerCallFrame& debuggerCallF
 {
     [m_topCallFrame.get() _clearDebuggerCallFrame];
 }
+
+void WebScriptDebugger::didReachBreakpoint(const DebuggerCallFrame&, int, int)
+{
+    return;
+}