forked from qt-creator/qt-creator
Debugger: Make Gdbmi threads parsing code re-usable.
Adapt watchutils code for new engine. Acked-by: hjk
This commit is contained in:
@@ -2964,30 +2964,9 @@ 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();
|
||||
Threads 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 = 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();
|
||||
threads.append(thread);
|
||||
}
|
||||
int currentThreadId;
|
||||
const Threads threads= ThreadsHandler::parseGdbmiThreads(response.data, ¤tThreadId);
|
||||
threadsHandler()->setThreads(threads);
|
||||
const int currentThreadId =
|
||||
response.data.findChild("current-thread-id").data().toInt();
|
||||
threadsHandler()->setCurrentThreadId(currentThreadId);
|
||||
updateViews(); // Adjust Threads combobox.
|
||||
if (m_hasInferiorThreadList) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class GdbMi;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ThreadsHandler
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
// Clear out all frame information
|
||||
void notifyRunning();
|
||||
|
||||
static Threads parseGdbmiThreads(const GdbMi &data, int *currentThread = 0);
|
||||
|
||||
private:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
@@ -1522,10 +1522,19 @@ bool QtDumperHelper::parseValue(const char *data, QList<WatchData> *l)
|
||||
{
|
||||
l->clear();
|
||||
GdbMi root;
|
||||
root.fromStringMultiple(QByteArray(data));
|
||||
if (!root.isValid())
|
||||
return false;
|
||||
gbdMiToWatchData(root, GdbMiRecursionContext(), l);
|
||||
// Array (CDB2)
|
||||
if (*data == '[') {
|
||||
root.fromString(data);
|
||||
if (!root.isValid())
|
||||
return false;
|
||||
foreach(const GdbMi &child, root.children())
|
||||
gbdMiToWatchData(child, GdbMiRecursionContext(), l);
|
||||
} else {
|
||||
root.fromStringMultiple(QByteArray(data));
|
||||
if (!root.isValid())
|
||||
return false;
|
||||
gbdMiToWatchData(root, GdbMiRecursionContext(), l);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user