aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4function.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-11-14 14:16:50 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-14 14:43:38 +0100
commitf0349e789a984de7646865b07c125a63406516bd (patch)
tree5985a6b19c14b72829dac4068d1c499a77478b4c /src/qml/jsruntime/qv4function.cpp
parent0ca8351e261055984f82b28bd65e4e15c9820e73 (diff)
V4 debugging: fix step-over and step-out.
- step-out: only stop if we’re leaving the context for the function we previously stopped at, so intermediate calls between the current position and the end do not stop the engine - step-over: set breakpoints on all lines in current function and continue to run. When hitting a breakpoint, see if we are in the same context, because recursive calls might happen. Breakpoints on all lines are needed, because the (pure) next line might be jumped over (like when doing step-over a single-line then clause, where the next line might be in the else clause). Change-Id: Idf35dc740ca64fae5079162162906490a96af2a7 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
-rw-r--r--src/qml/jsruntime/qv4function.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index b96fdb1fe5..ebe214ad72 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -147,19 +147,22 @@ int Function::lineNumberForProgramCounter(qptrdiff offset) const
return helper.table[pos * 2 + 1];
}
-qptrdiff Function::programCounterForLine(quint32 line) const
+QList<qptrdiff> Function::programCountersForAllLines() const
{
- // Access the second field, the line number
- LineNumberMappingHelper<1, quint32> helper;
- helper.table = compiledFunction->lineNumberMapping();
- const int count = static_cast<int>(compiledFunction->nLineNumberMappingEntries);
+ // Only store 1 breakpoint per line...
+ QHash<quint32, qptrdiff> offsetsPerLine;
+ const quint32 *mapping = compiledFunction->lineNumberMapping();
+
+ // ... and make it the first instruction by walking backwards over the line mapping table
+ // and inserting all entries keyed on line.
+ for (quint32 i = compiledFunction->nLineNumberMappingEntries; i > 0; ) {
+ --i; // the loop is written this way, because starting at endIndex-1 and checking for i>=0 will never end: i>=0 is always true for unsigned.
+ quint32 offset = mapping[i * 2];
+ quint32 line = mapping[i * 2 + 1];
+ offsetsPerLine.insert(line, offset);
+ }
- int pos = helper.upperBound(0, count, line);
- if (pos != 0 && count > 0)
- --pos;
- if (pos == count)
- return -1;
- return helper.table[pos * 2];
+ return offsetsPerLine.values();
}
QT_END_NAMESPACE