debugger: gather more information on threads when easily available

This commit is contained in:
hjk
2010-05-17 17:38:31 +02:00
parent 5d5eeed6c0
commit 2f69bae63f
7 changed files with 71 additions and 23 deletions

View File

@@ -1464,10 +1464,12 @@ void GdbEngine::handleStop1(const GdbMi &data)
if (supportsThreads()) {
int currentId = data.findChild("thread-id").data().toInt();
if (m_gdbAdapter->isTrkAdapter())
if (m_gdbAdapter->isTrkAdapter()) {
m_gdbAdapter->trkReloadThreads();
else
postCommand("-thread-list-ids", CB(handleStackListThreads), currentId);
} else {
// This is only available in gdb 7.1+.
postCommand("-thread-info", CB(handleThreadInfo), currentId);
}
}
//
@@ -2966,10 +2968,47 @@ void GdbEngine::handleStackSelectFrame(const GdbResponse &response)
reloadRegisters();
}
void GdbEngine::handleStackListThreads(const GdbResponse &response)
void GdbEngine::handleThreadInfo(const GdbResponse &response)
{
int id = response.cookie.toInt();
if (response.resultClass == GdbResultDone) {
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
// file="/.../app.cpp",fullname="/../app.cpp",line="1175"},
// state="stopped",core="0"}],current-thread-id="1"
const QList<GdbMi> items = response.data.findChild("threads").children();
QList<ThreadData> threads;
for (int index = 0, n = items.size(); index != n; ++index) {
bool ok = false;
const GdbMi item = items.at(index);
const GdbMi frame = item.findChild("frame");
ThreadData thread;
thread.id = item.findChild("id").data().toInt();
thread.targetId = item.findChild("target-id").data().toInt();
thread.core = QString::fromLatin1(item.findChild("core").data());
thread.state = QString::fromLatin1(item.findChild("state").data());
thread.address = frame.findChild("addr").data().toULongLong(&ok, 0);
thread.function = QString::fromLatin1(frame.findChild("func").data());
thread.fileName = QString::fromLatin1(frame.findChild("fullname").data());
thread.lineNumber = frame.findChild("line").data().toInt();
threads.append(thread);
}
ThreadsHandler *threadsHandler = manager()->threadsHandler();
threadsHandler->setThreads(threads);
int currentIndex = response.data.findChild("current-thread-id").data().toInt();
threadsHandler->setCurrentThread(currentIndex);
} else {
// Fall back for older versions: Try to get at least a list
// of running threads.
postCommand("-thread-list-ids", CB(handleThreadListIds), id);
}
}
void GdbEngine::handleThreadListIds(const GdbResponse &response)
{
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();
QList<ThreadData> threads;
int currentIndex = -1;