Debugger: Make updateThreads() a setThreads()

(and keep updateThread() for the single-thread case)

All backends create full lists, making that explicit allows to
simplify the interface.

Change-Id: I717cfcf3ec9f8e81df8a5dfc71ae84855bc3beae
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-08-30 11:52:37 +02:00
parent 7125f6853d
commit 06f3d2bf10
5 changed files with 11 additions and 18 deletions

View File

@@ -1002,7 +1002,7 @@ void CdbEngine::handleThreads(const DebuggerResponse &response)
qPrintable(DebuggerResponse::stringFromResultClass(response.resultClass)));
}
if (response.resultClass == ResultDone) {
threadsHandler()->updateThreads(response.data);
threadsHandler()->setThreads(response.data);
// Continue sequence
reloadFullStack();
} else {
@@ -1866,7 +1866,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
}
const GdbMi threads = stopReason["threads"];
if (threads.isValid()) {
threadsHandler()->updateThreads(threads);
threadsHandler()->setThreads(threads);
if (forcedThread)
threadsHandler()->setCurrentThread(forcedThread);
} else {

View File

@@ -2983,12 +2983,7 @@ void GdbEngine::handleThreadInfo(const DebuggerResponse &response)
{
if (response.resultClass == ResultDone) {
ThreadsHandler *handler = threadsHandler();
handler->updateThreads(response.data);
// This is necessary as the current thread might not be in the list.
if (!handler->currentThread()) {
if (Thread other = handler->threadAt(0))
selectThread(other);
}
handler->setThreads(response.data);
updateState(false); // Adjust Threads combobox.
if (boolSetting(ShowThreadNames)) {
runCommand({"threadnames " + action(MaximalStackDepth)->value().toString(),

View File

@@ -656,7 +656,7 @@ void LldbEngine::updateAll()
{
DebuggerCommand cmd("fetchThreads");
cmd.callback = [this](const DebuggerResponse &response) {
threadsHandler()->updateThreads(response.data);
threadsHandler()->setThreads(response.data);
fetchStack(action(MaximalStackDepth)->value().toInt());
reloadRegisters();
};

View File

@@ -282,12 +282,6 @@ Thread ThreadsHandler::currentThread() const
return m_currentThread;
}
Thread ThreadsHandler::threadAt(int index) const
{
QTC_ASSERT(index >= 0 && index < rootItem()->childCount(), return Thread());
return rootItem()->childAt(index);
}
void ThreadsHandler::setCurrentThread(const Thread &thread)
{
if (thread == m_currentThread)
@@ -368,8 +362,10 @@ void ThreadsHandler::notifyStopped(const QString &id)
thread->notifyStopped();
}
void ThreadsHandler::updateThreads(const GdbMi &data)
void ThreadsHandler::setThreads(const GdbMi &data)
{
rootItem()->removeChildren();
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
@@ -396,6 +392,9 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
const QString &currentId = data["current-thread-id"].data();
m_currentThread = threadForId(currentId);
if (!m_currentThread && !items.isEmpty())
m_currentThread = rootItem()->childAt(0);
}
QAbstractItemModel *ThreadsHandler::model()

View File

@@ -79,13 +79,12 @@ public:
int currentThreadIndex() const;
Thread currentThread() const;
Thread threadAt(int index) const;
Thread threadForId(const QString &id) const;
void setCurrentThread(const Thread &thread);
QString pidForGroupId(const QString &groupId) const;
void updateThread(const ThreadData &threadData);
void updateThreads(const GdbMi &data);
void setThreads(const GdbMi &data);
void removeThread(const QString &id);
void removeAll();