forked from qt-creator/qt-creator
Debugger: Simplify array dumper user code
Heads up: This switches the argument order to allow a default argument for the inner type if it can be determined from the base pointer. Change-Id: I9bf80fcdd51b5db8e7c65adba551ca667912cd86 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -701,12 +701,12 @@ class DumperBase:
|
||||
|
||||
def putCStyleArray(self, value):
|
||||
type = value.type.unqualified()
|
||||
targetType = value[0].type
|
||||
innerType = value[0].type
|
||||
#self.putAddress(value.address)
|
||||
self.putType(type)
|
||||
self.putNumChild(1)
|
||||
format = self.currentItemFormat()
|
||||
isDefault = format == None and str(targetType.unqualified()) == "char"
|
||||
isDefault = format == None and str(innerType.unqualified()) == "char"
|
||||
if isDefault or format == 0 or format == 1 or format == 2:
|
||||
blob = self.readMemory(self.addressOf(value), type.sizeof)
|
||||
|
||||
@@ -724,7 +724,7 @@ class DumperBase:
|
||||
self.putValue(blob, Hex2EncodedLocal8Bit)
|
||||
else:
|
||||
try:
|
||||
self.putValue("@0x%x" % self.pointerValue(value.cast(targetType.pointer())))
|
||||
self.putValue("@0x%x" % self.pointerValue(value.cast(innerType.pointer())))
|
||||
except:
|
||||
self.putEmptyValue()
|
||||
|
||||
@@ -732,13 +732,13 @@ class DumperBase:
|
||||
try:
|
||||
# May fail on artificial items like xmm register data.
|
||||
p = self.addressOf(value)
|
||||
ts = targetType.sizeof
|
||||
if not self.tryPutArrayContents(targetType, p, int(type.sizeof / ts)):
|
||||
with Children(self, childType=targetType,
|
||||
ts = innerType.sizeof
|
||||
if not self.tryPutArrayContents(p, int(type.sizeof / ts), innerType):
|
||||
with Children(self, childType=innerType,
|
||||
addrBase=p, addrStep=ts):
|
||||
self.putFields(value)
|
||||
except:
|
||||
with Children(self, childType=targetType):
|
||||
with Children(self, childType=innerType):
|
||||
self.putFields(value)
|
||||
|
||||
def cleanAddress(self, addr):
|
||||
@@ -754,14 +754,14 @@ class DumperBase:
|
||||
warn("CANNOT CONVERT TYPE: %s" % type(addr))
|
||||
return str(addr)
|
||||
|
||||
def tryPutArrayContents(self, typeobj, base, n):
|
||||
enc = self.simpleEncoding(typeobj)
|
||||
def tryPutArrayContents(self, base, n, innerType):
|
||||
enc = self.simpleEncoding(innerType)
|
||||
if not enc:
|
||||
return False
|
||||
size = n * typeobj.sizeof;
|
||||
self.put('childtype="%s",' % typeobj)
|
||||
size = n * innerType.sizeof;
|
||||
self.put('childtype="%s",' % innerType)
|
||||
self.put('addrbase="0x%x",' % toInteger(base))
|
||||
self.put('addrstep="0x%x",' % toInteger(typeobj.sizeof))
|
||||
self.put('addrstep="0x%x",' % toInteger(innerType.sizeof))
|
||||
self.put('arrayencoding="%s",' % enc)
|
||||
self.put('arraydata="')
|
||||
self.put(self.readMemory(base, size))
|
||||
@@ -860,7 +860,7 @@ class DumperBase:
|
||||
self.putType(typeName)
|
||||
self.putItemCount(n)
|
||||
self.putNumChild(n)
|
||||
self.putArrayData(innerType, value, n)
|
||||
self.putArrayData(value, n, innerType)
|
||||
return
|
||||
|
||||
if self.isFunctionType(innerType):
|
||||
@@ -1209,8 +1209,8 @@ class DumperBase:
|
||||
if pp > 1000:
|
||||
break
|
||||
|
||||
def isKnownMovableType(self, type):
|
||||
if type in (
|
||||
def isKnownMovableType(self, typeName):
|
||||
if typeName in (
|
||||
"QBrush", "QBitArray", "QByteArray", "QCustomTypeInfo", "QChar", "QDate",
|
||||
"QDateTime", "QFileInfo", "QFixed", "QFixedPoint", "QFixedSize",
|
||||
"QHashDummyValue", "QIcon", "QImage", "QLine", "QLineF", "QLatin1Char",
|
||||
@@ -1222,7 +1222,7 @@ class DumperBase:
|
||||
):
|
||||
return True
|
||||
|
||||
return type == "QStringList" and self.qtVersion() >= 0x050000
|
||||
return typeName == "QStringList" and self.qtVersion() >= 0x050000
|
||||
|
||||
def currentItemFormat(self, type = None):
|
||||
format = self.formats.get(self.currentIName)
|
||||
@@ -1233,12 +1233,31 @@ class DumperBase:
|
||||
format = self.typeformats.get(needle)
|
||||
return format
|
||||
|
||||
def putPlotData(self, type, base, n, plotFormat = 2):
|
||||
def putArrayData(self, base, n, innerType = None,
|
||||
childNumChild = None, maxNumChild = 10000):
|
||||
if innerType is None:
|
||||
innerType = base.dereference().type
|
||||
if not self.tryPutArrayContents(base, n, innerType):
|
||||
base = self.createPointerValue(base, innerType)
|
||||
with Children(self, n, innerType, childNumChild, maxNumChild,
|
||||
base, innerType.sizeof):
|
||||
for i in self.childRange():
|
||||
i = toInteger(i)
|
||||
self.putSubItem(i, (base + i).dereference())
|
||||
|
||||
def putArrayItem(self, name, addr, n, typeName, plotFormat = 2):
|
||||
with SubItem(self, name):
|
||||
self.putEmptyValue()
|
||||
self.putType("%s [%d]" % (typeName, n))
|
||||
self.putArrayData(addr, n, self.lookupType(typeName))
|
||||
self.putAddress(addr)
|
||||
|
||||
def putPlotData(self, base, n, typeobj, plotFormat = 2):
|
||||
if self.isExpanded():
|
||||
self.putArrayData(type, base, n)
|
||||
self.putArrayData(base, n, typeobj)
|
||||
if not hasPlot():
|
||||
return
|
||||
if not self.isSimpleType(type):
|
||||
if not self.isSimpleType(typeobj):
|
||||
#self.putValue(self.currentValue + " (not plottable)")
|
||||
self.putValue(self.currentValue)
|
||||
self.putField("plottable", "0")
|
||||
@@ -1254,7 +1273,7 @@ class DumperBase:
|
||||
gnuplotPipe[iname].terminate()
|
||||
del gnuplotPipe[iname]
|
||||
return
|
||||
base = self.createPointerValue(base, type)
|
||||
base = self.createPointerValue(base, typeobj)
|
||||
if not iname in gnuplotPipe:
|
||||
gnuplotPipe[iname] = subprocess.Popen(["gnuplot"],
|
||||
stdin=subprocess.PIPE)
|
||||
|
||||
@@ -1044,16 +1044,6 @@ class Dumper(DumperBase):
|
||||
def isStructType(self, typeobj):
|
||||
return typeobj.code == gdb.TYPE_CODE_STRUCT
|
||||
|
||||
def putArrayData(self, typeobj, base, n,
|
||||
childNumChild = None, maxNumChild = 10000):
|
||||
if not self.tryPutArrayContents(typeobj, base, n):
|
||||
base = self.createPointerValue(base, typeobj)
|
||||
with Children(self, n, typeobj, childNumChild, maxNumChild,
|
||||
base, typeobj.sizeof):
|
||||
for i in self.childRange():
|
||||
i = toInteger(i)
|
||||
self.putSubItem(i, (base + i).dereference())
|
||||
|
||||
def isFunctionType(self, type):
|
||||
return type.code == MethodCode or type.code == FunctionCode
|
||||
|
||||
|
||||
@@ -600,15 +600,6 @@ class Dumper(DumperBase):
|
||||
return Hex2EncodedInt8
|
||||
return None
|
||||
|
||||
def putArrayData(self, type, base, n,
|
||||
childNumChild = None, maxNumChild = 10000):
|
||||
if not self.tryPutArrayContents(type, base, n):
|
||||
base = self.createPointerValue(base, type)
|
||||
with Children(self, n, type, childNumChild, maxNumChild,
|
||||
base, type.GetByteSize()):
|
||||
for i in self.childRange():
|
||||
self.putSubItem(i, (base + i).dereference())
|
||||
|
||||
def createPointerValue(self, address, pointeeType):
|
||||
addr = int(address) & 0xFFFFFFFFFFFFFFFF
|
||||
return self.context.CreateValueFromAddress(None, addr, pointeeType).AddressOf()
|
||||
|
||||
@@ -39,87 +39,59 @@ def qdump____m128(d, value):
|
||||
d.putEmptyValue()
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.lookupType("float"), value.address, 4)
|
||||
d.putArrayData(value.address, 4, d.lookupType("float"))
|
||||
|
||||
def qdump____m256(d, value):
|
||||
d.putEmptyValue()
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.lookupType("float"), value.address, 8)
|
||||
d.putArrayData(value.address, 8, d.lookupType("float"))
|
||||
|
||||
def qdump____m512(d, value):
|
||||
d.putEmptyValue()
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.lookupType("float"), value.address, 16)
|
||||
d.putArrayData(value.address, 16, d.lookupType("float"))
|
||||
|
||||
def qdump____m128d(d, value):
|
||||
d.putEmptyValue()
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.lookupType("double"), value.address, 2)
|
||||
d.putArrayData(value.address, 2, d.lookupType("double"))
|
||||
|
||||
def qdump____m256d(d, value):
|
||||
d.putEmptyValue()
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.lookupType("double"), value.address, 4)
|
||||
d.putArrayData(value.address, 4, d.lookupType("double"))
|
||||
|
||||
def qdump____m512d(d, value):
|
||||
d.putEmptyValue()
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.lookupType("double"), value.address, 8)
|
||||
d.putArrayData(value.address, 8, d.lookupType("double"))
|
||||
|
||||
def qdump____m128i(d, value):
|
||||
data = d.readMemory(value.address, 16)
|
||||
d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 32, 4)))
|
||||
d.putNumChild(4)
|
||||
if d.isExpanded():
|
||||
# fake 4 children as arrays
|
||||
with Children(d):
|
||||
with SubItem(d, "uint8x16"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned char [16]")
|
||||
d.putArrayData(d.lookupType("unsigned char"), value.address, 16)
|
||||
d.putAddress(value.address)
|
||||
with SubItem(d, "uint16x8"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned short [8]")
|
||||
d.putArrayData(d.lookupType("unsigned short"), value.address, 8)
|
||||
with SubItem(d, "uint32x4"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned int [4]")
|
||||
d.putArrayData(d.lookupType("unsigned int"), value.address, 4)
|
||||
with SubItem(d, "uint64x2"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned long long [2]")
|
||||
d.putArrayData(d.lookupType("unsigned long long"), value.address, 2)
|
||||
d.putArrayItem("uint8x16", value.address, 16, "unsigned char")
|
||||
d.putArrayItem("uint16x8", value.address, 8, "unsigned short")
|
||||
d.putArrayItem("uint32x4", value.address, 4, "unsigned int")
|
||||
d.putArrayItem("uint64x2", value.address, 2, "unsigned long long")
|
||||
|
||||
def qdump____m256i(d, value):
|
||||
data = d.readMemory(value.address, 32)
|
||||
d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 64, 4)))
|
||||
d.putNumChild(4)
|
||||
if d.isExpanded():
|
||||
# fake 4 children as arrays
|
||||
with Children(d):
|
||||
with SubItem(d, "uint8x32"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned char [32]")
|
||||
d.putArrayData(d.lookupType("unsigned char"), value.address, 32)
|
||||
d.putAddress(value.address)
|
||||
with SubItem(d, "uint16x8"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned short [16]")
|
||||
d.putArrayData(d.lookupType("unsigned short"), value.address, 16)
|
||||
with SubItem(d, "uint32x8"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned int [8]")
|
||||
d.putArrayData(d.lookupType("unsigned int"), value.address, 8)
|
||||
with SubItem(d, "uint64x4"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned long long [4]")
|
||||
d.putArrayData(d.lookupType("unsigned long long"), value.address, 4)
|
||||
d.putArrayItem("uint8x32", value.address, 32, "unsigned char")
|
||||
d.putArrayItem("uint16x16", value.address, 16, "unsigned short")
|
||||
d.putArrayItem("uint32x8", value.address, 8, "unsigned int")
|
||||
d.putArrayItem("uint64x4", value.address, 4, "unsigned long long")
|
||||
|
||||
def qdump____m512i(d, value):
|
||||
data = d.readMemory(value.address, 64)
|
||||
@@ -127,16 +99,9 @@ def qdump____m512i(d, value):
|
||||
+ ', ' + ':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(64, 128, 4)))
|
||||
d.putNumChild(2)
|
||||
if d.isExpanded():
|
||||
# fake 2 children as arrays
|
||||
with Children(d):
|
||||
with SubItem(d, "uint32x16"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned int [16]")
|
||||
d.putArrayData(d.lookupType("unsigned int"), value.address, 16)
|
||||
with SubItem(d, "uint64x8"):
|
||||
d.putEmptyValue()
|
||||
d.putType("unsigned long long [8]")
|
||||
d.putArrayData(d.lookupType("unsigned long long"), value.address, 8)
|
||||
d.putArrayItem("uint32x16", value.address, 16, "unsigned int")
|
||||
d.putArrayItem("uint64x8", value.address, 8, "unsigned long long")
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
|
||||
@@ -68,7 +68,7 @@ def qdump__QByteArray(d, value):
|
||||
d.putField("editformat", DisplayUtf8String)
|
||||
d.putField("editvalue", d.encodeByteArray(value))
|
||||
if d.isExpanded():
|
||||
d.putArrayData(d.charType(), data, size)
|
||||
d.putArrayData(data, size, d.charType())
|
||||
|
||||
def qdump__QByteArrayData(d, value):
|
||||
data, size, alloc = d.byteArrayDataHelper(d.addressOf(value))
|
||||
@@ -534,8 +534,7 @@ def qdump__QFiniteStack(d, value):
|
||||
d.putItemCount(size)
|
||||
d.putNumChild(size)
|
||||
if d.isExpanded():
|
||||
innerType = d.templateArgument(value.type, 0)
|
||||
d.putPlotData(innerType, value["_array"], size)
|
||||
d.putPlotData(value["_array"], size, d.templateArgument(value.type, 0))
|
||||
|
||||
# Stock gdb 7.2 seems to have a problem with types here:
|
||||
#
|
||||
@@ -789,8 +788,7 @@ def qdump__QList(d, value):
|
||||
isInternal = innerSize <= stepSize and d.isMovableType(innerType)
|
||||
if isInternal:
|
||||
if innerSize == stepSize:
|
||||
p = d.createPointerValue(addr, innerType)
|
||||
d.putArrayData(innerType, p, size)
|
||||
d.putArrayData(addr, size, innerType)
|
||||
else:
|
||||
with Children(d, size, childType=innerType):
|
||||
for i in d.childRange():
|
||||
@@ -2172,8 +2170,7 @@ def qdump__QVector(d, value):
|
||||
d.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000)
|
||||
d.putItemCount(size)
|
||||
d.putNumChild(size)
|
||||
innerType = d.templateArgument(value.type, 0)
|
||||
d.putPlotData(innerType, data, size)
|
||||
d.putPlotData(data, size, d.templateArgument(value.type, 0))
|
||||
|
||||
|
||||
def qdump__QWeakPointer(d, value):
|
||||
|
||||
@@ -37,8 +37,7 @@ def qdump__std__array(d, value):
|
||||
d.putItemCount(size)
|
||||
d.putNumChild(size)
|
||||
if d.isExpanded():
|
||||
innerType = d.templateArgument(value.type, 0)
|
||||
d.putPlotData(innerType, d.addressOf(value), size)
|
||||
d.putPlotData(d.addressOf(value), size, d.templateArgument(value.type, 0))
|
||||
|
||||
|
||||
def qform__std____1__array():
|
||||
@@ -724,10 +723,10 @@ def qdump__std__vector(d, value):
|
||||
q = base + int(i / 8)
|
||||
d.putBoolItem(str(i), (int(d.extractPointer(q)) >> (i % 8)) & 1)
|
||||
else:
|
||||
d.putPlotData(type, start, size)
|
||||
d.putPlotData(start, size, type)
|
||||
|
||||
def qdump__std__vector__QNX(d, value):
|
||||
type = d.templateArgument(value.type, 0)
|
||||
innerType = d.templateArgument(value.type, 0)
|
||||
isBool = str(type) == 'bool'
|
||||
if isBool:
|
||||
impl = value['_Myvec']
|
||||
@@ -753,12 +752,12 @@ def qdump__std__vector__QNX(d, value):
|
||||
d.putNumChild(size)
|
||||
if d.isExpanded():
|
||||
if isBool:
|
||||
with Children(d, size, maxNumChild=10000, childType=type):
|
||||
with Children(d, size, maxNumChild=10000, childType=innerType):
|
||||
for i in d.childRange():
|
||||
q = start + int(i / storagesize)
|
||||
d.putBoolItem(str(i), (q.dereference() >> (i % storagesize)) & 1)
|
||||
else:
|
||||
d.putArrayData(type, start, size)
|
||||
d.putArrayData(start, size, innerType)
|
||||
|
||||
def qdump__std____1__vector(d, value):
|
||||
innerType = d.templateArgument(value.type, 0)
|
||||
@@ -775,7 +774,7 @@ def qdump__std____1__vector(d, value):
|
||||
d.putItemCount(size)
|
||||
d.putNumChild(size)
|
||||
if d.isExpanded():
|
||||
d.putPlotData(innerType, begin, size)
|
||||
d.putPlotData(begin, size, innerType)
|
||||
|
||||
|
||||
def qform__std____debug__vector():
|
||||
|
||||
@@ -5935,6 +5935,9 @@ namespace sse {
|
||||
__m128 sseA, sseB;
|
||||
sseA = _mm_loadu_ps(a);
|
||||
sseB = _mm_loadu_ps(b);
|
||||
|
||||
__m128i sseAi;
|
||||
sseAi = _mm_set_epi32(1, 3, 5, 7);
|
||||
BREAK_HERE;
|
||||
// Expand a b.
|
||||
// CheckType sseA __m128.
|
||||
|
||||
Reference in New Issue
Block a user