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 insertBreakpoints(BreakHandler *handler, BreakpointModelId *id) = 0;
|
||||
virtual void removeBreakpoints(BreakpointModelId *id) = 0;
|
||||
virtual void setBreakpoints() = 0;
|
||||
virtual void insertBreakpoint(BreakpointModelId id, BreakHandler *handler) = 0;
|
||||
virtual void removeBreakpoint(BreakpointModelId id, BreakHandler *handler) = 0;
|
||||
virtual void changeBreakpoint(BreakpointModelId id, BreakHandler *handler) = 0;
|
||||
virtual void updateBreakpoints() = 0;
|
||||
|
||||
virtual void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||
const QString &property, const QString value) = 0;
|
||||
@@ -75,7 +76,6 @@ public:
|
||||
virtual void synchronizeWatchers(const QStringList &watchers) = 0;
|
||||
|
||||
virtual void expandObject(const QByteArray &iname, quint64 objectId) = 0;
|
||||
virtual void sendPing() = 0;
|
||||
|
||||
virtual void setEngine(QmlEngine *engine) = 0;
|
||||
|
||||
|
@@ -491,8 +491,73 @@ void QmlEngine::selectThread(int 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()
|
||||
{
|
||||
if (!stateAcceptsBreakpointChanges()) {
|
||||
showMessage(_("BREAKPOINT SYNCHRONIZATION NOT POSSIBLE IN CURRENT STATE"));
|
||||
return;
|
||||
}
|
||||
|
||||
BreakHandler *handler = breakHandler();
|
||||
|
||||
foreach (BreakpointModelId id, handler->unclaimedBreakpointIds()) {
|
||||
@@ -501,45 +566,39 @@ void QmlEngine::attemptBreakpointSynchronization()
|
||||
handler->setEngine(id, this);
|
||||
}
|
||||
|
||||
QStringList breakPointsStr;
|
||||
foreach (BreakpointModelId id, handler->engineBreakpointIds(this)) {
|
||||
if (handler->state(id) == BreakpointRemoveRequested) {
|
||||
handler->notifyBreakpointRemoveProceeding(id);
|
||||
if (d->m_adapter.activeDebuggerClient())
|
||||
d->m_adapter.activeDebuggerClient()->removeBreakpoints(&id);
|
||||
else {
|
||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||
client->removeBreakpoints(&id);
|
||||
}
|
||||
}
|
||||
handler->notifyBreakpointRemoveOk(id);
|
||||
} else {
|
||||
if (handler->state(id) == BreakpointInsertRequested) {
|
||||
handler->notifyBreakpointInsertProceeding(id);
|
||||
}
|
||||
if (d->m_adapter.activeDebuggerClient())
|
||||
d->m_adapter.activeDebuggerClient()->insertBreakpoints(handler,&id);
|
||||
else {
|
||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||
client->insertBreakpoints(handler,&id);
|
||||
}
|
||||
}
|
||||
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)));
|
||||
switch (handler->state(id)) {
|
||||
case BreakpointNew:
|
||||
// Should not happen once claimed.
|
||||
QTC_CHECK(false);
|
||||
continue;
|
||||
case BreakpointInsertRequested:
|
||||
insertBreakpoint(id);
|
||||
continue;
|
||||
case BreakpointChangeRequested:
|
||||
changeBreakpoint(id);
|
||||
continue;
|
||||
case BreakpointRemoveRequested:
|
||||
removeBreakpoint(id);
|
||||
continue;
|
||||
case BreakpointChangeProceeding:
|
||||
case BreakpointInsertProceeding:
|
||||
case BreakpointRemoveProceeding:
|
||||
case BreakpointInserted:
|
||||
case BreakpointDead:
|
||||
continue;
|
||||
}
|
||||
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()) {
|
||||
d->m_adapter.activeDebuggerClient()->setBreakpoints();
|
||||
}
|
||||
else {
|
||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients())
|
||||
client->setBreakpoints();
|
||||
d->m_adapter.activeDebuggerClient()->updateBreakpoints();
|
||||
} else {
|
||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
||||
client->updateBreakpoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,8 +690,7 @@ void QmlEngine::synchronizeWatchers()
|
||||
QString("WATCH_EXPRESSIONS"), watchedExpressions.join(", ")));
|
||||
if (d->m_adapter.activeDebuggerClient()) {
|
||||
d->m_adapter.activeDebuggerClient()->synchronizeWatchers(watchedExpressions);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients())
|
||||
client->synchronizeWatchers(watchedExpressions);
|
||||
}
|
||||
|
@@ -107,6 +107,9 @@ private:
|
||||
void selectThread(int index);
|
||||
|
||||
void attemptBreakpointSynchronization();
|
||||
void insertBreakpoint(BreakpointModelId id);
|
||||
void removeBreakpoint(BreakpointModelId id);
|
||||
void changeBreakpoint(BreakpointModelId id);
|
||||
bool acceptsBreakpoint(BreakpointModelId id) const;
|
||||
|
||||
void assignValueInDebugger(const WatchData *data,
|
||||
|
@@ -197,33 +197,32 @@ void QmlV8DebuggerClient::activateFrame(int index)
|
||||
setLocals(index);
|
||||
}
|
||||
|
||||
void QmlV8DebuggerClient::insertBreakpoints(BreakHandler *handler, BreakpointModelId *id)
|
||||
void QmlV8DebuggerClient::insertBreakpoint(BreakpointModelId id, BreakHandler *handler)
|
||||
{
|
||||
QByteArray request;
|
||||
|
||||
JsonInputStream(request) << '{' << INITIALPARAMS ;
|
||||
JsonInputStream(request) << ',' << "command" << ':' << "setbreakpoint";
|
||||
JsonInputStream(request) << ',' << "arguments" << ':' << '{';
|
||||
if (handler->breakpointData(*id).type == BreakpointByFileAndLine) {
|
||||
if (handler->breakpointData(id).type == BreakpointByFileAndLine) {
|
||||
JsonInputStream(request) << "type" << ':' << "script";
|
||||
JsonInputStream(request) << ',' << "target" << ':' << QFileInfo(handler->fileName(*id)).fileName().toUtf8();
|
||||
JsonInputStream(request) << ',' << "line" << ':' << handler->lineNumber(*id) - 1;
|
||||
} else if (handler->breakpointData(*id).type == BreakpointByFunction) {
|
||||
JsonInputStream(request) << ',' << "target" << ':' << QFileInfo(handler->fileName(id)).fileName().toUtf8();
|
||||
JsonInputStream(request) << ',' << "line" << ':' << handler->lineNumber(id) - 1;
|
||||
} else if (handler->breakpointData(id).type == BreakpointByFunction) {
|
||||
JsonInputStream(request) << "type" << ':' << "function";
|
||||
JsonInputStream(request) << ',' << "target" << ':' << handler->functionName(*id).toUtf8();
|
||||
JsonInputStream(request) << ',' << "target" << ':' << handler->functionName(id).toUtf8();
|
||||
}
|
||||
JsonInputStream(request) << '}';
|
||||
JsonInputStream(request) << '}';
|
||||
|
||||
d->breakpointsSync.insert(d->sequence,*id);
|
||||
d->breakpointsSync.insert(d->sequence,id);
|
||||
sendMessage(packMessage(request));
|
||||
|
||||
}
|
||||
|
||||
void QmlV8DebuggerClient::removeBreakpoints(BreakpointModelId *id)
|
||||
void QmlV8DebuggerClient::removeBreakpoint(BreakpointModelId id, BreakHandler * /*handler*/)
|
||||
{
|
||||
QList<int> breakpoints = d->breakpoints.values(*id);
|
||||
d->breakpoints.remove(*id);
|
||||
QList<int> breakpoints = d->breakpoints.values(id);
|
||||
d->breakpoints.remove(id);
|
||||
|
||||
foreach (int bp, breakpoints) {
|
||||
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()
|
||||
{
|
||||
QByteArray request;
|
||||
@@ -362,9 +354,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
|
||||
}
|
||||
|
||||
QString debugCommand(value.findChild("command").toVariant().toString());
|
||||
if (debugCommand == "pong") {
|
||||
//DO NOTHING
|
||||
} else if (debugCommand == "backtrace") {
|
||||
if (debugCommand == "backtrace") {
|
||||
setStackFrames(response);
|
||||
|
||||
} else if (debugCommand == "lookup") {
|
||||
|
@@ -62,9 +62,10 @@ public:
|
||||
|
||||
void activateFrame(int index);
|
||||
|
||||
void insertBreakpoints(BreakHandler *handler, BreakpointModelId *id);
|
||||
void removeBreakpoints(BreakpointModelId *id);
|
||||
void setBreakpoints();
|
||||
void insertBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||
void removeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||
void changeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||
void updateBreakpoints();
|
||||
|
||||
void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||
const QString &property, const QString value);
|
||||
@@ -75,7 +76,6 @@ public:
|
||||
void synchronizeWatchers(const QStringList &watchers);
|
||||
|
||||
void expandObject(const QByteArray &iname, quint64 objectId);
|
||||
void sendPing();
|
||||
|
||||
void setEngine(QmlEngine *engine);
|
||||
|
||||
|
@@ -202,21 +202,29 @@ void QScriptDebuggerClient::activateFrame(int index)
|
||||
sendMessage(reply);
|
||||
}
|
||||
|
||||
void QScriptDebuggerClient::insertBreakpoints(BreakHandler *handler, BreakpointModelId *id)
|
||||
void QScriptDebuggerClient::insertBreakpoint(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();
|
||||
bp.fileUrl = QUrl::fromLocalFile(handler->fileName(id)).toString().toUtf8();
|
||||
bp.lineNumber = handler->lineNumber(id);
|
||||
bp.functionName = handler->functionName(id).toUtf8();
|
||||
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;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
@@ -224,8 +232,6 @@ void QScriptDebuggerClient::setBreakpoints()
|
||||
rs << cmd
|
||||
<< d->breakpoints;
|
||||
sendMessage(reply);
|
||||
|
||||
d->breakpoints.clear();
|
||||
}
|
||||
|
||||
void QScriptDebuggerClient::assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||
|
@@ -61,9 +61,10 @@ public:
|
||||
|
||||
void activateFrame(int index);
|
||||
|
||||
void insertBreakpoints(BreakHandler *handler, BreakpointModelId *id);
|
||||
void removeBreakpoints(BreakpointModelId *id);
|
||||
void setBreakpoints();
|
||||
void insertBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||
void removeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||
void changeBreakpoint(BreakpointModelId id, BreakHandler *handler);
|
||||
void updateBreakpoints();
|
||||
|
||||
void assignValueInDebugger(const QByteArray expr, const quint64 &id,
|
||||
const QString &property, const QString value);
|
||||
@@ -74,7 +75,6 @@ public:
|
||||
void synchronizeWatchers(const QStringList &watchers);
|
||||
|
||||
void expandObject(const QByteArray &iname, quint64 objectId);
|
||||
void sendPing();
|
||||
|
||||
void setEngine(QmlEngine *engine);
|
||||
|
||||
@@ -84,6 +84,9 @@ signals:
|
||||
protected:
|
||||
void messageReceived(const QByteArray &data);
|
||||
|
||||
private:
|
||||
void sendPing();
|
||||
|
||||
private:
|
||||
QScriptDebuggerClientPrivate *d;
|
||||
friend class QScriptDebuggerClientPrivate;
|
||||
|
Reference in New Issue
Block a user