Commit b6835eaa authored by hjk's avatar hjk Committed by hjk
Browse files

dumpers: fix two regressions in std::string and general pointer checking

Change-Id: I971ff4ad425e291c3536bc25ae6ee4933e46a681
Reviewed-on: http://codereview.qt.nokia.com/3957

Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent fb807825
...@@ -443,6 +443,12 @@ def checkPointer(p, align = 1): ...@@ -443,6 +443,12 @@ def checkPointer(p, align = 1):
if not isNull(p): if not isNull(p):
p.dereference() p.dereference()
def isAccessible(p):
try:
long(p)
return True
except:
return False
def isNull(p): def isNull(p):
# The following can cause evaluation to abort with "UnicodeEncodeError" # The following can cause evaluation to abort with "UnicodeEncodeError"
...@@ -454,7 +460,11 @@ def isNull(p): ...@@ -454,7 +460,11 @@ def isNull(p):
# return p.cast(lookupType("void").pointer()) == 0 # return p.cast(lookupType("void").pointer()) == 0
#except: #except:
# return False # return False
return long(p) == 0 try:
# Can fail with: "RuntimeError: Cannot access memory at address 0x5"
return long(p) == 0
except:
return False
movableTypes = set([ movableTypes = set([
"QBrush", "QBitArray", "QByteArray", "QCustomTypeInfo", "QChar", "QDate", "QBrush", "QBitArray", "QByteArray", "QCustomTypeInfo", "QChar", "QDate",
...@@ -1128,6 +1138,11 @@ class Dumper: ...@@ -1128,6 +1138,11 @@ class Dumper:
# in SubItem.__exit__(). # in SubItem.__exit__().
self.putBetterType(" ") self.putBetterType(" ")
def putInaccessible(self):
#self.putBetterType(" ")
self.putNumChild(0)
self.currentValue = None
def putBetterType(self, type, priority = 0): def putBetterType(self, type, priority = 0):
self.currentType = str(type) self.currentType = str(type)
self.currentTypePriority = self.currentTypePriority + 1 self.currentTypePriority = self.currentTypePriority + 1
...@@ -1211,7 +1226,7 @@ class Dumper: ...@@ -1211,7 +1226,7 @@ class Dumper:
return True return True
if isSimpleType(type): if isSimpleType(type):
return True return True
return self.stripNamespaceFromType(type) in movableTypes return self.stripNamespaceFromType(str(type)) in movableTypes
def putIntItem(self, name, value): def putIntItem(self, name, value):
with SubItem(self, name): with SubItem(self, name):
...@@ -1332,6 +1347,11 @@ class Dumper: ...@@ -1332,6 +1347,11 @@ class Dumper:
if type.code == PointerCode: if type.code == PointerCode:
#warn("POINTER: %s" % value) #warn("POINTER: %s" % value)
if not isAccessible(value):
self.currentValue = None
self.putNumChild(0)
return
if isNull(value): if isNull(value):
#warn("NULL POINTER") #warn("NULL POINTER")
self.putAddress(value.address) self.putAddress(value.address)
......
...@@ -51,8 +51,15 @@ def qdump__QChar(d, value): ...@@ -51,8 +51,15 @@ def qdump__QChar(d, value):
d.putNumChild(0) d.putNumChild(0)
def qform__QModelIndex():
return "Normal,Enhanced"
def qdump__QAbstractItemModel(d, value): def qdump__QAbstractItemModel(d, value):
format = d.currentItemFormat()
if format == 1:
d.putPlainChildren(value)
return
#format == 2:
# Create a default-constructed QModelIndex on the stack. # Create a default-constructed QModelIndex on the stack.
try: try:
ri = makeValue(d.ns + "QModelIndex", "-1, -1, 0, 0") ri = makeValue(d.ns + "QModelIndex", "-1, -1, 0, 0")
...@@ -86,7 +93,14 @@ def qdump__QAbstractItemModel(d, value): ...@@ -86,7 +93,14 @@ def qdump__QAbstractItemModel(d, value):
#d.putType(mi.type) #d.putType(mi.type)
#gdb.execute("call free($ri)") #gdb.execute("call free($ri)")
def qform__QModelIndex():
return "Normal,Enhanced"
def qdump__QModelIndex(d, value): def qdump__QModelIndex(d, value):
format = d.currentItemFormat()
if format == 1:
d.putPlainChildren(value)
return
r = value["r"] r = value["r"]
c = value["c"] c = value["c"]
p = value["p"] p = value["p"]
...@@ -681,6 +695,7 @@ def qdump__QObject(d, value): ...@@ -681,6 +695,7 @@ def qdump__QObject(d, value):
if privateType is None: if privateType is None:
d.putNumChild(4) d.putNumChild(4)
#d.putValue(cleanAddress(value.address)) #d.putValue(cleanAddress(value.address))
d.putPlainChildren(value)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
d.putFields(value) d.putFields(value)
...@@ -688,6 +703,9 @@ def qdump__QObject(d, value): ...@@ -688,6 +703,9 @@ def qdump__QObject(d, value):
#warn("OBJECTNAME: %s " % objectName) #warn("OBJECTNAME: %s " % objectName)
#warn("D_PTR: %s " % d_ptr) #warn("D_PTR: %s " % d_ptr)
mo = d_ptr["metaObject"] mo = d_ptr["metaObject"]
if not isAccessible(mo):
d.putInaccessible()
return
if isNull(mo): if isNull(mo):
mo = staticMetaObject mo = staticMetaObject
#warn("MO: %s " % mo) #warn("MO: %s " % mo)
...@@ -1807,7 +1825,7 @@ def qdump__std__stack(d, value): ...@@ -1807,7 +1825,7 @@ def qdump__std__stack(d, value):
def qdump__std__string(d, value): def qdump__std__string(d, value):
data = value["_M_dataplus"]["_M_p"] data = value["_M_dataplus"]["_M_p"]
baseType = value.type.unqualified().strip_typedefs() baseType = value.type.unqualified().strip_typedefs()
if baseType.code == ReferenceType: if baseType.code == ReferenceCode:
baseType = baseType.target().unqualified().strip_typedefs() baseType = baseType.target().unqualified().strip_typedefs()
# We might encounter 'std::string' or 'std::basic_string<>' # We might encounter 'std::string' or 'std::basic_string<>'
# or even 'std::locale::string' on MinGW due to some type lookup glitch. # or even 'std::locale::string' on MinGW due to some type lookup glitch.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment