From fe03946df991501bd377d0986f01838caa940ff8 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 1 Mar 2011 15:44:22 +0100 Subject: [PATCH] debugger: Switch off address printing for generated items --- share/qtcreator/gdbmacros/dumper.py | 37 ++++++++++++++----- share/qtcreator/gdbmacros/gdbmacros.py | 17 ++++++--- .../gdbdebugger/simple/simple_gdbtest_app.cpp | 18 +++++---- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py index 6625202f094..1c7b085232d 100644 --- a/share/qtcreator/gdbmacros/dumper.py +++ b/share/qtcreator/gdbmacros/dumper.py @@ -293,6 +293,18 @@ class OutputSafer: return False +class NoAddress: + def __init__(self, d): + self.d = d + + def __enter__(self): + self.savedPrintsAddress = self.d.printsAddress + self.d.printsAddress = False + + def __exit__(self, exType, exValue, exTraceBack): + self.d.printsAddress = self.savedPrintsAddress + + class SubItem: def __init__(self, d): self.d = d @@ -1114,6 +1126,7 @@ SalCommand() class Dumper: def __init__(self, args): self.output = "" + self.printsAddress = True self.currentChildType = "" self.currentChildNumChild = -1 self.currentMaxNumChilds = -1 @@ -1402,7 +1415,8 @@ class Dumper: self.currentTypePriority = priority def putAddress(self, addr): - self.put('addr="%s",' % cleanAddress(addr)) + if self.printsAddress: + self.put('addr="%s",' % cleanAddress(addr)) def putNumChild(self, numchild): #warn("NUM CHILD: '%s' '%s'" % (numchild, self.currentChildNumChild)) @@ -1731,8 +1745,10 @@ class Dumper: innerType = realtype.target() innerTypeName = str(innerType.unqualified()) # Never dereference char types. - if innerTypeName != "char" and innerTypeName != "signed char" \ - and innerTypeName != "unsigned char" and innerTypeName != "wchar_t": + if innerTypeName != "char" \ + and innerTypeName != "signed char" \ + and innerTypeName != "unsigned char" \ + and innerTypeName != "wchar_t": self.putType(innerType) savedCurrentChildType = self.currentChildType self.currentChildType = stripClassTag(str(innerType)) @@ -1806,7 +1822,7 @@ class Dumper: with Children(self): self.putFields(item) - def putFields(self, item): + def putFields(self, item, dumpBase = True): value = item.value type = stripTypedefs(value.type) fields = extractFields(type) @@ -1844,12 +1860,13 @@ class Dumper: # Field is base type. We cannot use field.name as part # of the iname as it might contain spaces and other # strange characters. - child = Item(value.cast(field.type), - item.iname, "@%d" % baseNumber, field.name) - baseNumber += 1 - with SubItem(self): - self.put('iname="%s",' % child.iname) - self.putItem(child) + if dumpBase: + child = Item(value.cast(field.type), + item.iname, "@%d" % baseNumber, field.name) + baseNumber += 1 + with SubItem(self): + self.put('iname="%s",' % child.iname) + self.putItem(child) elif len(field.name) == 0: # Anonymous union. We need a dummy name to distinguish # multiple anonymous unions in the struct. diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py index bfbb0a90a8f..ef5a50dfbdc 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.py +++ b/share/qtcreator/gdbmacros/gdbmacros.py @@ -725,8 +725,8 @@ def qdump__QObject(d, item): iname = item.iname + ".data" if d.isExpandedIName(iname): with Children(d): - child = Item(d_ptr, item.iname) - d.putFields(child) + child = Item(d_ptr, iname) + d.putFields(child, False) d.putFields(item) @@ -803,6 +803,7 @@ def qdump__QObject(d, item): # Static properties. propertyData = metaData[7] for i in xrange(staticPropertyCount): + with NoAddress(d): with SubItem(d): offset = propertyData + 3 * i propertyName = extractCString(metaStringData, @@ -844,19 +845,22 @@ def qdump__QObject(d, item): else: # User types. - # func = "typeToName(('%sQVariant::Type')%d)" % (d.ns, variantType) + # func = "typeToName(('%sQVariant::Type')%d)" + # % (d.ns, variantType) # type = str(call(item.value, func)) # type = type[type.find('"') + 1 : type.rfind('"')] # type = type.replace("Q", d.ns + "Q") # HACK! # data = call(item.value, "constData") - # tdata = data.cast(lookupType(type).pointer()).dereference() + # tdata = data.cast(lookupType(type).pointer()) + # .dereference() # d.putValue("(%s)" % tdata.type) # d.putType(tdata.type) # d.putNumChild(1) # if d.isExpanded(item): # with Children(d): - # d.putSubItem(Item(tdata, item.iname, "data", "data")) - warn("FIXME: CUSTOM QOBJECT PROPERTIES NOT IMPLEMENTED: %s %s" + # d.putSubItem(Item(tdata, item.iname, + # "data", "data")) + warn("FIXME: CUSTOM QOBJECT PROPERTY: %s %s" % (propertyType, innert)) d.putType(propertyType) d.putValue("...") @@ -1611,6 +1615,7 @@ def qdump__QVariant(d, item): if d.isExpanded(item): with Children(d): #warn("TDATA: %s" % tdata) + with NoAddress(d): d.putSubItem(Item(tdata, item.iname, "data", "data")) return tdata.type diff --git a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp index ff6caa57bed..902f5502986 100644 --- a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp +++ b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp @@ -137,10 +137,14 @@ int z; class DerivedObjectPrivate : public QObjectPrivate { public: - DerivedObjectPrivate() : m_extraX(43), m_extraY(44) {} + DerivedObjectPrivate() + { + m_extraX = 43; + m_extraY.append("xxx"); + } int m_extraX; - int m_extraY; + QStringList m_extraY; }; class DerivedObject : public QObject @@ -153,12 +157,12 @@ public: {} Q_PROPERTY(int x READ x WRITE setX) - Q_PROPERTY(int y READ y WRITE setY) + Q_PROPERTY(QStringList y READ y WRITE setY) int x() const; void setX(int x); - int y() const; - void setY(int y); + QStringList y() const; + void setY(QStringList y); private: Q_DECLARE_PRIVATE(DerivedObject) @@ -176,13 +180,13 @@ void DerivedObject::setX(int x) d->m_extraX = x; } -int DerivedObject::y() const +QStringList DerivedObject::y() const { Q_D(const DerivedObject); return d->m_extraY; } -void DerivedObject::setY(int y) +void DerivedObject::setY(QStringList y) { Q_D(DerivedObject); d->m_extraY = y;