forked from qt-creator/qt-creator
Changed the behaviour of setting breakpoints in qml files.
Delegates setting of breakpoints to functions that set/reset/change the breakpoint one at a time. Change-Id: I553a74b05cf19c9d2436344db67bc962da18457f Reviewed-on: http://codereview.qt.nokia.com/3082 Reviewed-by: Kai Koehne <kai.koehne@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
This commit is contained in:
@@ -62,9 +62,10 @@ public:
|
|||||||
|
|
||||||
virtual void activateFrame(int index) = 0;
|
virtual void activateFrame(int index) = 0;
|
||||||
|
|
||||||
virtual void insertBreakpoints(BreakHandler *handler, BreakpointModelId *id) = 0;
|
virtual void insertBreakpoint(BreakpointModelId id, BreakHandler *handler) = 0;
|
||||||
virtual void removeBreakpoints(BreakpointModelId *id) = 0;
|
virtual void removeBreakpoint(BreakpointModelId id, BreakHandler *handler) = 0;
|
||||||
virtual void setBreakpoints() = 0;
|
virtual void changeBreakpoint(BreakpointModelId id, BreakHandler *handler) = 0;
|
||||||
|
virtual void updateBreakpoints() = 0;
|
||||||
|
|
||||||
virtual void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
virtual void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||||
const QString &property, const QString value) = 0;
|
const QString &property, const QString value) = 0;
|
||||||
@@ -75,7 +76,6 @@ public:
|
|||||||
virtual void synchronizeWatchers(const QStringList &watchers) = 0;
|
virtual void synchronizeWatchers(const QStringList &watchers) = 0;
|
||||||
|
|
||||||
virtual void expandObject(const QByteArray &iname, quint64 objectId) = 0;
|
virtual void expandObject(const QByteArray &iname, quint64 objectId) = 0;
|
||||||
virtual void sendPing() = 0;
|
|
||||||
|
|
||||||
virtual void setEngine(QmlEngine *engine) = 0;
|
virtual void setEngine(QmlEngine *engine) = 0;
|
||||||
|
|
||||||
|
@@ -491,8 +491,73 @@ void QmlEngine::selectThread(int index)
|
|||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlEngine::insertBreakpoint(BreakpointModelId id)
|
||||||
|
{
|
||||||
|
BreakHandler *handler = breakHandler();
|
||||||
|
BreakpointState state = handler->state(id);
|
||||||
|
QTC_ASSERT(state == BreakpointInsertRequested, qDebug() << id << this << state);
|
||||||
|
handler->notifyBreakpointInsertProceeding(id);
|
||||||
|
|
||||||
|
if (d->m_adapter.activeDebuggerClient()) {
|
||||||
|
d->m_adapter.activeDebuggerClient()->insertBreakpoint(id,handler);
|
||||||
|
} else {
|
||||||
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||||
|
client->insertBreakpoint(id,handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler->state(id) == BreakpointInsertProceeding) {
|
||||||
|
handler->notifyBreakpointInsertOk(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlEngine::removeBreakpoint(BreakpointModelId id)
|
||||||
|
{
|
||||||
|
BreakHandler *handler = breakHandler();
|
||||||
|
BreakpointState state = handler->state(id);
|
||||||
|
QTC_ASSERT(state == BreakpointRemoveRequested, qDebug() << id << this << state);
|
||||||
|
handler->notifyBreakpointRemoveProceeding(id);
|
||||||
|
|
||||||
|
if (d->m_adapter.activeDebuggerClient()) {
|
||||||
|
d->m_adapter.activeDebuggerClient()->removeBreakpoint(id,handler);
|
||||||
|
} else {
|
||||||
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||||
|
client->removeBreakpoint(id,handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler->state(id) == BreakpointRemoveProceeding) {
|
||||||
|
handler->notifyBreakpointRemoveOk(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlEngine::changeBreakpoint(BreakpointModelId id)
|
||||||
|
{
|
||||||
|
BreakHandler *handler = breakHandler();
|
||||||
|
BreakpointState state = handler->state(id);
|
||||||
|
QTC_ASSERT(state == BreakpointChangeRequested, qDebug() << id << this << state);
|
||||||
|
handler->notifyBreakpointChangeProceeding(id);
|
||||||
|
|
||||||
|
if (d->m_adapter.activeDebuggerClient()) {
|
||||||
|
d->m_adapter.activeDebuggerClient()->changeBreakpoint(id,handler);
|
||||||
|
} else {
|
||||||
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||||
|
client->changeBreakpoint(id,handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler->state(id) == BreakpointChangeProceeding) {
|
||||||
|
handler->notifyBreakpointChangeOk(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QmlEngine::attemptBreakpointSynchronization()
|
void QmlEngine::attemptBreakpointSynchronization()
|
||||||
{
|
{
|
||||||
|
if (!stateAcceptsBreakpointChanges()) {
|
||||||
|
showMessage(_("BREAKPOINT SYNCHRONIZATION NOT POSSIBLE IN CURRENT STATE"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BreakHandler *handler = breakHandler();
|
BreakHandler *handler = breakHandler();
|
||||||
|
|
||||||
foreach (BreakpointModelId id, handler->unclaimedBreakpointIds()) {
|
foreach (BreakpointModelId id, handler->unclaimedBreakpointIds()) {
|
||||||
@@ -501,45 +566,39 @@ void QmlEngine::attemptBreakpointSynchronization()
|
|||||||
handler->setEngine(id, this);
|
handler->setEngine(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList breakPointsStr;
|
|
||||||
foreach (BreakpointModelId id, handler->engineBreakpointIds(this)) {
|
foreach (BreakpointModelId id, handler->engineBreakpointIds(this)) {
|
||||||
if (handler->state(id) == BreakpointRemoveRequested) {
|
switch (handler->state(id)) {
|
||||||
handler->notifyBreakpointRemoveProceeding(id);
|
case BreakpointNew:
|
||||||
if (d->m_adapter.activeDebuggerClient())
|
// Should not happen once claimed.
|
||||||
d->m_adapter.activeDebuggerClient()->removeBreakpoints(&id);
|
QTC_CHECK(false);
|
||||||
else {
|
continue;
|
||||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
case BreakpointInsertRequested:
|
||||||
client->removeBreakpoints(&id);
|
insertBreakpoint(id);
|
||||||
}
|
continue;
|
||||||
}
|
case BreakpointChangeRequested:
|
||||||
handler->notifyBreakpointRemoveOk(id);
|
changeBreakpoint(id);
|
||||||
} else {
|
continue;
|
||||||
if (handler->state(id) == BreakpointInsertRequested) {
|
case BreakpointRemoveRequested:
|
||||||
handler->notifyBreakpointInsertProceeding(id);
|
removeBreakpoint(id);
|
||||||
}
|
continue;
|
||||||
if (d->m_adapter.activeDebuggerClient())
|
case BreakpointChangeProceeding:
|
||||||
d->m_adapter.activeDebuggerClient()->insertBreakpoints(handler,&id);
|
case BreakpointInsertProceeding:
|
||||||
else {
|
case BreakpointRemoveProceeding:
|
||||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
case BreakpointInserted:
|
||||||
client->insertBreakpoints(handler,&id);
|
case BreakpointDead:
|
||||||
}
|
continue;
|
||||||
}
|
|
||||||
if (handler->state(id) == BreakpointInsertProceeding) {
|
|
||||||
handler->notifyBreakpointInsertOk(id);
|
|
||||||
}
|
|
||||||
breakPointsStr << QString("('%1' '%2' %3)").arg(QString(handler->functionName(id).toUtf8()),
|
|
||||||
QString(QUrl::fromLocalFile(handler->fileName(id)).toString().toUtf8()), QString::number(handler->lineNumber(id)));
|
|
||||||
}
|
}
|
||||||
|
QTC_ASSERT(false, qDebug() << "UNKNOWN STATE" << id << state());
|
||||||
}
|
}
|
||||||
|
|
||||||
logMessage(LogSend, QString("%1 [%2]").arg(QString("BREAKPOINTS"), breakPointsStr.join(", ")));
|
DebuggerEngine::attemptBreakpointSynchronization();
|
||||||
|
|
||||||
if (d->m_adapter.activeDebuggerClient()) {
|
if (d->m_adapter.activeDebuggerClient()) {
|
||||||
d->m_adapter.activeDebuggerClient()->setBreakpoints();
|
d->m_adapter.activeDebuggerClient()->updateBreakpoints();
|
||||||
}
|
} else {
|
||||||
else {
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients())
|
client->updateBreakpoints();
|
||||||
client->setBreakpoints();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,8 +690,7 @@ void QmlEngine::synchronizeWatchers()
|
|||||||
QString("WATCH_EXPRESSIONS"), watchedExpressions.join(", ")));
|
QString("WATCH_EXPRESSIONS"), watchedExpressions.join(", ")));
|
||||||
if (d->m_adapter.activeDebuggerClient()) {
|
if (d->m_adapter.activeDebuggerClient()) {
|
||||||
d->m_adapter.activeDebuggerClient()->synchronizeWatchers(watchedExpressions);
|
d->m_adapter.activeDebuggerClient()->synchronizeWatchers(watchedExpressions);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients())
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients())
|
||||||
client->synchronizeWatchers(watchedExpressions);
|
client->synchronizeWatchers(watchedExpressions);
|
||||||
}
|
}
|
||||||
|
@@ -107,6 +107,9 @@ private:
|
|||||||
void selectThread(int index);
|
void selectThread(int index);
|
||||||
|
|
||||||
void attemptBreakpointSynchronization();
|
void attemptBreakpointSynchronization();
|
||||||
|
void insertBreakpoint(BreakpointModelId id);
|
||||||
|
void removeBreakpoint(BreakpointModelId id);
|
||||||
|
void changeBreakpoint(BreakpointModelId id);
|
||||||
bool acceptsBreakpoint(BreakpointModelId id) const;
|
bool acceptsBreakpoint(BreakpointModelId id) const;
|
||||||
|
|
||||||
void assignValueInDebugger(const WatchData *data,
|
void assignValueInDebugger(const WatchData *data,
|
||||||
|
@@ -197,33 +197,32 @@ void QmlV8DebuggerClient::activateFrame(int index)
|
|||||||
setLocals(index);
|
setLocals(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlV8DebuggerClient::insertBreakpoints(BreakHandler *handler, BreakpointModelId *id)
|
void QmlV8DebuggerClient::insertBreakpoint(BreakpointModelId id, BreakHandler *handler)
|
||||||
{
|
{
|
||||||
QByteArray request;
|
QByteArray request;
|
||||||
|
|
||||||
JsonInputStream(request) << '{' << INITIALPARAMS ;
|
JsonInputStream(request) << '{' << INITIALPARAMS ;
|
||||||
JsonInputStream(request) << ',' << "command" << ':' << "setbreakpoint";
|
JsonInputStream(request) << ',' << "command" << ':' << "setbreakpoint";
|
||||||
JsonInputStream(request) << ',' << "arguments" << ':' << '{';
|
JsonInputStream(request) << ',' << "arguments" << ':' << '{';
|
||||||
if (handler->breakpointData(*id).type == BreakpointByFileAndLine) {
|
if (handler->breakpointData(id).type == BreakpointByFileAndLine) {
|
||||||
JsonInputStream(request) << "type" << ':' << "script";
|
JsonInputStream(request) << "type" << ':' << "script";
|
||||||
JsonInputStream(request) << ',' << "target" << ':' << QFileInfo(handler->fileName(*id)).fileName().toUtf8();
|
JsonInputStream(request) << ',' << "target" << ':' << QFileInfo(handler->fileName(id)).fileName().toUtf8();
|
||||||
JsonInputStream(request) << ',' << "line" << ':' << handler->lineNumber(*id) - 1;
|
JsonInputStream(request) << ',' << "line" << ':' << handler->lineNumber(id) - 1;
|
||||||
} else if (handler->breakpointData(*id).type == BreakpointByFunction) {
|
} else if (handler->breakpointData(id).type == BreakpointByFunction) {
|
||||||
JsonInputStream(request) << "type" << ':' << "function";
|
JsonInputStream(request) << "type" << ':' << "function";
|
||||||
JsonInputStream(request) << ',' << "target" << ':' << handler->functionName(*id).toUtf8();
|
JsonInputStream(request) << ',' << "target" << ':' << handler->functionName(id).toUtf8();
|
||||||
}
|
}
|
||||||
JsonInputStream(request) << '}';
|
JsonInputStream(request) << '}';
|
||||||
JsonInputStream(request) << '}';
|
JsonInputStream(request) << '}';
|
||||||
|
|
||||||
d->breakpointsSync.insert(d->sequence,*id);
|
d->breakpointsSync.insert(d->sequence,id);
|
||||||
sendMessage(packMessage(request));
|
sendMessage(packMessage(request));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlV8DebuggerClient::removeBreakpoints(BreakpointModelId *id)
|
void QmlV8DebuggerClient::removeBreakpoint(BreakpointModelId id, BreakHandler * /*handler*/)
|
||||||
{
|
{
|
||||||
QList<int> breakpoints = d->breakpoints.values(*id);
|
QList<int> breakpoints = d->breakpoints.values(id);
|
||||||
d->breakpoints.remove(*id);
|
d->breakpoints.remove(id);
|
||||||
|
|
||||||
foreach (int bp, breakpoints) {
|
foreach (int bp, breakpoints) {
|
||||||
QByteArray request;
|
QByteArray request;
|
||||||
@@ -241,7 +240,11 @@ void QmlV8DebuggerClient::removeBreakpoints(BreakpointModelId *id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlV8DebuggerClient::setBreakpoints()
|
void QmlV8DebuggerClient::changeBreakpoint(BreakpointModelId /*id*/, BreakHandler * /*handler*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlV8DebuggerClient::updateBreakpoints()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,17 +321,6 @@ void QmlV8DebuggerClient::expandObject(const QByteArray &iname, quint64 objectId
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlV8DebuggerClient::sendPing()
|
|
||||||
{
|
|
||||||
QByteArray request;
|
|
||||||
|
|
||||||
JsonInputStream(request) << '{' << INITIALPARAMS ;
|
|
||||||
JsonInputStream(request) << ',' << "command" << ':' << "ping" << '}';
|
|
||||||
|
|
||||||
d->ping = d->sequence;
|
|
||||||
sendMessage(packMessage(request));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlV8DebuggerClient::backtrace()
|
void QmlV8DebuggerClient::backtrace()
|
||||||
{
|
{
|
||||||
QByteArray request;
|
QByteArray request;
|
||||||
@@ -362,9 +354,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString debugCommand(value.findChild("command").toVariant().toString());
|
QString debugCommand(value.findChild("command").toVariant().toString());
|
||||||
if (debugCommand == "pong") {
|
if (debugCommand == "backtrace") {
|
||||||
//DO NOTHING
|
|
||||||
} else if (debugCommand == "backtrace") {
|
|
||||||
setStackFrames(response);
|
setStackFrames(response);
|
||||||
|
|
||||||
} else if (debugCommand == "lookup") {
|
} else if (debugCommand == "lookup") {
|
||||||
|
@@ -62,9 +62,10 @@ public:
|
|||||||
|
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
|
|
||||||
void insertBreakpoints(BreakHandler *handler, BreakpointModelId *id);
|
void insertBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||||
void removeBreakpoints(BreakpointModelId *id);
|
void removeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||||
void setBreakpoints();
|
void changeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||||
|
void updateBreakpoints();
|
||||||
|
|
||||||
void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||||
const QString &property, const QString value);
|
const QString &property, const QString value);
|
||||||
@@ -75,7 +76,6 @@ public:
|
|||||||
void synchronizeWatchers(const QStringList &watchers);
|
void synchronizeWatchers(const QStringList &watchers);
|
||||||
|
|
||||||
void expandObject(const QByteArray &iname, quint64 objectId);
|
void expandObject(const QByteArray &iname, quint64 objectId);
|
||||||
void sendPing();
|
|
||||||
|
|
||||||
void setEngine(QmlEngine *engine);
|
void setEngine(QmlEngine *engine);
|
||||||
|
|
||||||
|
@@ -202,21 +202,29 @@ void QScriptDebuggerClient::activateFrame(int index)
|
|||||||
sendMessage(reply);
|
sendMessage(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptDebuggerClient::insertBreakpoints(BreakHandler *handler, BreakpointModelId *id)
|
void QScriptDebuggerClient::insertBreakpoint(BreakpointModelId id, BreakHandler *handler)
|
||||||
{
|
{
|
||||||
JSAgentBreakpointData bp;
|
JSAgentBreakpointData bp;
|
||||||
bp.fileUrl = QUrl::fromLocalFile(handler->fileName(*id)).toString().toUtf8();
|
bp.fileUrl = QUrl::fromLocalFile(handler->fileName(id)).toString().toUtf8();
|
||||||
bp.lineNumber = handler->lineNumber(*id);
|
bp.lineNumber = handler->lineNumber(id);
|
||||||
bp.functionName = handler->functionName(*id).toUtf8();
|
bp.functionName = handler->functionName(id).toUtf8();
|
||||||
d->breakpoints.insert(bp);
|
d->breakpoints.insert(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptDebuggerClient::removeBreakpoints(BreakpointModelId * /*id*/)
|
void QScriptDebuggerClient::removeBreakpoint(BreakpointModelId id, BreakHandler *handler)
|
||||||
{
|
{
|
||||||
|
JSAgentBreakpointData bp;
|
||||||
|
bp.fileUrl = QUrl::fromLocalFile(handler->fileName(id)).toString().toUtf8();
|
||||||
|
bp.lineNumber = handler->lineNumber(id);
|
||||||
|
bp.functionName = handler->functionName(id).toUtf8();
|
||||||
|
d->breakpoints.remove(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptDebuggerClient::setBreakpoints()
|
void QScriptDebuggerClient::changeBreakpoint(BreakpointModelId /*id*/, BreakHandler * /*handler*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QScriptDebuggerClient::updateBreakpoints()
|
||||||
{
|
{
|
||||||
QByteArray reply;
|
QByteArray reply;
|
||||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||||
@@ -224,8 +232,6 @@ void QScriptDebuggerClient::setBreakpoints()
|
|||||||
rs << cmd
|
rs << cmd
|
||||||
<< d->breakpoints;
|
<< d->breakpoints;
|
||||||
sendMessage(reply);
|
sendMessage(reply);
|
||||||
|
|
||||||
d->breakpoints.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScriptDebuggerClient::assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
void QScriptDebuggerClient::assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||||
|
@@ -61,9 +61,10 @@ public:
|
|||||||
|
|
||||||
void activateFrame(int index);
|
void activateFrame(int index);
|
||||||
|
|
||||||
void insertBreakpoints(BreakHandler *handler, BreakpointModelId *id);
|
void insertBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||||
void removeBreakpoints(BreakpointModelId *id);
|
void removeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||||
void setBreakpoints();
|
void changeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||||
|
void updateBreakpoints();
|
||||||
|
|
||||||
void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||||
const QString &property, const QString value);
|
const QString &property, const QString value);
|
||||||
@@ -74,7 +75,6 @@ public:
|
|||||||
void synchronizeWatchers(const QStringList &watchers);
|
void synchronizeWatchers(const QStringList &watchers);
|
||||||
|
|
||||||
void expandObject(const QByteArray &iname, quint64 objectId);
|
void expandObject(const QByteArray &iname, quint64 objectId);
|
||||||
void sendPing();
|
|
||||||
|
|
||||||
void setEngine(QmlEngine *engine);
|
void setEngine(QmlEngine *engine);
|
||||||
|
|
||||||
@@ -84,6 +84,9 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
void messageReceived(const QByteArray &data);
|
void messageReceived(const QByteArray &data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void sendPing();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScriptDebuggerClientPrivate *d;
|
QScriptDebuggerClientPrivate *d;
|
||||||
friend class QScriptDebuggerClientPrivate;
|
friend class QScriptDebuggerClientPrivate;
|
||||||
|
Reference in New Issue
Block a user