forked from qt-creator/qt-creator
Debugger: Decrease dependency of protocol structures on Qt
For potential re-use in qtcreatorcdbextension. Change-Id: Ia5742b61c71fcd04eeaa894ed62218151d528a53 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -233,7 +233,7 @@ void GdbMi::parseTuple_helper(const char *&from, const char *to)
|
||||
//qDebug() << "\n=======\n" << qPrintable(child.toString()) << "\n========\n";
|
||||
if (!child.isValid())
|
||||
return;
|
||||
m_children += child;
|
||||
m_children.push_back(child);
|
||||
skipCommas(from, to);
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ void GdbMi::parseList(const char *&from, const char *to)
|
||||
GdbMi child;
|
||||
child.parseResultOrValue(from, to);
|
||||
if (child.isValid())
|
||||
m_children += child;
|
||||
m_children.push_back(child);
|
||||
skipCommas(from, to);
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ static QByteArray ind(int indent)
|
||||
|
||||
void GdbMi::dumpChildren(QByteArray * str, bool multiline, int indent) const
|
||||
{
|
||||
for (int i = 0; i < m_children.size(); ++i) {
|
||||
for (size_t i = 0; i < m_children.size(); ++i) {
|
||||
if (i != 0) {
|
||||
*str += ',';
|
||||
if (multiline)
|
||||
@@ -743,30 +743,6 @@ void DebuggerCommand::argHelper(const char *name, const QByteArray &data)
|
||||
args.append(",");
|
||||
}
|
||||
|
||||
QByteArray DebuggerCommand::toData(const QList<QByteArray> &value)
|
||||
{
|
||||
QByteArray res;
|
||||
foreach (const QByteArray &item, value) {
|
||||
if (!res.isEmpty())
|
||||
res.append(',');
|
||||
res += item;
|
||||
}
|
||||
return '[' + res + ']';
|
||||
}
|
||||
|
||||
QByteArray DebuggerCommand::toData(const QHash<QByteArray, QByteArray> &value)
|
||||
{
|
||||
QByteArray res;
|
||||
QHashIterator<QByteArray, QByteArray> it(value);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!res.isEmpty())
|
||||
res.append(',');
|
||||
res += '"' + it.key() + "\":" + it.value();
|
||||
}
|
||||
return '{' + res + '}';
|
||||
}
|
||||
|
||||
void DebuggerCommand::arg(const char *name, int value)
|
||||
{
|
||||
argHelper(name, QByteArray::number(value));
|
||||
|
||||
@@ -31,9 +31,11 @@
|
||||
#ifndef DEBUGGER_PROTOCOL_H
|
||||
#define DEBUGGER_PROTOCOL_H
|
||||
|
||||
#include <QTime>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
@@ -67,13 +69,10 @@ public:
|
||||
void beginGroup(const char *name = 0);
|
||||
void endGroup();
|
||||
|
||||
static QByteArray toData(const QList<QByteArray> &value);
|
||||
static QByteArray toData(const QHash<QByteArray, QByteArray> &value);
|
||||
|
||||
QByteArray function;
|
||||
QByteArray args;
|
||||
Callback callback;
|
||||
QTime postTime;
|
||||
uint postTime; // msecsSinceStartOfDay
|
||||
int flags;
|
||||
|
||||
private:
|
||||
@@ -137,7 +136,7 @@ public:
|
||||
|
||||
QByteArray m_name;
|
||||
QByteArray m_data;
|
||||
QList<GdbMi> m_children;
|
||||
std::vector<GdbMi> m_children;
|
||||
|
||||
enum Type {
|
||||
Invalid,
|
||||
@@ -159,7 +158,7 @@ public:
|
||||
|
||||
|
||||
inline QByteArray data() const { return m_data; }
|
||||
inline const QList<GdbMi> &children() const { return m_children; }
|
||||
inline const std::vector<GdbMi> &children() const { return m_children; }
|
||||
inline int childCount() const { return m_children.size(); }
|
||||
|
||||
const GdbMi &childAt(int index) const { return m_children[index]; }
|
||||
|
||||
@@ -420,7 +420,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
||||
data.parseResultOrValue(from, to);
|
||||
if (data.isValid()) {
|
||||
//qDebug() << "parsed result:" << data.toString();
|
||||
result.m_children += data;
|
||||
result.m_children.push_back(data);
|
||||
result.m_type = GdbMi::Tuple;
|
||||
}
|
||||
}
|
||||
@@ -944,7 +944,7 @@ void GdbEngine::flushCommand(const DebuggerCommand &cmd0)
|
||||
const int token = ++currentToken();
|
||||
|
||||
DebuggerCommand cmd = cmd0;
|
||||
cmd.postTime = QTime::currentTime();
|
||||
cmd.postTime = QTime::currentTime().msecsSinceStartOfDay();
|
||||
m_commandForToken[token] = cmd;
|
||||
if (cmd.flags & ConsoleCommand)
|
||||
cmd.function = "-interpreter-exec console \"" + cmd.function + '"';
|
||||
@@ -1119,7 +1119,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
|
||||
if (boolSetting(LogTimeStamps)) {
|
||||
showMessage(_("Response time: %1: %2 s")
|
||||
.arg(_(cmd.function))
|
||||
.arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.),
|
||||
.arg(QTime::fromMSecsSinceStartOfDay(cmd.postTime).msecsTo(QTime::currentTime()) / 1000.),
|
||||
LogTime);
|
||||
}
|
||||
|
||||
@@ -3441,8 +3441,8 @@ void GdbEngine::handleThreadListIds(const DebuggerResponse &response)
|
||||
// "72^done,{thread-ids={thread-id="2",thread-id="1"},number-of-threads="2"}
|
||||
// In gdb 7.1+ additionally: current-thread-id="1"
|
||||
ThreadsHandler *handler = threadsHandler();
|
||||
const QList<GdbMi> items = response.data["thread-ids"].children();
|
||||
for (int index = 0, n = items.size(); index != n; ++index) {
|
||||
const std::vector<GdbMi> &items = response.data["thread-ids"].children();
|
||||
for (size_t index = 0, n = items.size(); index != n; ++index) {
|
||||
ThreadData thread;
|
||||
thread.id = ThreadId(items.at(index).toInt());
|
||||
handler->updateThread(thread);
|
||||
@@ -3896,7 +3896,7 @@ void GdbEngine::handleFetchMemory(const DebuggerResponse &response, MemoryAgentC
|
||||
if (response.resultClass == ResultDone) {
|
||||
GdbMi memory = response.data["memory"];
|
||||
QTC_ASSERT(memory.children().size() <= 1, return);
|
||||
if (memory.children().isEmpty())
|
||||
if (memory.children().empty())
|
||||
return;
|
||||
GdbMi memory0 = memory.children().at(0); // we asked for only one 'row'
|
||||
GdbMi data = memory0["data"];
|
||||
|
||||
@@ -461,10 +461,10 @@ void ThreadsHandler::updateThreads(const GdbMi &data)
|
||||
// m_currentIndex = -1;
|
||||
// }
|
||||
|
||||
const QList<GdbMi> items = data["threads"].children();
|
||||
const std::vector<GdbMi> &items = data["threads"].children();
|
||||
const int n = items.size();
|
||||
for (int index = 0; index != n; ++index) {
|
||||
const GdbMi item = items.at(index);
|
||||
const GdbMi item = items[index];
|
||||
const GdbMi frame = item["frame"];
|
||||
ThreadData thread;
|
||||
thread.id = ThreadId(item["id"].toInt());
|
||||
|
||||
Reference in New Issue
Block a user