Title: [130615] trunk/Source/WebCore
Revision
130615
Author
[email protected]
Date
2012-10-07 21:37:59 -0700 (Sun, 07 Oct 2012)

Log Message

Web Inspector: The front-end should provide the position in original source file when set a breakpoint
https://bugs.webkit.org/show_bug.cgi?id=93473

Patch by Peter Wang <[email protected]> on 2012-10-07
Reviewed by Yury Semikhatsky.

Since frontend truncates the indent, the first statement in a line must match the breakpoint (line, 0).
With this patch JSC debugger can support both normal and "Pretty Print" mode.

No new test case. This patch can be verified with cases in "LayoutTests/inspector/debugger/".

* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::ScriptDebugServer):
(WebCore::ScriptDebugServer::hasBreakpoint):
(WebCore::ScriptDebugServer::createCallFrameAndPauseIfNeeded):
(WebCore::ScriptDebugServer::pauseIfNeeded):
* bindings/js/ScriptDebugServer.h:
(ScriptDebugServer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (130614 => 130615)


--- trunk/Source/WebCore/ChangeLog	2012-10-08 03:29:37 UTC (rev 130614)
+++ trunk/Source/WebCore/ChangeLog	2012-10-08 04:37:59 UTC (rev 130615)
@@ -1,3 +1,23 @@
+2012-10-07  Peter Wang  <[email protected]>
+
+        Web Inspector: The front-end should provide the position in original source file when set a breakpoint
+        https://bugs.webkit.org/show_bug.cgi?id=93473
+
+        Reviewed by Yury Semikhatsky.
+
+        Since frontend truncates the indent, the first statement in a line must match the breakpoint (line, 0).
+        With this patch JSC debugger can support both normal and "Pretty Print" mode.
+
+        No new test case. This patch can be verified with cases in "LayoutTests/inspector/debugger/".
+
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::ScriptDebugServer):
+        (WebCore::ScriptDebugServer::hasBreakpoint):
+        (WebCore::ScriptDebugServer::createCallFrameAndPauseIfNeeded):
+        (WebCore::ScriptDebugServer::pauseIfNeeded):
+        * bindings/js/ScriptDebugServer.h:
+        (ScriptDebugServer):
+
 2012-10-07  Martin Robinson  <[email protected]>
 
         [Soup] Clean up ResourceError creation

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp (130614 => 130615)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-10-08 03:29:37 UTC (rev 130614)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-10-08 04:37:59 UTC (rev 130615)
@@ -60,6 +60,8 @@
     , m_breakpointsActivated(true)
     , m_pauseOnCallFrame(0)
     , m_recompileTimer(this, &ScriptDebugServer::recompileAllJSFunctions)
+    , m_lastExecutedLine(-1)
+    , m_lastExecutedSourceId(-1)
 {
 }
 
@@ -126,44 +128,6 @@
     }
 }
 
-void ScriptDebugServer::updateCurrentStatementPosition(intptr_t sourceID, int line)
-{
-    if (line < 0)
-        return;
-
-    SourceProvider* source = reinterpret_cast<SourceProvider*>(sourceID);
-
-    if (m_currentSourceID != sourceID) {
-        const String& sourceCode = source->source();
-        m_currentSourceCode.clear();
-        sourceCode.split("\n", true, m_currentSourceCode);
-        m_currentSourceID = sourceID;
-        m_currentStatementPosition.lineNumber = 0;
-        m_currentStatementPosition.columnNumber = 0;
-    }
-
-    if (line != m_currentStatementPosition.lineNumber) {
-        m_currentStatementPosition.lineNumber = line;
-        m_currentStatementPosition.columnNumber = 0;
-        return;
-    }
-
-    int startLine = source->startPosition().m_line.zeroBasedInt();
-    if ((m_currentStatementPosition.lineNumber - startLine - 1) >= static_cast<int>(m_currentSourceCode.size()))
-        return;
-    const String& codeInLine = m_currentSourceCode[m_currentStatementPosition.lineNumber - startLine - 1];
-    if (codeInLine.isEmpty())
-        return;
-    int nextColumn = codeInLine.find(";", m_currentStatementPosition.columnNumber);
-    if (nextColumn != -1) {
-        UChar c = codeInLine[nextColumn + 1];
-        if (c == ' ' || c == '\t')
-            nextColumn += 1;
-        m_currentStatementPosition.columnNumber = nextColumn + 1;
-    } else
-        m_currentStatementPosition.columnNumber = 0;
-}
-
 bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, const TextPosition& position) const
 {
     if (!m_breakpointsActivated)
@@ -188,7 +152,10 @@
     unsigned i;
     for (i = 0; i < breaksCount; i++) {
         int breakLine = breaksVector.at(i).lineNumber;
-        if (lineNumber == breakLine) {
+        int breakColumn = breaksVector.at(i).columnNumber;
+        // Since frontend truncates the indent, the first statement in a line must match the breakpoint (line,0).
+        if ((lineNumber != m_lastExecutedLine && lineNumber == breakLine && !breakColumn)
+            || (lineNumber == breakLine && columnNumber == breakColumn)) {
             hit = true;
             break;
         }
@@ -433,6 +400,10 @@
 {
     TextPosition textPosition(OrdinalNumber::fromOneBasedInt(lineNumber), OrdinalNumber::fromZeroBasedInt(columnNumber));
     m_currentCallFrame = _javascript_CallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition);
+    if (m_lastExecutedSourceId != sourceID) {
+        m_lastExecutedLine = -1;
+        m_lastExecutedSourceId = sourceID;
+    }
     pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject());
 }
 
@@ -458,6 +429,7 @@
     bool pauseNow = m_pauseOnNextStatement;
     pauseNow |= (m_pauseOnCallFrame == m_currentCallFrame);
     pauseNow |= hasBreakpoint(m_currentCallFrame->sourceID(), m_currentCallFrame->position());
+    m_lastExecutedLine = m_currentCallFrame->position().m_line.zeroBasedInt();
     if (!pauseNow)
         return;
 

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.h (130614 => 130615)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.h	2012-10-08 03:29:37 UTC (rev 130614)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.h	2012-10-08 04:37:59 UTC (rev 130615)
@@ -137,9 +137,6 @@
     virtual void didExecuteProgram(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int columnNumber);
     virtual void didReachBreakpoint(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int columnNumber);
 
-
-    void updateCurrentStatementPosition(intptr_t, int);
-
     typedef Vector<ScriptBreakpoint> BreakpointsInLine;
     typedef HashMap<long, BreakpointsInLine> LineToBreakpointMap;
     typedef HashMap<intptr_t, LineToBreakpointMap> SourceIdToBreakpointsMap;
@@ -155,9 +152,8 @@
     SourceIdToBreakpointsMap m_sourceIdToBreakpoints;
     Timer<ScriptDebugServer> m_recompileTimer;
 
-    Vector<String> m_currentSourceCode;
-    intptr_t m_currentSourceID;
-    ScriptBreakpoint m_currentStatementPosition;
+    int m_lastExecutedLine;
+    intptr_t m_lastExecutedSourceId;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to