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();
|
int id = response.cookie.toInt();
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)",
|
int currentThreadId;
|
||||||
// frame={level="0",addr="0x080530bf",func="testQString",args=[],
|
const Threads threads= ThreadsHandler::parseGdbmiThreads(response.data, ¤tThreadId);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
threadsHandler()->setThreads(threads);
|
threadsHandler()->setThreads(threads);
|
||||||
const int currentThreadId =
|
|
||||||
response.data.findChild("current-thread-id").data().toInt();
|
|
||||||
threadsHandler()->setCurrentThreadId(currentThreadId);
|
threadsHandler()->setCurrentThreadId(currentThreadId);
|
||||||
updateViews(); // Adjust Threads combobox.
|
updateViews(); // Adjust Threads combobox.
|
||||||
if (m_hasInferiorThreadList) {
|
if (m_hasInferiorThreadList) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "threadshandler.h"
|
#include "threadshandler.h"
|
||||||
|
#include "gdb/gdbmi.h"
|
||||||
|
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
|
||||||
@@ -254,5 +255,37 @@ void ThreadsHandler::notifyRunning()
|
|||||||
index(m_threads.size() - 1, ThreadData::ColumnCount - 1));
|
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 Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
class GdbMi;
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ThreadsHandler
|
// ThreadsHandler
|
||||||
@@ -68,6 +68,8 @@ public:
|
|||||||
// Clear out all frame information
|
// Clear out all frame information
|
||||||
void notifyRunning();
|
void notifyRunning();
|
||||||
|
|
||||||
|
static Threads parseGdbmiThreads(const GdbMi &data, int *currentThread = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(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();
|
l->clear();
|
||||||
GdbMi root;
|
GdbMi root;
|
||||||
|
// 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));
|
root.fromStringMultiple(QByteArray(data));
|
||||||
if (!root.isValid())
|
if (!root.isValid())
|
||||||
return false;
|
return false;
|
||||||
gbdMiToWatchData(root, GdbMiRecursionContext(), l);
|
gbdMiToWatchData(root, GdbMiRecursionContext(), l);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user