Changeset 130615 in webkit
- Timestamp:
- Oct 7, 2012, 9:37:59 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r130613 r130615 1 2012-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 1 21 2012-10-07 Martin Robinson <mrobinson@igalia.com> 2 22 -
trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp
r130612 r130615 61 61 , m_pauseOnCallFrame(0) 62 62 , m_recompileTimer(this, &ScriptDebugServer::recompileAllJSFunctions) 63 , m_lastExecutedLine(-1) 64 , m_lastExecutedSourceId(-1) 63 65 { 64 66 } … … 127 129 } 128 130 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 } else164 m_currentStatementPosition.columnNumber = 0;165 }166 167 131 bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, const TextPosition& position) const 168 132 { … … 189 153 for (i = 0; i < breaksCount; i++) { 190 154 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)) { 192 159 hit = true; 193 160 break; … … 434 401 TextPosition textPosition(OrdinalNumber::fromOneBasedInt(lineNumber), OrdinalNumber::fromZeroBasedInt(columnNumber)); 435 402 m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition); 403 if (m_lastExecutedSourceId != sourceID) { 404 m_lastExecutedLine = -1; 405 m_lastExecutedSourceId = sourceID; 406 } 436 407 pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject()); 437 408 } … … 459 430 pauseNow |= (m_pauseOnCallFrame == m_currentCallFrame); 460 431 pauseNow |= hasBreakpoint(m_currentCallFrame->sourceID(), m_currentCallFrame->position()); 432 m_lastExecutedLine = m_currentCallFrame->position().m_line.zeroBasedInt(); 461 433 if (!pauseNow) 462 434 return; -
trunk/Source/WebCore/bindings/js/ScriptDebugServer.h
r128572 r130615 138 138 virtual void didReachBreakpoint(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int columnNumber); 139 139 140 141 void updateCurrentStatementPosition(intptr_t, int);142 143 140 typedef Vector<ScriptBreakpoint> BreakpointsInLine; 144 141 typedef HashMap<long, BreakpointsInLine> LineToBreakpointMap; … … 156 153 Timer<ScriptDebugServer> m_recompileTimer; 157 154 158 Vector<String> m_currentSourceCode; 159 intptr_t m_currentSourceID; 160 ScriptBreakpoint m_currentStatementPosition; 155 int m_lastExecutedLine; 156 intptr_t m_lastExecutedSourceId; 161 157 }; 162 158
Note:
See TracChangeset
for help on using the changeset viewer.