forked from qt-creator/qt-creator
dumpers: fix two regressions in std::string and general pointer checking
Change-Id: I971ff4ad425e291c3536bc25ae6ee4933e46a681 Reviewed-on: http://codereview.qt.nokia.com/3957 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -443,6 +443,12 @@ def checkPointer(p, align = 1):
|
||||
if not isNull(p):
|
||||
p.dereference()
|
||||
|
||||
def isAccessible(p):
|
||||
try:
|
||||
long(p)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def isNull(p):
|
||||
# The following can cause evaluation to abort with "UnicodeEncodeError"
|
||||
@@ -454,7 +460,11 @@ def isNull(p):
|
||||
# return p.cast(lookupType("void").pointer()) == 0
|
||||
#except:
|
||||
# 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([
|
||||
"QBrush", "QBitArray", "QByteArray", "QCustomTypeInfo", "QChar", "QDate",
|
||||
@@ -1128,6 +1138,11 @@ class Dumper:
|
||||
# in SubItem.__exit__().
|
||||
self.putBetterType(" ")
|
||||
|
||||
def putInaccessible(self):
|
||||
#self.putBetterType(" ")
|
||||
self.putNumChild(0)
|
||||
self.currentValue = None
|
||||
|
||||
def putBetterType(self, type, priority = 0):
|
||||
self.currentType = str(type)
|
||||
self.currentTypePriority = self.currentTypePriority + 1
|
||||
@@ -1211,7 +1226,7 @@ class Dumper:
|
||||
return True
|
||||
if isSimpleType(type):
|
||||
return True
|
||||
return self.stripNamespaceFromType(type) in movableTypes
|
||||
return self.stripNamespaceFromType(str(type)) in movableTypes
|
||||
|
||||
def putIntItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
@@ -1332,6 +1347,11 @@ class Dumper:
|
||||
if type.code == PointerCode:
|
||||
#warn("POINTER: %s" % value)
|
||||
|
||||
if not isAccessible(value):
|
||||
self.currentValue = None
|
||||
self.putNumChild(0)
|
||||
return
|
||||
|
||||
if isNull(value):
|
||||
#warn("NULL POINTER")
|
||||
self.putAddress(value.address)
|
||||
|
||||
@@ -51,8 +51,15 @@ def qdump__QChar(d, value):
|
||||
d.putNumChild(0)
|
||||
|
||||
|
||||
def qform__QModelIndex():
|
||||
return "Normal,Enhanced"
|
||||
|
||||
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.
|
||||
try:
|
||||
ri = makeValue(d.ns + "QModelIndex", "-1, -1, 0, 0")
|
||||
@@ -86,7 +93,14 @@ def qdump__QAbstractItemModel(d, value):
|
||||
#d.putType(mi.type)
|
||||
#gdb.execute("call free($ri)")
|
||||
|
||||
def qform__QModelIndex():
|
||||
return "Normal,Enhanced"
|
||||
|
||||
def qdump__QModelIndex(d, value):
|
||||
format = d.currentItemFormat()
|
||||
if format == 1:
|
||||
d.putPlainChildren(value)
|
||||
return
|
||||
r = value["r"]
|
||||
c = value["c"]
|
||||
p = value["p"]
|
||||
@@ -681,6 +695,7 @@ def qdump__QObject(d, value):
|
||||
if privateType is None:
|
||||
d.putNumChild(4)
|
||||
#d.putValue(cleanAddress(value.address))
|
||||
d.putPlainChildren(value)
|
||||
if d.isExpanded():
|
||||
with Children(d):
|
||||
d.putFields(value)
|
||||
@@ -688,6 +703,9 @@ def qdump__QObject(d, value):
|
||||
#warn("OBJECTNAME: %s " % objectName)
|
||||
#warn("D_PTR: %s " % d_ptr)
|
||||
mo = d_ptr["metaObject"]
|
||||
if not isAccessible(mo):
|
||||
d.putInaccessible()
|
||||
return
|
||||
if isNull(mo):
|
||||
mo = staticMetaObject
|
||||
#warn("MO: %s " % mo)
|
||||
@@ -1807,7 +1825,7 @@ def qdump__std__stack(d, value):
|
||||
def qdump__std__string(d, value):
|
||||
data = value["_M_dataplus"]["_M_p"]
|
||||
baseType = value.type.unqualified().strip_typedefs()
|
||||
if baseType.code == ReferenceType:
|
||||
if baseType.code == ReferenceCode:
|
||||
baseType = baseType.target().unqualified().strip_typedefs()
|
||||
# We might encounter 'std::string' or 'std::basic_string<>'
|
||||
# or even 'std::locale::string' on MinGW due to some type lookup glitch.
|
||||
|
||||
Reference in New Issue
Block a user