forked from qt-creator/qt-creator
QmlDebugger: Pass selected watch item as context to V4 debugger
Newer V4 debug servers will accept a "context" parameter which specifies the ID of an object which is then used to look up a QML context to inject when evaluating expressions. Change-Id: I9d2a2226559380550308cacfe559e079291c14b5 Task-number: QTCREATORBUG-17177 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -144,7 +144,7 @@ public:
|
|||||||
|
|
||||||
void continueDebugging(StepAction stepAction);
|
void continueDebugging(StepAction stepAction);
|
||||||
|
|
||||||
void evaluate(const QString expr, const QmlCallback &cb);
|
void evaluate(const QString expr, qint64 context, const QmlCallback &cb);
|
||||||
void lookup(const LookupItems &items);
|
void lookup(const LookupItems &items);
|
||||||
void backtrace();
|
void backtrace();
|
||||||
void updateLocals();
|
void updateLocals();
|
||||||
@@ -939,7 +939,7 @@ void QmlEngine::assignValueInDebugger(WatchItem *item,
|
|||||||
StackHandler *handler = stackHandler();
|
StackHandler *handler = stackHandler();
|
||||||
QString exp = QString("%1 = %2;").arg(expression).arg(value.toString());
|
QString exp = QString("%1 = %2;").arg(expression).arg(value.toString());
|
||||||
if (handler->isContentsValid() && handler->currentFrame().isUsable()) {
|
if (handler->isContentsValid() && handler->currentFrame().isUsable()) {
|
||||||
d->evaluate(exp, [this](const QVariantMap &) { d->updateLocals(); });
|
d->evaluate(exp, -1, [this](const QVariantMap &) { d->updateLocals(); });
|
||||||
} else {
|
} else {
|
||||||
showMessage(QString("Cannot evaluate %1 in current stack frame")
|
showMessage(QString("Cannot evaluate %1 in current stack frame")
|
||||||
.arg(expression), ConsoleOutput);
|
.arg(expression), ConsoleOutput);
|
||||||
@@ -971,7 +971,7 @@ void QmlEngine::updateItem(const QString &iname)
|
|||||||
// The Qt side Q_ASSERTs otherwise. So postpone the evaluation,
|
// The Qt side Q_ASSERTs otherwise. So postpone the evaluation,
|
||||||
// it will be triggered from from upateLocals() later.
|
// it will be triggered from from upateLocals() later.
|
||||||
QString exp = item->exp;
|
QString exp = item->exp;
|
||||||
d->evaluate(exp, [this, iname, exp](const QVariantMap &response) {
|
d->evaluate(exp, -1, [this, iname, exp](const QVariantMap &response) {
|
||||||
d->handleEvaluateExpression(response, iname, exp);
|
d->handleEvaluateExpression(response, iname, exp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1130,23 +1130,26 @@ void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages
|
|||||||
if (state() == InferiorStopOk) {
|
if (state() == InferiorStopOk) {
|
||||||
StackHandler *handler = stackHandler();
|
StackHandler *handler = stackHandler();
|
||||||
if (handler->isContentsValid() && handler->currentFrame().isUsable()) {
|
if (handler->isContentsValid() && handler->currentFrame().isUsable()) {
|
||||||
d->evaluate(command, CB(d->handleExecuteDebuggerCommand));
|
d->evaluate(command, -1, CB(d->handleExecuteDebuggerCommand));
|
||||||
} else {
|
} else {
|
||||||
// Paused but no stack? Something is wrong
|
// Paused but no stack? Something is wrong
|
||||||
d->engine->showMessage(QString("Cannot evaluate %1. The stack trace is broken.").arg(command),
|
d->engine->showMessage(QString("Cannot evaluate %1. The stack trace is broken.").arg(command),
|
||||||
ConsoleOutput);
|
ConsoleOutput);
|
||||||
}
|
}
|
||||||
} else if (d->unpausedEvaluate) {
|
|
||||||
d->evaluate(command, CB(d->handleExecuteDebuggerCommand));
|
|
||||||
} else {
|
} else {
|
||||||
QModelIndex currentIndex = inspectorView()->currentIndex();
|
QModelIndex currentIndex = inspectorView()->currentIndex();
|
||||||
quint32 queryId = d->inspectorAgent.queryExpressionResult(
|
qint64 contextId = watchHandler()->watchItem(currentIndex)->id;
|
||||||
watchHandler()->watchItem(currentIndex)->id, command);
|
|
||||||
if (queryId) {
|
if (d->unpausedEvaluate) {
|
||||||
d->queryIds.append(queryId);
|
d->evaluate(command, contextId, CB(d->handleExecuteDebuggerCommand));
|
||||||
} else {
|
} else {
|
||||||
d->engine->showMessage("The application has to be stopped in a breakpoint in order to"
|
quint32 queryId = d->inspectorAgent.queryExpressionResult(contextId, command);
|
||||||
" evaluate expressions", ConsoleOutput);
|
if (queryId) {
|
||||||
|
d->queryIds.append(queryId);
|
||||||
|
} else {
|
||||||
|
d->engine->showMessage("The application has to be stopped in a breakpoint in order to"
|
||||||
|
" evaluate expressions", ConsoleOutput);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1295,7 +1298,7 @@ void QmlEnginePrivate::continueDebugging(StepAction action)
|
|||||||
previousStepAction = action;
|
previousStepAction = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEnginePrivate::evaluate(const QString expr, const QmlCallback &cb)
|
void QmlEnginePrivate::evaluate(const QString expr, qint64 context, const QmlCallback &cb)
|
||||||
{
|
{
|
||||||
// { "seq" : <number>,
|
// { "seq" : <number>,
|
||||||
// "type" : "request",
|
// "type" : "request",
|
||||||
@@ -1304,11 +1307,7 @@ void QmlEnginePrivate::evaluate(const QString expr, const QmlCallback &cb)
|
|||||||
// "frame" : <number>,
|
// "frame" : <number>,
|
||||||
// "global" : <boolean>,
|
// "global" : <boolean>,
|
||||||
// "disable_break" : <boolean>,
|
// "disable_break" : <boolean>,
|
||||||
// "additional_context" : [
|
// "context" : <object id>
|
||||||
// { "name" : <name1>, "handle" : <handle1> },
|
|
||||||
// { "name" : <name2>, "handle" : <handle2> },
|
|
||||||
// ...
|
|
||||||
// ]
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -1323,6 +1322,9 @@ void QmlEnginePrivate::evaluate(const QString expr, const QmlCallback &cb)
|
|||||||
if (handler->currentFrame().isUsable())
|
if (handler->currentFrame().isUsable())
|
||||||
cmd.arg(FRAME, handler->currentIndex());
|
cmd.arg(FRAME, handler->currentIndex());
|
||||||
|
|
||||||
|
if (context >= 0)
|
||||||
|
cmd.arg(CONTEXT, context);
|
||||||
|
|
||||||
runCommand(cmd, cb);
|
runCommand(cmd, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2187,7 +2189,7 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response)
|
|||||||
item->id = 0;
|
item->id = 0;
|
||||||
}
|
}
|
||||||
watchHandler->insertItem(item);
|
watchHandler->insertItem(item);
|
||||||
evaluate(exp, [this, iname, exp](const QVariantMap &response) {
|
evaluate(exp, -1, [this, iname, exp](const QVariantMap &response) {
|
||||||
handleEvaluateExpression(response, iname, exp);
|
handleEvaluateExpression(response, iname, exp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2210,7 +2212,7 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response)
|
|||||||
QStringList watchers = watchHandler->watchedExpressions();
|
QStringList watchers = watchHandler->watchedExpressions();
|
||||||
foreach (const QString &exp, watchers) {
|
foreach (const QString &exp, watchers) {
|
||||||
const QString iname = watchHandler->watcherName(exp);
|
const QString iname = watchHandler->watcherName(exp);
|
||||||
evaluate(exp, [this, iname, exp](const QVariantMap &response) {
|
evaluate(exp, -1, [this, iname, exp](const QVariantMap &response) {
|
||||||
handleEvaluateExpression(response, iname, exp);
|
handleEvaluateExpression(response, iname, exp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ const char EXPRESSION[] = "expression";
|
|||||||
const char FRAME[] = "frame";
|
const char FRAME[] = "frame";
|
||||||
const char GLOBAL[] = "global";
|
const char GLOBAL[] = "global";
|
||||||
const char DISABLE_BREAK[] = "disable_break";
|
const char DISABLE_BREAK[] = "disable_break";
|
||||||
const char ADDITIONAL_CONTEXT[] = "additional_context";
|
const char CONTEXT[] = "context";
|
||||||
const char HANDLES[] = "handles";
|
const char HANDLES[] = "handles";
|
||||||
const char INCLUDESOURCE[] = "includeSource";
|
const char INCLUDESOURCE[] = "includeSource";
|
||||||
const char FROMFRAME[] = "fromFrame";
|
const char FROMFRAME[] = "fromFrame";
|
||||||
|
Reference in New Issue
Block a user