forked from qt-creator/qt-creator
DAP: Show variables for different scopes
Fixed displaying several the same variables. Change-Id: I848113de3a5e142394fbdb4efd40230f43c2417f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -409,8 +409,12 @@ void DapEngine::assignValueInDebugger(WatchItem *, const QString &/*expression*/
|
|||||||
void DapEngine::updateItem(const QString &iname)
|
void DapEngine::updateItem(const QString &iname)
|
||||||
{
|
{
|
||||||
WatchItem *item = watchHandler()->findItem(iname);
|
WatchItem *item = watchHandler()->findItem(iname);
|
||||||
m_currentWatchItem = item;
|
|
||||||
m_dapClient->variables(item->variablesReference);
|
if (m_currentWatchItem != item) {
|
||||||
|
m_currentWatchItem = item;
|
||||||
|
m_isFirstLayer = false;
|
||||||
|
m_dapClient->variables(item->variablesReference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DapEngine::errorMessage(QProcess::ProcessError error) const
|
QString DapEngine::errorMessage(QProcess::ProcessError error) const
|
||||||
@@ -542,20 +546,23 @@ void DapEngine::handleScopesResponse(const QJsonObject &response)
|
|||||||
if (!response.value("success").toBool())
|
if (!response.value("success").toBool())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
watchHandler()->cleanup();
|
||||||
|
watchHandler()->removeAllData();
|
||||||
|
watchHandler()->notifyUpdateStarted();
|
||||||
|
|
||||||
|
m_watchItems.clear();
|
||||||
|
|
||||||
QJsonArray scopes = response.value("body").toObject().value("scopes").toArray();
|
QJsonArray scopes = response.value("body").toObject().value("scopes").toArray();
|
||||||
for (const QJsonValueRef &scope : scopes) {
|
for (const QJsonValueRef &scope : scopes) {
|
||||||
const QString name = scope.toObject().value("name").toString();
|
const QString name = scope.toObject().value("name").toString();
|
||||||
const int variablesReference = scope.toObject().value("variablesReference").toInt();
|
if (name == "Registers")
|
||||||
qCDebug(dapEngineLog) << "scoped success" << name << variablesReference;
|
continue;
|
||||||
if (name == "Locals") { // Fix for several scopes
|
m_variablesReferenceQueue.push(scope.toObject().value("variablesReference").toInt());
|
||||||
watchHandler()->removeAllData();
|
|
||||||
watchHandler()->notifyUpdateStarted();
|
|
||||||
|
|
||||||
m_watchItems.clear();
|
|
||||||
watchHandler()->cleanup();
|
|
||||||
m_dapClient->variables(variablesReference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isFirstLayer = true;
|
||||||
|
m_dapClient->variables(m_variablesReferenceQueue.front());
|
||||||
|
m_variablesReferenceQueue.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DapEngine::handleThreadsResponse(const QJsonObject &response)
|
void DapEngine::handleThreadsResponse(const QJsonObject &response)
|
||||||
@@ -695,7 +702,6 @@ void DapEngine::handleBreakpointEvent(const QJsonObject &event)
|
|||||||
|
|
||||||
void DapEngine::refreshLocals(const QJsonArray &variables)
|
void DapEngine::refreshLocals(const QJsonArray &variables)
|
||||||
{
|
{
|
||||||
bool isFirstLayer = m_watchItems.isEmpty();
|
|
||||||
for (auto variable : variables) {
|
for (auto variable : variables) {
|
||||||
WatchItem *item = new WatchItem;
|
WatchItem *item = new WatchItem;
|
||||||
const QString name = variable.toObject().value("name").toString();
|
const QString name = variable.toObject().value("name").toString();
|
||||||
@@ -711,18 +717,24 @@ void DapEngine::refreshLocals(const QJsonArray &variables)
|
|||||||
if (variablesReference > 0)
|
if (variablesReference > 0)
|
||||||
item->wantsChildren = true;
|
item->wantsChildren = true;
|
||||||
|
|
||||||
qCDebug(dapEngineLog) << "variable" << name << item->hexAddress();
|
qCDebug(dapEngineLog) << "variable" << name << variablesReference;
|
||||||
if (isFirstLayer)
|
if (m_isFirstLayer)
|
||||||
m_watchItems.append(item);
|
m_watchItems.append(item);
|
||||||
else
|
else
|
||||||
m_currentWatchItem->appendChild(item);
|
m_currentWatchItem->appendChild(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFirstLayer) {
|
if (m_isFirstLayer) {
|
||||||
for (auto item : m_watchItems)
|
if (m_variablesReferenceQueue.empty()) {
|
||||||
watchHandler()->insertItem(item);
|
for (auto item : m_watchItems)
|
||||||
} else
|
watchHandler()->insertItem(item);
|
||||||
|
} else {
|
||||||
|
m_dapClient->variables(m_variablesReferenceQueue.front());
|
||||||
|
m_variablesReferenceQueue.pop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
watchHandler()->updateWatchExpression(m_currentWatchItem, "");
|
watchHandler()->updateWatchExpression(m_currentWatchItem, "");
|
||||||
|
}
|
||||||
|
|
||||||
watchHandler()->notifyUpdateFinished();
|
watchHandler()->notifyUpdateFinished();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ protected:
|
|||||||
int m_nextBreakpointId = 1;
|
int m_nextBreakpointId = 1;
|
||||||
int m_currentThreadId = -1;
|
int m_currentThreadId = -1;
|
||||||
|
|
||||||
|
bool m_isFirstLayer = true;
|
||||||
|
std::queue<int> m_variablesReferenceQueue;
|
||||||
WatchItem *m_currentWatchItem = nullptr;
|
WatchItem *m_currentWatchItem = nullptr;
|
||||||
QList<WatchItem *> m_watchItems;
|
QList<WatchItem *> m_watchItems;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user