Debugger: Streamline GdbMi structure interface

Change-Id: If9c4d1ae8b05a5dae7d6a1a7534e49d1966dd493
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-26 08:39:40 +01:00
parent 1c59dd1837
commit 623de07ab9
3 changed files with 15 additions and 22 deletions

View File

@@ -1874,7 +1874,7 @@ void CdbEngine::handleLocals(const CdbCommandPtr &reply, int flags)
} }
GdbMi root; GdbMi root;
root.fromString(reply->extensionReply); root.fromString(reply->extensionReply);
QTC_ASSERT(root.isList(), return); QTC_ASSERT(root.type() == GdbMi::List, return);
if (debugLocals) if (debugLocals)
qDebug() << root.toString(true, 4); qDebug() << root.toString(true, 4);
// Courtesy of GDB engine // Courtesy of GDB engine

View File

@@ -366,12 +366,13 @@ void GdbMi::fromStringMultiple(const QByteArray &ba)
parseTuple_helper(from, to); 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) for (int i = 0, n = int(m_children.size()); i < n; ++i)
if (m_children.at(i).m_name == name) if (m_children.at(i).m_name == name)
return m_children.at(i); return m_children.at(i);
return GdbMi(); return empty;
} }
qulonglong GdbMi::toAddress() const qulonglong GdbMi::toAddress() const

View File

@@ -138,32 +138,23 @@ public:
QByteArray m_data; QByteArray m_data;
std::vector<GdbMi> m_children; std::vector<GdbMi> m_children;
enum Type { enum Type { Invalid, Const, Tuple, List };
Invalid,
Const,
Tuple,
List
};
Type m_type; Type m_type;
inline Type type() const { return m_type; } Type type() const { return m_type; }
inline QByteArray name() const { return m_name; } const QByteArray &name() const { return m_name; }
inline bool hasName(const char *name) const { return m_name == name; } bool hasName(const char *name) const { return m_name == name; }
inline bool isValid() const { return m_type != Invalid; } bool isValid() const { return m_type != Invalid; }
inline bool isConst() const { return m_type == Const; } bool isList() const { return m_type == List; }
inline bool isTuple() const { return m_type == Tuple; }
inline bool isList() const { return m_type == List; }
const QByteArray &data() const { return m_data; }
inline QByteArray data() const { return m_data; } const std::vector<GdbMi> &children() const { return m_children; }
inline const std::vector<GdbMi> &children() const { return m_children; } int childCount() const { return int(m_children.size()); }
inline int childCount() const { return int(m_children.size()); }
const GdbMi &childAt(int index) const { return m_children[index]; } const GdbMi &childAt(int index) const { return m_children[index]; }
GdbMi &childAt(int index) { return m_children[index]; } const GdbMi &operator[](const char *name) const;
GdbMi operator[](const char *name) const;
QByteArray toString(bool multiline = false, int indent = 0) const; QByteArray toString(bool multiline = false, int indent = 0) const;
qulonglong toAddress() const; qulonglong toAddress() const;
@@ -181,6 +172,7 @@ public:
void parseTuple_helper(const char *&from, const char *to); void parseTuple_helper(const char *&from, const char *to);
void parseList(const char *&from, const char *to); void parseList(const char *&from, const char *to);
private:
void dumpChildren(QByteArray *str, bool multiline, int indent) const; void dumpChildren(QByteArray *str, bool multiline, int indent) const;
}; };