Commit 23b4c3fe authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger: Show current thread correctly in reply to thread-info.

Reviewed-by: hjk
parent 560c054f
......@@ -2963,8 +2963,8 @@ void GdbEngine::handleThreadInfo(const GdbResponse &response)
threads.append(thread);
}
threadsHandler()->setThreads(threads);
int currentIndex = response.data.findChild("current-thread-id").data().toInt();
threadsHandler()->setCurrentThread(currentIndex);
const int currentThreadId = response.data.findChild("current-thread-id").data().toInt();
threadsHandler()->setCurrentThreadId(currentThreadId);
} else {
// Fall back for older versions: Try to get at least a list
// of running threads.
......@@ -2974,24 +2974,18 @@ void GdbEngine::handleThreadInfo(const GdbResponse &response)
void GdbEngine::handleThreadListIds(const GdbResponse &response)
{
int id = response.cookie.toInt();
const int id = response.cookie.toInt();
// "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
// In gdb 7.1+ additionally: current-thread-id="1"
const QList<GdbMi> items = response.data.findChild("thread-ids").children();
Threads threads;
int currentIndex = -1;
for (int index = 0, n = items.size(); index != n; ++index) {
ThreadData thread;
thread.id = items.at(index).data().toInt();
threads.append(thread);
if (thread.id == id) {
//qDebug() << "SETTING INDEX TO:" << index << " ID:"
// << id << " RECOD:" << response.toString();
currentIndex = index;
}
}
threadsHandler()->setThreads(threads);
threadsHandler()->setCurrentThread(currentIndex);
threadsHandler()->setCurrentThreadId(id);
}
......
......@@ -187,6 +187,25 @@ void ThreadsHandler::setCurrentThread(int index)
emit dataChanged(i, i);
}
void ThreadsHandler::setCurrentThreadId(int id)
{
const int index = indexOf(id);
if (index != -1) {
setCurrentThread(index);
} else {
qWarning("ThreadsHandler::setCurrentThreadId: No such thread %d.", id);
}
}
int ThreadsHandler::indexOf(int threadId) const
{
const int count = m_threads.size();
for(int i = 0; i < count; i++)
if (m_threads.at(i).id == threadId)
return i;
return -1;
}
void ThreadsHandler::setThreads(const Threads &threads)
{
m_threads = threads;
......
......@@ -97,7 +97,10 @@ public:
explicit ThreadsHandler(DebuggerEngine *engine);
int currentThreadId() const;
void setCurrentThreadId(int id);
void setCurrentThread(int index);
int indexOf(int threadId) const;
void selectThread(int index);
void setThreads(const Threads &threads);
void removeAll();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment