From 623de07ab9cc956ee4203c9823fdc58520f4515f Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 26 Feb 2015 08:39:40 +0100 Subject: [PATCH] Debugger: Streamline GdbMi structure interface Change-Id: If9c4d1ae8b05a5dae7d6a1a7534e49d1966dd493 Reviewed-by: Christian Stenger --- src/plugins/debugger/cdb/cdbengine.cpp | 2 +- src/plugins/debugger/debuggerprotocol.cpp | 5 ++-- src/plugins/debugger/debuggerprotocol.h | 30 +++++++++-------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 1c0a01527a0..f5954d0e638 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -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 diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 7621f31ae23..26b0ad1d60e 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -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 diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index 73aa8201b57..3214fdb76e0 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -138,32 +138,23 @@ public: QByteArray m_data; std::vector 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 &children() const { return m_children; } - inline int childCount() const { return int(m_children.size()); } + const QByteArray &data() const { return m_data; } + const std::vector &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; };