Debugger: Streamline ThreadHandler

- Use the TreeItem/data pattern recently introduced with Breakpoints
  to remove the need of keeping track of id/object mapping. Opens
  possibility to have thread groups as intermediate level.
- Use the ThreadHandler directly as model for the thread combobox
  to remove the need of manual combo box updates.
- Move setting current thread from individual engines to central code.

Change-Id: I030e21a4aa5ab30b0efbc84528d9cecf29cbbe30
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2018-08-15 17:28:00 +02:00
parent 7dcfe86c34
commit 9f9c72302f
15 changed files with 258 additions and 366 deletions

View File

@@ -1239,14 +1239,9 @@ void CdbEngine::updateAll()
updateLocals();
}
void CdbEngine::selectThread(ThreadId threadId)
void CdbEngine::selectThread(const Thread &thread)
{
if (!threadId.isValid() || threadId == threadsHandler()->currentThread())
return;
threadsHandler()->setCurrentThread(threadId);
runCommand({'~' + QString::number(threadId.raw()) + " s", BuiltinCommand,
runCommand({'~' + thread->id() + " s", BuiltinCommand,
[this](const DebuggerResponse &) { reloadFullStack(); }});
}
@@ -1809,7 +1804,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
// Further examine stop and report to user
QString message;
QString exceptionBoxMessage;
ThreadId forcedThreadId;
Thread forcedThread;
const unsigned stopFlags = examineStopReason(stopReason, &message, &exceptionBoxMessage,
conditionalBreakPointTriggered);
m_stopMode = NoStopRequested;
@@ -1847,7 +1842,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
if (stopFlags & StopInArtificialThread) {
showMessage(tr("Switching to main thread..."), LogMisc);
runCommand({"~0 s", NoFlags});
forcedThreadId = ThreadId(0);
forcedThread = Thread();
// Re-fetch stack again.
reloadFullStack();
} else {
@@ -1872,8 +1867,8 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
const GdbMi threads = stopReason["threads"];
if (threads.isValid()) {
threadsHandler()->updateThreads(threads);
if (forcedThreadId.isValid())
threadsHandler()->setCurrentThread(forcedThreadId);
if (forcedThread)
threadsHandler()->setCurrentThread(forcedThread);
} else {
showMessage(stopReason["threaderror"].data(), LogError);
}