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)
|
if (!m_stackNeeded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
reloadStack(false); // Will trigger register reload.
|
|
||||||
|
|
||||||
if (supportsThreads()) {
|
if (supportsThreads()) {
|
||||||
if (m_isMacGdb || m_gdbVersion < 70100) {
|
if (m_isMacGdb || m_gdbVersion < 70100) {
|
||||||
postCommand("-thread-list-ids", Discardable, CB(handleThreadListIds));
|
postCommand("-thread-list-ids", Discardable, CB(handleThreadListIds));
|
||||||
@@ -1777,7 +1775,6 @@ void GdbEngine::handleStop2()
|
|||||||
postCommand("-thread-info", Discardable, CB(handleThreadInfo));
|
postCommand("-thread-info", Discardable, CB(handleThreadInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleInfoProc(const GdbResponse &response)
|
void GdbEngine::handleInfoProc(const GdbResponse &response)
|
||||||
@@ -3644,13 +3641,21 @@ void GdbEngine::handleStackSelectFrame(const GdbResponse &response)
|
|||||||
void GdbEngine::handleThreadInfo(const GdbResponse &response)
|
void GdbEngine::handleThreadInfo(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
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.
|
updateViews(); // Adjust Threads combobox.
|
||||||
if (m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) {
|
if (m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) {
|
||||||
postCommand("threadnames " +
|
postCommand("threadnames " +
|
||||||
debuggerCore()->action(MaximalStackDepth)->value().toByteArray(),
|
debuggerCore()->action(MaximalStackDepth)->value().toByteArray(),
|
||||||
Discardable, CB(handleThreadNames));
|
Discardable, CB(handleThreadNames));
|
||||||
}
|
}
|
||||||
|
reloadStack(false); // Will trigger register reload.
|
||||||
} else {
|
} else {
|
||||||
// Fall back for older versions: Try to get at least a list
|
// Fall back for older versions: Try to get at least a list
|
||||||
// of running threads.
|
// of running threads.
|
||||||
@@ -3669,6 +3674,7 @@ void GdbEngine::handleThreadListIds(const GdbResponse &response)
|
|||||||
thread.id = ThreadId(items.at(index).data().toInt());
|
thread.id = ThreadId(items.at(index).data().toInt());
|
||||||
handler->updateThread(thread);
|
handler->updateThread(thread);
|
||||||
}
|
}
|
||||||
|
reloadStack(false); // Will trigger register reload.
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleThreadNames(const GdbResponse &response)
|
void GdbEngine::handleThreadNames(const GdbResponse &response)
|
||||||
|
|||||||
@@ -419,6 +419,18 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
|||||||
// 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"},
|
||||||
// state="stopped",core="0"}],current-thread-id="1"
|
// 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 QList<GdbMi> items = data.findChild("threads").children();
|
||||||
const int n = items.size();
|
const int n = items.size();
|
||||||
for (int index = 0; index != n; ++index) {
|
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());
|
thread.name = QString::fromLatin1(frame.findChild("name").data());
|
||||||
if (thread.state == QLatin1String("running"))
|
if (thread.state == QLatin1String("running"))
|
||||||
thread.stopped = false;
|
thread.stopped = false;
|
||||||
|
if (thread.id == currentId)
|
||||||
|
m_currentIndex = index;
|
||||||
updateThread(thread);
|
updateThread(thread);
|
||||||
}
|
}
|
||||||
const GdbMi current = data.findChild("current-thread-id");
|
|
||||||
if (current.isValid())
|
if (m_currentIndex != -1)
|
||||||
setCurrentThread(ThreadId(current.data().toLongLong()));
|
dataChanged(m_currentIndex);
|
||||||
|
|
||||||
updateThreadBox();
|
updateThreadBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user