forked from qt-creator/qt-creator
DAP: Fix rootWatchItem deletion
Change-Id: I2fcdf7547a361dcb136cd1a03325e7f5186b273a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -64,17 +64,6 @@ static Q_LOGGING_CATEGORY(dapEngineLog, "qtc.dbg.dapengine", QtWarningMsg)
|
|||||||
|
|
||||||
namespace Debugger::Internal {
|
namespace Debugger::Internal {
|
||||||
|
|
||||||
DapEngine::DapEngine()
|
|
||||||
{
|
|
||||||
m_rootWatchItem = new WatchItem();
|
|
||||||
m_currentWatchItem = m_rootWatchItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
DapEngine::~DapEngine()
|
|
||||||
{
|
|
||||||
delete m_rootWatchItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DapEngine::executeDebuggerCommand(const QString &/*command*/)
|
void DapEngine::executeDebuggerCommand(const QString &/*command*/)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qCDebug(dapEngineLog) << state());
|
QTC_ASSERT(state() == InferiorStopOk, qCDebug(dapEngineLog) << state());
|
||||||
@@ -558,8 +547,6 @@ void DapEngine::handleScopesResponse(const QJsonObject &response)
|
|||||||
const int variablesReference = scope.toObject().value("variablesReference").toInt();
|
const int variablesReference = scope.toObject().value("variablesReference").toInt();
|
||||||
qCDebug(dapEngineLog) << "scoped success" << name << variablesReference;
|
qCDebug(dapEngineLog) << "scoped success" << name << variablesReference;
|
||||||
if (name == "Locals") { // Fix for several scopes
|
if (name == "Locals") { // Fix for several scopes
|
||||||
m_rootWatchItem = new WatchItem();
|
|
||||||
m_currentWatchItem = m_rootWatchItem;
|
|
||||||
watchHandler()->removeAllData();
|
watchHandler()->removeAllData();
|
||||||
watchHandler()->notifyUpdateStarted();
|
watchHandler()->notifyUpdateStarted();
|
||||||
m_dapClient->variables(variablesReference);
|
m_dapClient->variables(variablesReference);
|
||||||
@@ -701,6 +688,7 @@ 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();
|
||||||
@@ -712,6 +700,9 @@ void DapEngine::refreshLocals(const QJsonArray &variables)
|
|||||||
item->type = variable.toObject().value("type").toString();
|
item->type = variable.toObject().value("type").toString();
|
||||||
|
|
||||||
qCDebug(dapEngineLog) << "variable" << name << item->hexAddress();
|
qCDebug(dapEngineLog) << "variable" << name << item->hexAddress();
|
||||||
|
if (isFirstLayer)
|
||||||
|
m_watchItems.append(item);
|
||||||
|
else
|
||||||
m_currentWatchItem->appendChild(item);
|
m_currentWatchItem->appendChild(item);
|
||||||
|
|
||||||
const int variablesReference = variable.toObject().value("variablesReference").toInt();
|
const int variablesReference = variable.toObject().value("variablesReference").toInt();
|
||||||
@@ -720,8 +711,10 @@ void DapEngine::refreshLocals(const QJsonArray &variables)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_variablesReferenceQueue.empty()) {
|
if (m_variablesReferenceQueue.empty()) {
|
||||||
for (auto item = m_rootWatchItem->begin(); item != m_rootWatchItem->end(); ++item)
|
for (auto item : m_watchItems)
|
||||||
watchHandler()->insertItem(*item);
|
watchHandler()->insertItem(item);
|
||||||
|
m_watchItems.clear();
|
||||||
|
|
||||||
watchHandler()->notifyUpdateFinished();
|
watchHandler()->notifyUpdateFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ enum class DapEventType;
|
|||||||
class DapEngine : public DebuggerEngine
|
class DapEngine : public DebuggerEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DapEngine();
|
DapEngine() = default;
|
||||||
~DapEngine() override;
|
~DapEngine() override = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeStepIn(bool) override;
|
void executeStepIn(bool) override;
|
||||||
@@ -115,7 +115,7 @@ protected:
|
|||||||
|
|
||||||
std::queue<std::pair<int, WatchItem *>> m_variablesReferenceQueue;
|
std::queue<std::pair<int, WatchItem *>> m_variablesReferenceQueue;
|
||||||
WatchItem *m_currentWatchItem = nullptr;
|
WatchItem *m_currentWatchItem = nullptr;
|
||||||
WatchItem *m_rootWatchItem = nullptr;
|
QList<WatchItem *> m_watchItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Debugger::Internal
|
} // Debugger::Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user