Debugger: Make Gdbmi threads parsing code re-usable.

Adapt watchutils code for new engine.

Acked-by: hjk
This commit is contained in:
Friedemann Kleint
2010-11-08 17:15:33 +01:00
parent c0303faa9e
commit 4ac2634de7
4 changed files with 51 additions and 28 deletions

View File

@@ -28,6 +28,7 @@
**************************************************************************/
#include "threadshandler.h"
#include "gdb/gdbmi.h"
#include "debuggerconstants.h"
@@ -254,5 +255,37 @@ void ThreadsHandler::notifyRunning()
index(m_threads.size() - 1, ThreadData::ColumnCount - 1));
}
Threads ThreadsHandler::parseGdbmiThreads(const GdbMi &data, int *currentThread)
{
// ^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 = data.findChild("threads").children();
const int n = items.size();
Threads threads;
threads.reserve(n);
for (int index = 0; 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 = QString::fromAscii(item.findChild("target-id").data());
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();
// Non-GDB (Cdb2) output name here.
thread.name = frame.findChild("name").data().toInt();
threads.append(thread);
}
if (currentThread)
*currentThread = data.findChild("current-thread-id").data().toInt();
return threads;
}
} // namespace Internal
} // namespace Debugger