Changeset 130615 in webkit


Ignore:
Timestamp:
Oct 7, 2012, 9:37:59 PM (13 years ago)
Author:
commit-queue@webkit.org
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 <peter.wang@torchmobile.com.cn> 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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130613 r130615  
     12012-10-07  Peter Wang  <peter.wang@torchmobile.com.cn>
     2
     3        Web Inspector: The front-end should provide the position in original source file when set a breakpoint
     4        https://bugs.webkit.org/show_bug.cgi?id=93473
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Since frontend truncates the indent, the first statement in a line must match the breakpoint (line, 0).
     9        With this patch JSC debugger can support both normal and "Pretty Print" mode.
     10
     11        No new test case. This patch can be verified with cases in "LayoutTests/inspector/debugger/".
     12
     13        * bindings/js/ScriptDebugServer.cpp:
     14        (WebCore::ScriptDebugServer::ScriptDebugServer):
     15        (WebCore::ScriptDebugServer::hasBreakpoint):
     16        (WebCore::ScriptDebugServer::createCallFrameAndPauseIfNeeded):
     17        (WebCore::ScriptDebugServer::pauseIfNeeded):
     18        * bindings/js/ScriptDebugServer.h:
     19        (ScriptDebugServer):
     20
    1212012-10-07  Martin Robinson  <mrobinson@igalia.com>
    222
  • trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp

    r130612 r130615  
    6161    , m_pauseOnCallFrame(0)
    6262    , m_recompileTimer(this, &ScriptDebugServer::recompileAllJSFunctions)
     63    , m_lastExecutedLine(-1)
     64    , m_lastExecutedSourceId(-1)
    6365{
    6466}
     
    127129}
    128130
    129 void ScriptDebugServer::updateCurrentStatementPosition(intptr_t sourceID, int line)
    130 {
    131     if (line < 0)
    132         return;
    133 
    134     SourceProvider* source = reinterpret_cast<SourceProvider*>(sourceID);
    135 
    136     if (m_currentSourceID != sourceID) {
    137         const String& sourceCode = source->source();
    138         m_currentSourceCode.clear();
    139         sourceCode.split("\n", true, m_currentSourceCode);
    140         m_currentSourceID = sourceID;
    141         m_currentStatementPosition.lineNumber = 0;
    142         m_currentStatementPosition.columnNumber = 0;
    143     }
    144 
    145     if (line != m_currentStatementPosition.lineNumber) {
    146         m_currentStatementPosition.lineNumber = line;
    147         m_currentStatementPosition.columnNumber = 0;
    148         return;
    149     }
    150 
    151     int startLine = source->startPosition().m_line.zeroBasedInt();
    152     if ((m_currentStatementPosition.lineNumber - startLine - 1) >= static_cast<int>(m_currentSourceCode.size()))
    153         return;
    154     const String& codeInLine = m_currentSourceCode[m_currentStatementPosition.lineNumber - startLine - 1];
    155     if (codeInLine.isEmpty())
    156         return;
    157     int nextColumn = codeInLine.find(";", m_currentStatementPosition.columnNumber);
    158     if (nextColumn != -1) {
    159         UChar c = codeInLine[nextColumn + 1];
    160         if (c == ' ' || c == '\t')
    161             nextColumn += 1;
    162         m_currentStatementPosition.columnNumber = nextColumn + 1;
    163     } else
    164         m_currentStatementPosition.columnNumber = 0;
    165 }
    166 
    167131bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, const TextPosition& position) const
    168132{
     
    189153    for (i = 0; i < breaksCount; i++) {
    190154        int breakLine = breaksVector.at(i).lineNumber;
    191         if (lineNumber == breakLine) {
     155        int breakColumn = breaksVector.at(i).columnNumber;
     156        // Since frontend truncates the indent, the first statement in a line must match the breakpoint (line,0).
     157        if ((lineNumber != m_lastExecutedLine && lineNumber == breakLine && !breakColumn)
     158            || (lineNumber == breakLine && columnNumber == breakColumn)) {
    192159            hit = true;
    193160            break;
     
    434401    TextPosition textPosition(OrdinalNumber::fromOneBasedInt(lineNumber), OrdinalNumber::fromZeroBasedInt(columnNumber));
    435402    m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition);
     403    if (m_lastExecutedSourceId != sourceID) {
     404        m_lastExecutedLine = -1;
     405        m_lastExecutedSourceId = sourceID;
     406    }
    436407    pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject());
    437408}
     
    459430    pauseNow |= (m_pauseOnCallFrame == m_currentCallFrame);
    460431    pauseNow |= hasBreakpoint(m_currentCallFrame->sourceID(), m_currentCallFrame->position());
     432    m_lastExecutedLine = m_currentCallFrame->position().m_line.zeroBasedInt();
    461433    if (!pauseNow)
    462434        return;
  • trunk/Source/WebCore/bindings/js/ScriptDebugServer.h

    r128572 r130615  
    138138    virtual void didReachBreakpoint(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int columnNumber);
    139139
    140 
    141     void updateCurrentStatementPosition(intptr_t, int);
    142 
    143140    typedef Vector<ScriptBreakpoint> BreakpointsInLine;
    144141    typedef HashMap<long, BreakpointsInLine> LineToBreakpointMap;
     
    156153    Timer<ScriptDebugServer> m_recompileTimer;
    157154
    158     Vector<String> m_currentSourceCode;
    159     intptr_t m_currentSourceID;
    160     ScriptBreakpoint m_currentStatementPosition;
     155    int m_lastExecutedLine;
     156    intptr_t m_lastExecutedSourceId;
    161157};
    162158
Note: See TracChangeset for help on using the changeset viewer.