OSDN Git Service

Debugger[CDB]: Make error message more verbose.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 22 Mar 2011 15:09:12 +0000 (16:09 +0100)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 22 Mar 2011 15:09:12 +0000 (16:09 +0100)
Task-number: QTCREATORBUG-4185

src/libs/qtcreatorcdbext/symbolgroupvalue.cpp

index 6982c00..ff917fc 100644 (file)
@@ -89,14 +89,37 @@ bool SymbolGroupValue::isValid() const
     return m_node != 0 && m_context.dataspaces != 0;
 }
 
+// Debug helper
+static void formatNodeError(const AbstractSymbolGroupNode *n, std::ostream &os)
+{
+    const AbstractSymbolGroupNode::AbstractSymbolGroupNodePtrVector &children = n->children();
+    const VectorIndexType size = children.size();
+    if (const SymbolGroupNode *sn = n->asSymbolGroupNode()) {
+        os << "type: " << sn->type() << ", raw value: \"" << wStringToString(sn->symbolGroupRawValue())
+           << "\", 0x" << std::hex << sn->address() << ", " << std::dec;
+    }
+    if (size) {
+        os << "children (" << size << "): [";
+        for (VectorIndexType i = 0; i < size; i++)
+            os << ' ' << children.at(i)->name();
+        os << ']';
+    } else {
+        os << "No children";
+    }
+}
+
 SymbolGroupValue SymbolGroupValue::operator[](unsigned index) const
 {
     if (ensureExpanded())
         if (index < m_node->children().size())
             if (SymbolGroupNode *n = m_node->childAt(index)->asSymbolGroupNode())
                 return SymbolGroupValue(n, m_context);
-    if (isValid() && SymbolGroupValue::verbose)
-        DebugPrint() << name() << "::operator[" << index << "](const char*) failed.";
+    if (isValid() && SymbolGroupValue::verbose) {
+        DebugPrint dp;
+        dp << name() << "::operator[](#" << index << ") failed. ";
+        if (m_node)
+            formatNodeError(m_node, dp);
+    }
     return SymbolGroupValue(m_errorMessage);
 }
 
@@ -125,8 +148,12 @@ SymbolGroupValue SymbolGroupValue::operator[](const char *name) const
         if (AbstractSymbolGroupNode *child = m_node->childByIName(name))
             if (SymbolGroupNode *n = child->asSymbolGroupNode())
                 return SymbolGroupValue(n, m_context);
-    if (isValid() && SymbolGroupValue::verbose) // Do not report subsequent errors
-        DebugPrint() << this->name() << "::operator[](" << name << ") failed.";
+    if (isValid() && SymbolGroupValue::verbose) { // Do not report subsequent errors
+        DebugPrint dp;
+        dp << this->name() << "::operator[](\"" << name << "\") failed. ";
+        if (m_node)
+            formatNodeError(m_node, dp);
+    }
     return SymbolGroupValue(m_errorMessage);
 }