summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2010-07-06 12:43:48 +0200
committerhjk <qtc-committer@nokia.com>2010-07-06 12:44:32 +0200
commitbcdcbc2f70f0bac1b14a9fe603a27eb3399a3e3a (patch)
tree5ed084b0719203dc94b092e896d62e92fc9e5a23 /share
parentd7dd4e9373ee3d60ece61a03f75ff46690ea7dc7 (diff)
downloadqt-creator-bcdcbc2f70f0bac1b14a9fe603a27eb3399a3e3a.tar.gz
debugger: backport small fixes and synchronized code layout with master
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/gdbmacros/dumper.py81
1 files changed, 63 insertions, 18 deletions
diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py
index ea771f839a..e7d8853e4e 100644
--- a/share/qtcreator/gdbmacros/dumper.py
+++ b/share/qtcreator/gdbmacros/dumper.py
@@ -1,7 +1,4 @@
from __future__ import with_statement
-#Note: Keep name-type-value-numchild-extra order
-
-#return
import sys
import gdb
@@ -9,6 +6,7 @@ import base64
import __builtin__
import os
+
# Fails on Windows.
try:
import curses.ascii
@@ -128,6 +126,9 @@ def lookupType(typestring):
typeCache[typestring] = type
return type
+def cleanType(type):
+ return lookupType(str(type))
+
def cleanAddress(addr):
if addr is None:
return "<no address>"
@@ -240,9 +241,9 @@ class SubItem:
if len(type) > 0 and type != self.d.currentChildType:
self.d.put('type="%s",' % type) # str(type.unqualified()) ?
if not self.d.currentValueEncoding is None:
- self.d.putField("valueencoded", self.d.currentValueEncoding)
+ self.d.put('valueencoded="%d",' % self.d.currentValueEncoding)
if not self.d.currentValue is None:
- self.d.putField("value", self.d.currentValue)
+ self.d.put('value="%s",' % self.d.currentValue)
except:
pass
self.d.put('},')
@@ -423,6 +424,8 @@ def listOfLocals(varList):
hasBlock = 'block' in __builtin__.dir(frame)
items = []
+ #warn("HAS BLOCK: %s" % hasBlock);
+ #warn("IS GOOD GDB: %s" % isGoodGdb());
if hasBlock and isGoodGdb():
#warn("IS GOOD: %s " % varList)
try:
@@ -783,8 +786,8 @@ def encodeString(value):
p += 1
return s
-def stripTypedefs(typeobj):
- type = typeobj
+def stripTypedefs(type):
+ type = type.unqualified()
while type.code == gdb.TYPE_CODE_TYPEDEF:
type = type.strip_typedefs().unqualified()
return type
@@ -822,12 +825,56 @@ class Item:
#######################################################################
#
+# SetupCommand
+#
+#######################################################################
+
+# This is a mapping from 'type name' to 'display alternatives'.
+
+qqDumpers = {}
+qqFormats = {}
+
+
+class SetupCommand(gdb.Command):
+ """Setup Creator Pretty Printing"""
+
+ def __init__(self):
+ super(SetupCommand, self).__init__("bbsetup", gdb.COMMAND_OBSCURE)
+
+ def invoke(self, args, from_tty):
+ module = sys.modules[__name__]
+ for key, value in module.__dict__.items():
+ if key.startswith("qdump__"):
+ name = key[7:]
+ qqDumpers[name] = value
+ qqFormats[name] = qqFormats.get(name, "");
+ elif key.startswith("qform__"):
+ name = key[7:]
+ formats = ""
+ try:
+ formats = value()
+ except:
+ pass
+ qqFormats[name] = formats
+ result = "dumpers=["
+ # Too early: ns = qtNamespace()
+ for key, value in qqFormats.items():
+ result += '{type="%s",formats="%s"},' % (key, value)
+ result += ']'
+ #result += '],namespace="%s"' % ns
+ print(result)
+
+SetupCommand()
+
+
+#######################################################################
+#
# FrameCommand
#
#######################################################################
class FrameCommand(gdb.Command):
- """Do fancy stuff. Usage bb --verbose expandedINames"""
+ """Do fancy stuff."""
def __init__(self):
super(FrameCommand, self).__init__("bb", gdb.COMMAND_OBSCURE)
@@ -1109,15 +1156,16 @@ class Dumper:
def childRange(self):
return xrange(qmin(self.currentMaxNumChilds, self.currentNumChilds))
- # convenience
+ # Convenience function.
def putItemCount(self, count):
- self.put('value="<%s items>",' % count)
+ # This needs to override the default value, so don't use 'put' directly.
+ self.putValue('<%s items>' % count)
def putEllipsis(self):
self.put('{name="<incomplete>",value="",type="",numchild="0"},')
def putType(self, type, priority = 0):
- # higher priority values override lower ones
+ # Higher priority values override lower ones.
if priority >= self.currentTypePriority:
self.currentType = type
self.currentTypePriority = priority
@@ -1131,7 +1179,7 @@ class Dumper:
self.put('numchild="%s",' % numchild)
def putValue(self, value, encoding = None, priority = 0):
- # higher priority values override lower ones
+ # Higher priority values override lower ones.
if priority >= self.currentValuePriority:
self.currentValue = value
self.currentValuePriority = priority
@@ -1267,9 +1315,6 @@ class Dumper:
value = item.value
type = value.type
- if type.code == gdb.TYPE_CODE_TYPEDEF:
- type = type.target()
-
typedefStrippedType = stripTypedefs(type);
nsStrippedType = self.stripNamespaceFromType(
typedefStrippedType).replace("::", "__")
@@ -1423,8 +1468,8 @@ class Dumper:
charptr = lookupType("unsigned char").pointer()
addr1 = (baseptr+1).cast(charptr)
addr0 = baseptr.cast(charptr)
- self.putField("addrbase" % cleanAddress(addr0))
- self.putField("addrstep" % (addr1 - addr0))
+ self.put('addrbase="%s",' % cleanAddress(addr0))
+ self.put('addrstep="%s",' % (addr1 - addr0))
innerType = None
if len(fields) == 1 and fields[0].name is None:
@@ -1468,7 +1513,7 @@ class Dumper:
item.iname, "@%d" % baseNumber, field.name)
baseNumber += 1
with SubItem(self):
- self.putField("iname", child.iname)
+ self.put('iname="%s",' % child.iname)
self.putItemHelper(child)
elif len(field.name) == 0:
# Anonymous union. We need a dummy name to distinguish