DAP: Add locals lazy loading

Change-Id: I49c6d9fce8c6f45f1ec4cb3b6c1733d93202bc0f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Artem Sokolovskii
2023-08-30 14:41:33 +02:00
parent be6b83ec4a
commit 53718bcf1d
6 changed files with 32 additions and 22 deletions

View File

@@ -47,7 +47,11 @@ public:
void start() override { m_socket.connectToServer(m_socketName, QIODevice::ReadWrite); } void start() override { m_socket.connectToServer(m_socketName, QIODevice::ReadWrite); }
bool isRunning() const override { return m_socket.isOpen(); } bool isRunning() const override { return m_socket.isOpen(); }
void writeRaw(const QByteArray &data) override { m_socket.write(data); } void writeRaw(const QByteArray &data) override
{
if (m_socket.isOpen())
m_socket.write(data);
}
void kill() override void kill() override
{ {
if (m_socket.isOpen()) if (m_socket.isOpen())

View File

@@ -413,8 +413,9 @@ void DapEngine::assignValueInDebugger(WatchItem *, const QString &/*expression*/
void DapEngine::updateItem(const QString &iname) void DapEngine::updateItem(const QString &iname)
{ {
Q_UNUSED(iname) WatchItem *item = watchHandler()->findItem(iname);
updateAll(); m_currentWatchItem = item;
m_dapClient->variables(item->variablesReference);
} }
QString DapEngine::errorMessage(QProcess::ProcessError error) const QString DapEngine::errorMessage(QProcess::ProcessError error) const
@@ -554,6 +555,9 @@ void DapEngine::handleScopesResponse(const QJsonObject &response)
if (name == "Locals") { // Fix for several scopes if (name == "Locals") { // Fix for several scopes
watchHandler()->removeAllData(); watchHandler()->removeAllData();
watchHandler()->notifyUpdateStarted(); watchHandler()->notifyUpdateStarted();
m_watchItems.clear();
watchHandler()->cleanup();
m_dapClient->variables(variablesReference); m_dapClient->variables(variablesReference);
} }
} }
@@ -707,31 +711,25 @@ void DapEngine::refreshLocals(const QJsonArray &variables)
item->address = variable.toObject().value("address").toInt(); item->address = variable.toObject().value("address").toInt();
item->type = variable.toObject().value("type").toString(); item->type = variable.toObject().value("type").toString();
const int variablesReference = variable.toObject().value("variablesReference").toInt();
item->variablesReference = variablesReference;
if (variablesReference > 0)
item->wantsChildren = true;
qCDebug(dapEngineLog) << "variable" << name << item->hexAddress(); qCDebug(dapEngineLog) << "variable" << name << item->hexAddress();
if (isFirstLayer) if (isFirstLayer)
m_watchItems.append(item); m_watchItems.append(item);
else else
m_currentWatchItem->appendChild(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()) { if (isFirstLayer) {
for (auto item : m_watchItems) for (auto item : m_watchItems)
watchHandler()->insertItem(item); watchHandler()->insertItem(item);
m_watchItems.clear(); } else
watchHandler()->updateWatchExpression(m_currentWatchItem, "");
watchHandler()->notifyUpdateFinished(); watchHandler()->notifyUpdateFinished();
return;
}
const auto front = m_variablesReferenceQueue.front();
m_variablesReferenceQueue.pop();
m_dapClient->variables(front.first);
m_currentWatchItem = front.second;
} }
void DapEngine::refreshStack(const QJsonArray &stackFrames) void DapEngine::refreshStack(const QJsonArray &stackFrames)

View File

@@ -113,7 +113,6 @@ protected:
int m_nextBreakpointId = 1; int m_nextBreakpointId = 1;
int m_currentThreadId = -1; int m_currentThreadId = -1;
std::queue<std::pair<int, WatchItem *>> m_variablesReferenceQueue;
WatchItem *m_currentWatchItem = nullptr; WatchItem *m_currentWatchItem = nullptr;
QList<WatchItem *> m_watchItems; QList<WatchItem *> m_watchItems;
}; };

View File

@@ -63,7 +63,11 @@ public:
} }
bool isRunning() const override { return m_proc.isRunning(); } bool isRunning() const override { return m_proc.isRunning(); }
void writeRaw(const QByteArray &data) override { m_proc.writeRaw(data); } void writeRaw(const QByteArray &data) override
{
if (m_proc.state() == QProcess::Running)
m_proc.writeRaw(data);
}
void kill() override { m_proc.kill(); } void kill() override { m_proc.kill(); }
QByteArray readAllStandardOutput() override { return m_proc.readAllStandardOutput().toUtf8(); } QByteArray readAllStandardOutput() override { return m_proc.readAllStandardOutput().toUtf8(); }
QString readAllStandardError() override { return m_proc.readAllStandardError(); } QString readAllStandardError() override { return m_proc.readAllStandardError(); }

View File

@@ -78,7 +78,11 @@ public:
} }
bool isRunning() const override { return m_socket.isOpen(); } bool isRunning() const override { return m_socket.isOpen(); }
void writeRaw(const QByteArray &data) override { m_socket.write(data); } void writeRaw(const QByteArray &data) override
{
if (m_socket.isOpen())
m_socket.write(data);
}
void kill() override void kill() override
{ {
m_timer->stop(); m_timer->stop();
@@ -100,7 +104,7 @@ public:
QProcess::ExitStatus exitStatus() const override { return QProcess::NormalExit; } QProcess::ExitStatus exitStatus() const override { return QProcess::NormalExit; }
QProcess::ProcessError error() const override { return QProcess::UnknownError; } QProcess::ProcessError error() const override { return QProcess::UnknownError; }
Utils::ProcessResult result() const override { return ProcessResult::FinishedWithSuccess; } Utils::ProcessResult result() const override { return ProcessResult::FinishedWithSuccess; }
QString exitMessage() const override { return QString(); }; QString exitMessage() const override { return QString(); }
private: private:
Utils::Process m_proc; Utils::Process m_proc;

View File

@@ -71,6 +71,7 @@ public:
uint bitpos = 0; // Position within bit fields uint bitpos = 0; // Position within bit fields
uint bitsize = 0; // Size in case of bit fields uint bitsize = 0; // Size in case of bit fields
uint autoDerefCount = 0; // number of levels of automatic dereferencing that has taken place (for pointer types) uint autoDerefCount = 0; // number of levels of automatic dereferencing that has taken place (for pointer types)
uint variablesReference = 0;// reference to the variable in the variables request DAP related
int elided = 0; // Full size if value was cut off, -1 if cut on unknown size, 0 otherwise int elided = 0; // Full size if value was cut off, -1 if cut on unknown size, 0 otherwise
int arrayIndex = -1; // -1 if not an array member int arrayIndex = -1; // -1 if not an array member
uchar sortGroup = 0; // 0 - ordinary member, 1 - vptr, 2 - base class uchar sortGroup = 0; // 0 - ordinary member, 1 - vptr, 2 - base class