Commit 623de07a authored by hjk's avatar hjk

Debugger: Streamline GdbMi structure interface

Change-Id: If9c4d1ae8b05a5dae7d6a1a7534e49d1966dd493
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 1c59dd18
......@@ -1874,7 +1874,7 @@ void CdbEngine::handleLocals(const CdbCommandPtr &reply, int flags)
}
GdbMi root;
root.fromString(reply->extensionReply);
QTC_ASSERT(root.isList(), return);
QTC_ASSERT(root.type() == GdbMi::List, return);
if (debugLocals)
qDebug() << root.toString(true, 4);
// Courtesy of GDB engine
......
......@@ -366,12 +366,13 @@ void GdbMi::fromStringMultiple(const QByteArray &ba)
parseTuple_helper(from, to);
}
GdbMi GdbMi::operator[](const char *name) const
const GdbMi &GdbMi::operator[](const char *name) const
{
static GdbMi empty;
for (int i = 0, n = int(m_children.size()); i < n; ++i)
if (m_children.at(i).m_name == name)
return m_children.at(i);
return GdbMi();
return empty;
}
qulonglong GdbMi::toAddress() const
......
......@@ -138,32 +138,23 @@ public:
QByteArray m_data;
std::vector<GdbMi> m_children;
enum Type {
Invalid,
Const,
Tuple,
List
};
enum Type { Invalid, Const, Tuple, List };
Type m_type;
inline Type type() const { return m_type; }
inline QByteArray name() const { return m_name; }
inline bool hasName(const char *name) const { return m_name == name; }
Type type() const { return m_type; }
const QByteArray &name() const { return m_name; }
bool hasName(const char *name) const { return m_name == name; }
inline bool isValid() const { return m_type != Invalid; }
inline bool isConst() const { return m_type == Const; }
inline bool isTuple() const { return m_type == Tuple; }
inline bool isList() const { return m_type == List; }
bool isValid() const { return m_type != Invalid; }
bool isList() const { return m_type == List; }
inline QByteArray data() const { return m_data; }
inline const std::vector<GdbMi> &children() const { return m_children; }
inline int childCount() const { return int(m_children.size()); }
const QByteArray &data() const { return m_data; }
const std::vector<GdbMi> &children() const { return m_children; }
int childCount() const { return int(m_children.size()); }
const GdbMi &childAt(int index) const { return m_children[index]; }
GdbMi &childAt(int index) { return m_children[index]; }
GdbMi operator[](const char *name) const;
const GdbMi &operator[](const char *name) const;
QByteArray toString(bool multiline = false, int indent = 0) const;
qulonglong toAddress() const;
......@@ -181,6 +172,7 @@ public:
void parseTuple_helper(const char *&from, const char *to);
void parseList(const char *&from, const char *to);
private:
void dumpChildren(QByteArray *str, bool multiline, int indent) const;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment