Commit 641716be authored by Aurindam Jana's avatar Aurindam Jana

QmlDebugging: Implement RunToLine capability

Change-Id: I153c30310ac318d2de8b9a96c6d1e7f80439d306
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent bcd9bbb6
......@@ -34,6 +34,7 @@
#define QMLDEBUGGERCLIENT_H
#include "qmljsprivateapi.h"
#include "debuggerengine.h"
namespace Debugger {
namespace Internal {
......@@ -60,6 +61,8 @@ public:
virtual void executeNext() = 0;
virtual void executeStepI() = 0;
virtual void executeRunToLine(const ContextData &data) = 0;
virtual void continueInferior() = 0;
virtual void interruptInferior() = 0;
......
......@@ -530,8 +530,13 @@ void QmlEngine::executeNextI()
void QmlEngine::executeRunToLine(const ContextData &data)
{
Q_UNUSED(data)
SDEBUG("FIXME: QmlEngine::executeRunToLine()");
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
showStatusMessage(tr("Run to line %1 (%2) requested...").arg(data.lineNumber).arg(data.fileName), 5000);
resetLocation();
if (d->m_adapter.activeDebuggerClient())
d->m_adapter.activeDebuggerClient()->executeRunToLine(data);
notifyInferiorRunRequested();
notifyInferiorRunOk();
}
void QmlEngine::executeRunToFunction(const QString &functionName)
......@@ -777,7 +782,9 @@ void QmlEngine::synchronizeWatchers()
unsigned QmlEngine::debuggerCapabilities() const
{
return AddWatcherCapability|AddWatcherWhileRunningCapability;
return AddWatcherCapability
| AddWatcherWhileRunningCapability
| RunToLineCapability;
/*ReverseSteppingCapability | SnapshotCapability
| AutoDerefPointersCapability | DisassemblerCapability
| RegisterCapability | ShowMemoryCapability
......
......@@ -138,6 +138,7 @@ public:
QmlEngine *engine;
QHash<BreakpointModelId, int> breakpoints;
QHash<int, BreakpointModelId> breakpointsSync;
QList<int> breakpointsTemp;
QScriptValue parser;
QScriptValue stringifier;
......@@ -1019,6 +1020,19 @@ void QmlV8DebuggerClient::executeStepI()
d->continueDebugging(In);
}
void QmlV8DebuggerClient::executeRunToLine(const ContextData &data)
{
if (d->isOldService) {
d->setBreakpoint(QString(_(SCRIPT)), QFileInfo(data.fileName).fileName(),
data.lineNumber - 1);
} else {
d->setBreakpoint(QString(_(SCRIPTREGEXP)), QFileInfo(data.fileName).fileName(),
data.lineNumber - 1);
}
clearExceptionSelection();
d->continueDebugging(Continue);
}
void QmlV8DebuggerClient::continueInferior()
{
clearExceptionSelection();
......@@ -1282,11 +1296,16 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
const QVariantMap breakpointData = resp.value(_(BODY)).toMap();
int index = breakpointData.value(_("breakpoint")).toInt();
BreakpointModelId id = d->breakpointsSync.take(seq);
d->breakpoints.insert(id, index);
if (d->breakpointsSync.contains(seq)) {
BreakpointModelId id = d->breakpointsSync.take(seq);
d->breakpoints.insert(id, index);
if (d->engine->breakHandler()->state(id) != BreakpointInserted)
d->engine->breakHandler()->notifyBreakpointInsertOk(id);
if (d->engine->breakHandler()->state(id) != BreakpointInserted)
d->engine->breakHandler()->notifyBreakpointInsertOk(id);
} else {
d->breakpointsTemp.append(index);
}
} else if (debugCommand == _(CHANGEBREAKPOINT)) {
......@@ -1447,6 +1466,10 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
}
if (d->engine->state() == InferiorRunOk) {
foreach (const QVariant &breakpointId, v8BreakpointIds) {
if (d->breakpointsTemp.contains(breakpointId.toInt()))
d->clearBreakpoint(breakpointId.toInt());
}
d->engine->inferiorSpontaneousStop();
d->backtrace();
} else if (d->engine->state() == InferiorStopOk) {
......
......@@ -73,6 +73,8 @@ public:
void executeNext();
void executeStepI();
void executeRunToLine(const ContextData &data);
void continueInferior();
void interruptInferior();
......
......@@ -183,6 +183,17 @@ void QScriptDebuggerClient::executeStepI()
sendMessage(reply);
}
void QScriptDebuggerClient::executeRunToLine(const ContextData &data)
{
JSAgentBreakpointData bp;
bp.fileUrl = QUrl::fromLocalFile(data.fileName).toString().toUtf8();
bp.lineNumber = data.lineNumber;
bp.functionName = "TEMPORARY";
d->breakpoints.insert(bp);
synchronizeBreakpoints();
continueInferior();
}
void QScriptDebuggerClient::continueInferior()
{
QByteArray reply;
......@@ -398,6 +409,7 @@ void QScriptDebuggerClient::messageReceived(const QByteArray &data)
if (ideStackFrames.size() && ideStackFrames.back().function == QLatin1String("<global>"))
ideStackFrames.takeLast();
d->engine->stackHandler()->setFrames(ideStackFrames);
d->engine->watchHandler()->beginCycle();
......@@ -478,6 +490,18 @@ void QScriptDebuggerClient::messageReceived(const QByteArray &data)
}
}
QList<JSAgentBreakpointData> breakpoints(d->breakpoints.toList());
foreach (const JSAgentBreakpointData &data, breakpoints) {
if (data.fileUrl == QUrl::fromLocalFile(file).toString().toUtf8() &&
data.lineNumber == line &&
data.functionName == "TEMPORARY") {
breakpoints.removeOne(data);
d->breakpoints = JSAgentBreakpoints::fromList(breakpoints);
synchronizeBreakpoints();
break;
}
}
d->logReceiveMessage(logString);
}
......
......@@ -59,6 +59,8 @@ public:
void executeNext();
void executeStepI();
void executeRunToLine(const ContextData &data);
void continueInferior();
void interruptInferior();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment