forked from qt-creator/qt-creator
DAP: Add displaying nested variables
Change-Id: I588dde7c0ef402fe8d6c9d43dc9f0183bfa2d733 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -151,6 +151,8 @@ DapEngine::DapEngine()
|
||||
{
|
||||
setObjectName("DapEngine");
|
||||
setDebuggerName("DAP");
|
||||
m_rootWatchItem = new WatchItem();
|
||||
m_currentWatchItem = m_rootWatchItem;
|
||||
}
|
||||
|
||||
void DapEngine::executeDebuggerCommand(const QString &/*command*/)
|
||||
@@ -837,18 +839,21 @@ void DapEngine::handleOutput(const QJsonDocument &data)
|
||||
const QString name = scope.toObject().value("name").toString();
|
||||
const int variablesReference = scope.toObject().value("variablesReference").toInt();
|
||||
qCDebug(dapEngineLog) << "scoped success" << name << variablesReference;
|
||||
// if (name == "Locals")
|
||||
// dapVariables(variablesReference);
|
||||
if (name == "Locals") { // Fix for several scopes
|
||||
m_rootWatchItem = new WatchItem();
|
||||
m_currentWatchItem = m_rootWatchItem;
|
||||
watchHandler()->removeAllData();
|
||||
watchHandler()->notifyUpdateStarted();
|
||||
dapVariables(variablesReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (command == "variables") {
|
||||
if (ob.value("success").toBool()) {
|
||||
auto variables = ob.value("body").toObject().value("variables").toArray();
|
||||
refreshLocals(variables);
|
||||
}
|
||||
}
|
||||
|
||||
if (command == "stepIn" || command == "stepOut" || command == "next") {
|
||||
if (ob.value("success").toBool()) {
|
||||
@@ -985,7 +990,6 @@ void DapEngine::handleOutput(const QJsonDocument &data)
|
||||
|
||||
void DapEngine::refreshLocals(const QJsonArray &variables)
|
||||
{
|
||||
watchHandler()->notifyUpdateStarted();
|
||||
for (auto variable : variables) {
|
||||
WatchItem *item = new WatchItem;
|
||||
const QString name = variable.toObject().value("name").toString();
|
||||
@@ -995,10 +999,27 @@ void DapEngine::refreshLocals(const QJsonArray &variables)
|
||||
item->value = variable.toObject().value("value").toString();
|
||||
item->address = variable.toObject().value("address").toInt();
|
||||
item->type = variable.toObject().value("type").toString();
|
||||
|
||||
qCDebug(dapEngineLog) << "variable" << name << item->hexAddress();
|
||||
watchHandler()->insertItem(item);
|
||||
m_currentWatchItem->appendChild(item);
|
||||
|
||||
const int variablesReference = variable.toObject().value("variablesReference").toInt();
|
||||
if (variablesReference > 0)
|
||||
m_variablesReferenceQueue.push({variablesReference, item});
|
||||
}
|
||||
|
||||
if (m_variablesReferenceQueue.empty()) {
|
||||
for (auto item = m_rootWatchItem->begin(); item != m_rootWatchItem->end(); ++item)
|
||||
watchHandler()->insertItem(*item);
|
||||
watchHandler()->notifyUpdateFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto front = m_variablesReferenceQueue.front();
|
||||
m_variablesReferenceQueue.pop();
|
||||
|
||||
dapVariables(front.first);
|
||||
m_currentWatchItem = front.second;
|
||||
}
|
||||
|
||||
void DapEngine::refreshStack(const QJsonArray &stackFrames)
|
||||
|
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <queue>
|
||||
|
||||
namespace Debugger::Internal {
|
||||
|
||||
class DebuggerCommand;
|
||||
@@ -126,6 +128,10 @@ private:
|
||||
|
||||
int m_nextBreakpointId = 1;
|
||||
int m_currentThreadId = -1;
|
||||
|
||||
std::queue<std::pair<int, WatchItem *>> m_variablesReferenceQueue;
|
||||
WatchItem *m_currentWatchItem = nullptr;
|
||||
WatchItem *m_rootWatchItem = nullptr;
|
||||
};
|
||||
|
||||
} // Debugger::Internal
|
||||
|
Reference in New Issue
Block a user