forked from qt-creator/qt-creator
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:
@@ -1002,7 +1002,7 @@ void CdbEngine::handleThreads(const DebuggerResponse &response)
|
|||||||
qPrintable(DebuggerResponse::stringFromResultClass(response.resultClass)));
|
qPrintable(DebuggerResponse::stringFromResultClass(response.resultClass)));
|
||||||
}
|
}
|
||||||
if (response.resultClass == ResultDone) {
|
if (response.resultClass == ResultDone) {
|
||||||
threadsHandler()->updateThreads(response.data);
|
threadsHandler()->setThreads(response.data);
|
||||||
// Continue sequence
|
// Continue sequence
|
||||||
reloadFullStack();
|
reloadFullStack();
|
||||||
} else {
|
} else {
|
||||||
@@ -1866,7 +1866,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
}
|
}
|
||||||
const GdbMi threads = stopReason["threads"];
|
const GdbMi threads = stopReason["threads"];
|
||||||
if (threads.isValid()) {
|
if (threads.isValid()) {
|
||||||
threadsHandler()->updateThreads(threads);
|
threadsHandler()->setThreads(threads);
|
||||||
if (forcedThread)
|
if (forcedThread)
|
||||||
threadsHandler()->setCurrentThread(forcedThread);
|
threadsHandler()->setCurrentThread(forcedThread);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -2983,12 +2983,7 @@ void GdbEngine::handleThreadInfo(const DebuggerResponse &response)
|
|||||||
{
|
{
|
||||||
if (response.resultClass == ResultDone) {
|
if (response.resultClass == ResultDone) {
|
||||||
ThreadsHandler *handler = threadsHandler();
|
ThreadsHandler *handler = threadsHandler();
|
||||||
handler->updateThreads(response.data);
|
handler->setThreads(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);
|
|
||||||
}
|
|
||||||
updateState(false); // Adjust Threads combobox.
|
updateState(false); // Adjust Threads combobox.
|
||||||
if (boolSetting(ShowThreadNames)) {
|
if (boolSetting(ShowThreadNames)) {
|
||||||
runCommand({"threadnames " + action(MaximalStackDepth)->value().toString(),
|
runCommand({"threadnames " + action(MaximalStackDepth)->value().toString(),
|
||||||
|
@@ -656,7 +656,7 @@ void LldbEngine::updateAll()
|
|||||||
{
|
{
|
||||||
DebuggerCommand cmd("fetchThreads");
|
DebuggerCommand cmd("fetchThreads");
|
||||||
cmd.callback = [this](const DebuggerResponse &response) {
|
cmd.callback = [this](const DebuggerResponse &response) {
|
||||||
threadsHandler()->updateThreads(response.data);
|
threadsHandler()->setThreads(response.data);
|
||||||
fetchStack(action(MaximalStackDepth)->value().toInt());
|
fetchStack(action(MaximalStackDepth)->value().toInt());
|
||||||
reloadRegisters();
|
reloadRegisters();
|
||||||
};
|
};
|
||||||
|
@@ -282,12 +282,6 @@ Thread ThreadsHandler::currentThread() const
|
|||||||
return m_currentThread;
|
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)
|
void ThreadsHandler::setCurrentThread(const Thread &thread)
|
||||||
{
|
{
|
||||||
if (thread == m_currentThread)
|
if (thread == m_currentThread)
|
||||||
@@ -368,8 +362,10 @@ void ThreadsHandler::notifyStopped(const QString &id)
|
|||||||
thread->notifyStopped();
|
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)",
|
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
|
||||||
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
||||||
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
||||||
@@ -396,6 +392,9 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
|||||||
|
|
||||||
const QString ¤tId = data["current-thread-id"].data();
|
const QString ¤tId = data["current-thread-id"].data();
|
||||||
m_currentThread = threadForId(currentId);
|
m_currentThread = threadForId(currentId);
|
||||||
|
|
||||||
|
if (!m_currentThread && !items.isEmpty())
|
||||||
|
m_currentThread = rootItem()->childAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel *ThreadsHandler::model()
|
QAbstractItemModel *ThreadsHandler::model()
|
||||||
|
@@ -79,13 +79,12 @@ public:
|
|||||||
|
|
||||||
int currentThreadIndex() const;
|
int currentThreadIndex() const;
|
||||||
Thread currentThread() const;
|
Thread currentThread() const;
|
||||||
Thread threadAt(int index) const;
|
|
||||||
Thread threadForId(const QString &id) const;
|
Thread threadForId(const QString &id) const;
|
||||||
void setCurrentThread(const Thread &thread);
|
void setCurrentThread(const Thread &thread);
|
||||||
QString pidForGroupId(const QString &groupId) const;
|
QString pidForGroupId(const QString &groupId) const;
|
||||||
|
|
||||||
void updateThread(const ThreadData &threadData);
|
void updateThread(const ThreadData &threadData);
|
||||||
void updateThreads(const GdbMi &data);
|
void setThreads(const GdbMi &data);
|
||||||
|
|
||||||
void removeThread(const QString &id);
|
void removeThread(const QString &id);
|
||||||
void removeAll();
|
void removeAll();
|
||||||
|
Reference in New Issue
Block a user