forked from qt-creator/qt-creator
debugger: switch to another thread if the current one is dead
Change-Id: I5d7d4a6c6430487296bfc32cdb00dd40d50a025b Reviewed-by: Matthias Blaicher <matthias@blaicher.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -1767,8 +1767,6 @@ void GdbEngine::handleStop2()
|
||||
if (!m_stackNeeded)
|
||||
return;
|
||||
|
||||
reloadStack(false); // Will trigger register reload.
|
||||
|
||||
if (supportsThreads()) {
|
||||
if (m_isMacGdb || m_gdbVersion < 70100) {
|
||||
postCommand("-thread-list-ids", Discardable, CB(handleThreadListIds));
|
||||
@@ -1777,7 +1775,6 @@ void GdbEngine::handleStop2()
|
||||
postCommand("-thread-info", Discardable, CB(handleThreadInfo));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GdbEngine::handleInfoProc(const GdbResponse &response)
|
||||
@@ -3644,13 +3641,21 @@ void GdbEngine::handleStackSelectFrame(const GdbResponse &response)
|
||||
void GdbEngine::handleThreadInfo(const GdbResponse &response)
|
||||
{
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
threadsHandler()->updateThreads(response.data);
|
||||
ThreadsHandler *handler = threadsHandler();
|
||||
handler->updateThreads(response.data);
|
||||
// This is necessary as the current thread might not be in the list.
|
||||
if (!handler->currentThread().isValid()) {
|
||||
ThreadId other = handler->threadAt(0);
|
||||
if (other.isValid())
|
||||
selectThread(other);
|
||||
}
|
||||
updateViews(); // Adjust Threads combobox.
|
||||
if (m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) {
|
||||
postCommand("threadnames " +
|
||||
debuggerCore()->action(MaximalStackDepth)->value().toByteArray(),
|
||||
Discardable, CB(handleThreadNames));
|
||||
}
|
||||
reloadStack(false); // Will trigger register reload.
|
||||
} else {
|
||||
// Fall back for older versions: Try to get at least a list
|
||||
// of running threads.
|
||||
@@ -3669,6 +3674,7 @@ void GdbEngine::handleThreadListIds(const GdbResponse &response)
|
||||
thread.id = ThreadId(items.at(index).data().toInt());
|
||||
handler->updateThread(thread);
|
||||
}
|
||||
reloadStack(false); // Will trigger register reload.
|
||||
}
|
||||
|
||||
void GdbEngine::handleThreadNames(const GdbResponse &response)
|
||||
|
||||
@@ -419,6 +419,18 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
||||
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
||||
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
|
||||
// state="stopped",core="0"}],current-thread-id="1"
|
||||
|
||||
// Emit changed for previous frame.
|
||||
if (m_currentIndex != -1) {
|
||||
dataChanged(m_currentIndex);
|
||||
m_currentIndex = -1;
|
||||
}
|
||||
|
||||
ThreadId currentId;
|
||||
const GdbMi current = data.findChild("current-thread-id");
|
||||
if (current.isValid())
|
||||
currentId = ThreadId(current.data().toLongLong());
|
||||
|
||||
const QList<GdbMi> items = data.findChild("threads").children();
|
||||
const int n = items.size();
|
||||
for (int index = 0; index != n; ++index) {
|
||||
@@ -441,11 +453,14 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
||||
thread.name = QString::fromLatin1(frame.findChild("name").data());
|
||||
if (thread.state == QLatin1String("running"))
|
||||
thread.stopped = false;
|
||||
if (thread.id == currentId)
|
||||
m_currentIndex = index;
|
||||
updateThread(thread);
|
||||
}
|
||||
const GdbMi current = data.findChild("current-thread-id");
|
||||
if (current.isValid())
|
||||
setCurrentThread(ThreadId(current.data().toLongLong()));
|
||||
|
||||
if (m_currentIndex != -1)
|
||||
dataChanged(m_currentIndex);
|
||||
|
||||
updateThreadBox();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user