Commit 4794cbf0 authored by hjk's avatar hjk

debugger: rename 'magic' prefix for custom dumper from qqDump to qdump__

It is nicer in the presence of namespaces as '::' will be replaced by '__'
to create the dumper function names.
parent 15ee71b3
...@@ -214,10 +214,10 @@ class FrameCommand(gdb.Command): ...@@ -214,10 +214,10 @@ class FrameCommand(gdb.Command):
if useFancy == -1: if useFancy == -1:
output = "dumpers=[" output = "dumpers=["
for key, value in module.__dict__.items(): for key, value in module.__dict__.items():
if key.startswith("qqDump"): if key.startswith("qdump__"):
if output != "dumpers=[": if output != "dumpers=[":
output += "," output += ","
output += '"' + key[6:] + '"' output += '"' + key[7:] + '"'
output += "]," output += "],"
#output += "qtversion=[%d,%d,%d]" #output += "qtversion=[%d,%d,%d]"
output += "qtversion=[4,6,0]," output += "qtversion=[4,6,0],"
...@@ -233,8 +233,8 @@ class FrameCommand(gdb.Command): ...@@ -233,8 +233,8 @@ class FrameCommand(gdb.Command):
if useFancy: if useFancy:
for key, value in module.__dict__.items(): for key, value in module.__dict__.items():
#if callable(value): #if callable(value):
if key.startswith("qqDump"): if key.startswith("qdump__"):
self.dumpers[key[6:]] = value self.dumpers[key[7:]] = value
d = Dumper() d = Dumper()
d.dumpers = self.dumpers d.dumpers = self.dumpers
...@@ -298,7 +298,7 @@ class FrameCommand(gdb.Command): ...@@ -298,7 +298,7 @@ class FrameCommand(gdb.Command):
d.beginChildren(n) d.beginChildren(n)
for i in xrange(0, n): for i in xrange(0, n):
value = p.dereference() value = p.dereference()
d.putItemOrPointer(Item(value, item.iname, i, None)) d.putItem(Item(value, item.iname, i, None))
p += 1 p += 1
if n > 100: if n > 100:
d.putEllipsis() d.putEllipsis()
...@@ -506,7 +506,6 @@ class Dumper: ...@@ -506,7 +506,6 @@ class Dumper:
str = encodeByteArray(value) str = encodeByteArray(value)
self.putCommaIfNeeded() self.putCommaIfNeeded()
self.put('valueencoded="%d",value="%s"' % (6, str)) self.put('valueencoded="%d",value="%s"' % (6, str))
def putName(self, name): def putName(self, name):
self.putCommaIfNeeded() self.putCommaIfNeeded()
...@@ -530,6 +529,11 @@ class Dumper: ...@@ -530,6 +529,11 @@ class Dumper:
self.output = self.output[0:pos] self.output = self.output[0:pos]
def stripNamespaceFromType(self, typeobj): def stripNamespaceFromType(self, typeobj):
# This breaks for dumpers type names containing '__star'.
# But this should not happen as identifiers containing two
# subsequent underscores are reserved for the implemention.
if typeobj.code == gdb.TYPE_CODE_PTR:
return self.stripNamespaceFromType(typeobj.target()) + "__star"
# FIXME: pass ns from plugin # FIXME: pass ns from plugin
type = stripClassTag(str(typeobj)) type = stripClassTag(str(typeobj))
if len(self.ns) > 0 and type.startswith(self.ns): if len(self.ns) > 0 and type.startswith(self.ns):
...@@ -571,6 +575,11 @@ class Dumper: ...@@ -571,6 +575,11 @@ class Dumper:
if isSimpleType(item.value.type): if isSimpleType(item.value.type):
self.safePutItemHelper(item) self.safePutItemHelper(item)
def safePutItem(self, item):
self.beginHash()
self.safePutItemHelper(item)
self.endHash()
def safePutItemHelper(self, item): def safePutItemHelper(self, item):
self.pushOutput() self.pushOutput()
# This is only used at the top level to ensure continuation # This is only used at the top level to ensure continuation
...@@ -608,26 +617,21 @@ class Dumper: ...@@ -608,26 +617,21 @@ class Dumper:
self.safePutItemHelper(item) self.safePutItemHelper(item)
self.endHash() self.endHash()
def putItemOrPointer(self, item):
self.beginHash()
self.putItemOrPointerHelper(item)
self.endHash()
def putCallItem(self, name, item, func): def putCallItem(self, name, item, func):
result = call(item.value, func) result = call(item.value, func)
self.putItem(Item(result, item.iname, name, name)) self.putItem(Item(result, item.iname, name, name))
def putItemOrPointerHelper(self, item): #def putItemOrPointerHelper(self, item):
if item.value.type.code == gdb.TYPE_CODE_PTR \ # if item.value.type.code == gdb.TYPE_CODE_PTR \
and str(item.value.type.target()) != "char": # and str(item.value.type.target()) != "char":
if not isNull(item.value): # if not isNull(item.value):
self.putItemOrPointerHelper( # self.putItemOrPointerHelper(
Item(item.value.dereference(), item.iname, None, None)) # Item(item.value.dereference(), item.iname, None, None))
else: # else:
self.putValue("(null)") # self.putValue("(null)")
self.putNumChild(0) # self.putNumChild(0)
else: # else:
self.safePutItemHelper(item) # self.safePutItemHelper(item)
def putItemHelper(self, item): def putItemHelper(self, item):
...@@ -635,7 +639,6 @@ class Dumper: ...@@ -635,7 +639,6 @@ class Dumper:
if not name is None: if not name is None:
self.putName(name) self.putName(name)
self.putType(item.value.type)
# FIXME: Gui shows references stripped? # FIXME: Gui shows references stripped?
#warn("REAL INAME: %s " % item.iname) #warn("REAL INAME: %s " % item.iname)
#warn("REAL TYPE: %s " % item.value.type) #warn("REAL TYPE: %s " % item.value.type)
...@@ -659,61 +662,76 @@ class Dumper: ...@@ -659,61 +662,76 @@ class Dumper:
#warn(" DUMPERS: %s" % (strippedType in self.dumpers)) #warn(" DUMPERS: %s" % (strippedType in self.dumpers))
if isSimpleType(type): if isSimpleType(type):
#warn("IS SIMPLE: %s " % type)
self.putType(item.value.type)
self.putValue(value) self.putValue(value)
self.putNumChild(0) self.putNumChild(0)
elif strippedType in self.dumpers: elif strippedType in self.dumpers:
#warn("IS DUMPABLE: %s " % type)
self.putType(item.value.type)
self.dumpers[strippedType](self, item) self.dumpers[strippedType](self, item)
elif type.code == gdb.TYPE_CODE_ENUM: elif type.code == gdb.TYPE_CODE_ENUM:
#warn("GENERIC ENUM: %s" % value) #warn("GENERIC ENUM: %s" % value)
self.putType(item.value.type)
self.putValue(value) self.putValue(value)
self.putNumChild(0) self.putNumChild(0)
elif type.code == gdb.TYPE_CODE_PTR: elif type.code == gdb.TYPE_CODE_PTR:
isHandled = False if self.useFancy:
#warn("GENERIC POINTER: %s" % value) #warn("A POINTER: %s" % value.type)
if isNull(value): isHandled = False
self.putValue("0x0") if isNull(value):
self.putNumChild(0) self.putValue("0x0")
isHandled = True self.putType(item.value.type)
self.putNumChild(0)
target = str(type.target().unqualified()) isHandled = True
if target == "char" and not isHandled:
# Display values up to given length directly target = str(type.target().unqualified())
firstNul = -1 if target == "void" and not isHandled:
p = value self.putType(item.value.type)
for i in xrange(0, 100): self.putValue(str(value))
if p.dereference() == 0: self.putNumChild(0)
# Found terminating NUL isHandled = True
self.putField("valueencoded", "6")
self.put(',value="') if target == "char" and not isHandled:
self.put(encodeCharArray(value, i)) # Display values up to given length directly
self.put('"') self.putType(item.value.type)
self.putNumChild(0) firstNul = -1
isHandled = True p = value
return for i in xrange(0, 100):
p += 1 if p.dereference() == 0:
# Found terminating NUL
if not isHandled: self.putValue(encodeCharArray(value, i), "6")
# Generic pointer type. self.putNumChild(0)
#warn("GENERIC POINTER: %s" % value) isHandled = True
if self.isExpanded(item): break
#warn("GENERIC POINTER: %s" % item.value.type.target()) p += 1
self.put(',')
# Temporary change to target type. if not isHandled:
## Generic pointer type.
#warn("GENERIC POINTER: %s" % value)
innerType = item.value.type.target()
self.putType(innerType)
self.childTypes.append( self.childTypes.append(
stripClassTag(str(item.value.type.target()))) stripClassTag(str(innerType)))
self.putItemOrPointerHelper( #self.putType(item.value.type.target())
self.putItemHelper(
Item(item.value.dereference(), item.iname, None, None)) Item(item.value.dereference(), item.iname, None, None))
self.childTypes.pop() self.childTypes.pop()
else: else:
self.putValue(str(value.address)) self.putType(item.value.type)
self.putNumChild(1) self.putValue(str(value.address))
self.putNumChild(1)
if self.isExpanded(item):
self.beginChildren()
self.putItem(
Item(item.value.dereference(), item.iname, "*", "*"))
self.endChildren()
else: else:
#warn("COMMON TYPE: %s " % value.type)
#warn("INAME: %s " % item.iname) #warn("INAME: %s " % item.iname)
#warn("INAMES: %s " % self.expandedINames) #warn("INAMES: %s " % self.expandedINames)
#warn("EXPANDED: %s " % (item.iname in self.expandedINames)) #warn("EXPANDED: %s " % (item.iname in self.expandedINames))
...@@ -722,6 +740,7 @@ class Dumper: ...@@ -722,6 +740,7 @@ class Dumper:
#fields = value.type.fields() #fields = value.type.fields()
fields = value.type.strip_typedefs().fields() fields = value.type.strip_typedefs().fields()
self.putType(item.value.type)
self.putValue("{...}") self.putValue("{...}")
if False: if False:
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
####################################################################### #######################################################################
def qqDumpQByteArray(d, item): def qdump__QByteArray(d, item):
d.putByteArrayValue(item.value) d.putByteArrayValue(item.value)
d_ptr = item.value['d'].dereference() d_ptr = item.value['d'].dereference()
...@@ -28,14 +28,14 @@ def qqDumpQByteArray(d, item): ...@@ -28,14 +28,14 @@ def qqDumpQByteArray(d, item):
d.endChildren() d.endChildren()
def qqDumpQChar(d, item): def qdump__QChar(d, item):
ucs = int(item.value["ucs"]) ucs = int(item.value["ucs"])
c = select(curses.ascii.isprint(ucs), ucs, '?') c = select(curses.ascii.isprint(ucs), ucs, '?')
d.putValue("'%c' (%d)" % (c, ucs)) d.putValue("'%c' (%d)" % (c, ucs))
d.putNumChild(0) d.putNumChild(0)
def qqDumpQAbstractItem(d, item): def qdump__QAbstractItem(d, item):
r = item.value["r"] r = item.value["r"]
c = item.value["c"] c = item.value["c"]
p = item.value["p"] p = item.value["p"]
...@@ -70,7 +70,7 @@ def qqDumpQAbstractItem(d, item): ...@@ -70,7 +70,7 @@ def qqDumpQAbstractItem(d, item):
d.endChildren() d.endChildren()
def qqDumpQAbstractItemModel(d, item): def qdump__QAbstractItemModel(d, item):
rowCount = call(item.value, "rowCount()") rowCount = call(item.value, "rowCount()")
if rowCount < 0: if rowCount < 0:
return return
...@@ -102,7 +102,7 @@ def qqDumpQAbstractItemModel(d, item): ...@@ -102,7 +102,7 @@ def qqDumpQAbstractItemModel(d, item):
d.endChildren() d.endChildren()
def qqDumpQDateTime(d, item): def qdump__QDateTime(d, item):
d.putStringValue(call(item.value, "toString(%sQt::TextDate)" % d.ns)) d.putStringValue(call(item.value, "toString(%sQt::TextDate)" % d.ns))
d.putNumChild(3) d.putNumChild(3)
if d.isExpanded(item): if d.isExpanded(item):
...@@ -124,7 +124,7 @@ def qqDumpQDateTime(d, item): ...@@ -124,7 +124,7 @@ def qqDumpQDateTime(d, item):
d.endChildren() d.endChildren()
def qqDumpQDir(d, item): def qdump__QDir(d, item):
d.putStringValue(call(item.value, "path()")) d.putStringValue(call(item.value, "path()"))
d.putNumChild(2) d.putNumChild(2)
if d.isExpanded(item): if d.isExpanded(item):
...@@ -134,7 +134,7 @@ def qqDumpQDir(d, item): ...@@ -134,7 +134,7 @@ def qqDumpQDir(d, item):
d.endChildren() d.endChildren()
def qqDumpQFile(d, item): def qdump__QFile(d, item):
d.putStringValue(call(item.value, "fileName()")) d.putStringValue(call(item.value, "fileName()"))
d.putNumChild(2) d.putNumChild(2)
if d.isExpanded(item): if d.isExpanded(item):
...@@ -144,7 +144,7 @@ def qqDumpQFile(d, item): ...@@ -144,7 +144,7 @@ def qqDumpQFile(d, item):
d.endChildren() d.endChildren()
def qqDumpQFileInfo(d, item): def qdump__QFileInfo(d, item):
d.putStringValue(call(item.value, "filePath()")) d.putStringValue(call(item.value, "filePath()"))
d.putNumChild(3) d.putNumChild(3)
if d.isExpanded(item): if d.isExpanded(item):
...@@ -214,7 +214,7 @@ def qqDumpQFileInfo(d, item): ...@@ -214,7 +214,7 @@ def qqDumpQFileInfo(d, item):
d.endChildren() d.endChildren()
def qqDumpQFlags(d, item): def qdump__QFlags(d, item):
#warn("QFLAGS: %s" % item.value) #warn("QFLAGS: %s" % item.value)
i = item.value["i"] i = item.value["i"]
enumType = item.value.type.template_argument(0) enumType = item.value.type.template_argument(0)
...@@ -223,7 +223,7 @@ def qqDumpQFlags(d, item): ...@@ -223,7 +223,7 @@ def qqDumpQFlags(d, item):
d.putNumChild(0) d.putNumChild(0)
def qqDumpQHash(d, item): def qdump__QHash(d, item):
def hashDataFirstNode(value): def hashDataFirstNode(value):
value = value.cast(hashDataType) value = value.cast(hashDataType)
...@@ -294,7 +294,7 @@ def qqDumpQHash(d, item): ...@@ -294,7 +294,7 @@ def qqDumpQHash(d, item):
d.endChildren() d.endChildren()
def qqDumpQHashNode(d, item): def qdump__QHashNode(d, item):
keyType = item.value.type.template_argument(0) keyType = item.value.type.template_argument(0)
valueType = item.value.type.template_argument(1) valueType = item.value.type.template_argument(1)
key = item.value["key"] key = item.value["key"]
...@@ -319,7 +319,7 @@ def qqDumpQHashNode(d, item): ...@@ -319,7 +319,7 @@ def qqDumpQHashNode(d, item):
d.endChildren() d.endChildren()
def qqDumpQList(d, item): def qdump__QList(d, item):
d_ptr = item.value["d"] d_ptr = item.value["d"]
begin = d_ptr["begin"] begin = d_ptr["begin"]
end = d_ptr["end"] end = d_ptr["end"]
...@@ -364,21 +364,11 @@ def qqDumpQList(d, item): ...@@ -364,21 +364,11 @@ def qqDumpQList(d, item):
inner = innerType inner = innerType
d.beginChildren(n, inner) d.beginChildren(n, inner)
for i in xrange(0, n): for i in xrange(0, n):
if innerTypeIsPointer: if isInternal:
if isNull(p.dereference()): d.putItem(Item(p.dereference(), item.iname, i, None))
d.beginHash()
d.putValue("(null)")
d.putNumChild(0)
d.putType(p.dereference().type)
d.endHash()
else:
d.putItemOrPointer(Item(p.dereference(), item.iname, i, None))
else: else:
if isInternal: pp = p.cast(innerType.pointer().pointer()).dereference()
d.putItem(Item(p.dereference(), item.iname, i, None)) d.putItem(Item(pp.dereference(), item.iname, i, None))
else:
pp = p.cast(innerType.pointer().pointer()).dereference()
d.putItem(Item(pp.dereference(), item.iname, i, None))
p += 1 p += 1
if n < end - begin: if n < end - begin:
...@@ -386,7 +376,7 @@ def qqDumpQList(d, item): ...@@ -386,7 +376,7 @@ def qqDumpQList(d, item):
d.endChildren() d.endChildren()
def qqDumpQImage(d, item): def qdump__QImage(d, item):
painters = item.value["painters"] painters = item.value["painters"]
#warn("PAINTERS: %s" % painters) #warn("PAINTERS: %s" % painters)
check(0 <= painters and painters < 1000) check(0 <= painters and painters < 1000)
...@@ -406,7 +396,7 @@ def qqDumpQImage(d, item): ...@@ -406,7 +396,7 @@ def qqDumpQImage(d, item):
# d.endChildren() # d.endChildren()
def qqDumpQImageData(d, item): def qdump__QImageData(d, item):
pass pass
# const QImage &im = *reinterpret_cast<const QImage *>(d.data) # const QImage &im = *reinterpret_cast<const QImage *>(d.data)
# const QByteArray ba(QByteArray::fromRawData((const char*)im.bits(), im.numBytes())) # const QByteArray ba(QByteArray::fromRawData((const char*)im.bits(), im.numBytes()))
...@@ -422,7 +412,7 @@ def qqDumpQImageData(d, item): ...@@ -422,7 +412,7 @@ def qqDumpQImageData(d, item):
# #endif # #endif
def qqDumpQLinkedList(d, item): def qdump__QLinkedList(d, item):
d_ptr = item.value["d"] d_ptr = item.value["d"]
e_ptr = item.value["e"] e_ptr = item.value["e"]
nn = d_ptr["size"] nn = d_ptr["size"]
...@@ -440,14 +430,14 @@ def qqDumpQLinkedList(d, item): ...@@ -440,14 +430,14 @@ def qqDumpQLinkedList(d, item):
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
p = e_ptr["n"] p = e_ptr["n"]
for i in xrange(0, n): for i in xrange(0, n):
d.putItemOrPointer(Item(p["t"], None, None, None)) d.safePutItem(Item(p["t"], None, None, None))
p = p["n"] p = p["n"]
if n < nn: if n < nn:
d.putEllipsis() d.putEllipsis()
d.endChildren() d.endChildren()
def qqDumpQLocale(d, item): def qdump__QLocale(d, item):
d.putStringValue(call(item.value, "name()")) d.putStringValue(call(item.value, "name()"))
d.putNumChild(8) d.putNumChild(8)
if d.isExpanded(item): if d.isExpanded(item):
...@@ -469,7 +459,7 @@ def qqDumpQLocale(d, item): ...@@ -469,7 +459,7 @@ def qqDumpQLocale(d, item):
d.endChildren() d.endChildren()
def qqDumpQMapNode(d, item): def qdump__QMapNode(d, item):
d.putValue(" ") d.putValue(" ")
d.putNumChild(2) d.putNumChild(2)
if d.isExpanded(item): if d.isExpanded(item):
...@@ -485,7 +475,7 @@ def qqDumpQMapNode(d, item): ...@@ -485,7 +475,7 @@ def qqDumpQMapNode(d, item):
d.endChildren() d.endChildren()
def qqDumpQMap(d, item): def qdump__QMap(d, item):
d_ptr = item.value["d"].dereference() d_ptr = item.value["d"].dereference()
e_ptr = item.value["e"].dereference() e_ptr = item.value["e"].dereference()
n = d_ptr["size"] n = d_ptr["size"]
...@@ -536,11 +526,11 @@ def qqDumpQMap(d, item): ...@@ -536,11 +526,11 @@ def qqDumpQMap(d, item):
d.endChildren() d.endChildren()
def qqDumpMultiMap(d, item): def qdump__MultiMap(d, item):
qqDumpMap(d, item) qdump__Map(d, item)
def qqDumpQModelIndex(d, item): def qdump__QModelIndex(d, item):
r = item.value["r"] r = item.value["r"]
c = item.value["c"] c = item.value["c"]
p = item.value["p"] p = item.value["p"]
...@@ -577,7 +567,7 @@ def extractCString(table, offset): ...@@ -577,7 +567,7 @@ def extractCString(table, offset):
return result return result
def qqDumpQObject(d, item): def qdump__QObject(d, item):
#warn("OBJECT: %s " % item.value) #warn("OBJECT: %s " % item.value)
staticMetaObject = item.value["staticMetaObject"] staticMetaObject = item.value["staticMetaObject"]
#warn("SMO: %s " % staticMetaObject) #warn("SMO: %s " % staticMetaObject)
...@@ -1309,7 +1299,7 @@ def qqDumpQObject(d, item): ...@@ -1309,7 +1299,7 @@ def qqDumpQObject(d, item):
# #endif // QT_BOOTSTRAPPED # #endif // QT_BOOTSTRAPPED