DAP: Add proper stack frame selection

- Fixed locals view freezing when scope is empty

Change-Id: I1e64217b061937ab66abf3508e2156e9a2c1460c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Artem Sokolovskii
2023-09-21 10:17:07 +02:00
parent dedfc3dbe7
commit 6c93ca2e66
3 changed files with 15 additions and 5 deletions

View File

@@ -218,7 +218,9 @@ void DapEngine::activateFrame(int frameIndex)
QTC_ASSERT(frameIndex < handler->stackSize(), return); QTC_ASSERT(frameIndex < handler->stackSize(), return);
handler->setCurrentIndex(frameIndex); handler->setCurrentIndex(frameIndex);
gotoLocation(handler->currentFrame()); gotoLocation(handler->currentFrame());
updateLocals();
m_currentStackFrameId = handler->currentFrame().debuggerId;
m_dapClient->scopes(m_currentStackFrameId);
} }
void DapEngine::selectThread(const Thread &thread) void DapEngine::selectThread(const Thread &thread)
@@ -546,7 +548,8 @@ void DapEngine::handleStackTraceResponse(const QJsonObject &response)
gotoLocation(Location(file, line)); gotoLocation(Location(file, line));
refreshStack(stackFrames); refreshStack(stackFrames);
m_dapClient->scopes(stackFrame.value("id").toInt()); m_currentStackFrameId = stackFrame.value("id").toInt();
m_dapClient->scopes(m_currentStackFrameId);
} }
void DapEngine::handleScopesResponse(const QJsonObject &response) void DapEngine::handleScopesResponse(const QJsonObject &response)
@@ -568,9 +571,13 @@ void DapEngine::handleScopesResponse(const QJsonObject &response)
m_variablesReferenceQueue.push(scope.toObject().value("variablesReference").toInt()); m_variablesReferenceQueue.push(scope.toObject().value("variablesReference").toInt());
} }
m_isFirstLayer = true; if (!m_variablesReferenceQueue.empty()) {
m_dapClient->variables(m_variablesReferenceQueue.front()); m_isFirstLayer = true;
m_variablesReferenceQueue.pop(); m_dapClient->variables(m_variablesReferenceQueue.front());
m_variablesReferenceQueue.pop();
} else {
watchHandler()->notifyUpdateFinished();
}
} }
void DapEngine::handleThreadsResponse(const QJsonObject &response) void DapEngine::handleThreadsResponse(const QJsonObject &response)
@@ -761,6 +768,7 @@ void DapEngine::refreshStack(const QJsonArray &stackFrames)
frame.file = FilePath::fromString(source.value("path").toString()); frame.file = FilePath::fromString(source.value("path").toString());
frame.address = item.value("instructionPointerReference").toInt(); frame.address = item.value("instructionPointerReference").toInt();
frame.usable = frame.file.isReadableFile(); frame.usable = frame.file.isReadableFile();
frame.debuggerId = item.value("id").toInt();
frames.append(frame); frames.append(frame);
} }
handler->setFrames(frames, false); handler->setFrames(frames, false);

View File

@@ -114,6 +114,7 @@ protected:
int m_nextBreakpointId = 1; int m_nextBreakpointId = 1;
int m_currentThreadId = -1; int m_currentThreadId = -1;
int m_currentStackFrameId = -1;
bool m_isFirstLayer = true; bool m_isFirstLayer = true;
std::queue<int> m_variablesReferenceQueue; std::queue<int> m_variablesReferenceQueue;

View File

@@ -37,6 +37,7 @@ public:
quint64 address = 0; quint64 address = 0;
bool usable = false; bool usable = false;
QString context; // Opaque value produced and consumed by the native backends. QString context; // Opaque value produced and consumed by the native backends.
uint debuggerId = 0;
}; };
using StackFrames = QList<StackFrame>; using StackFrames = QList<StackFrame>;