Debugger: merge put array code from cdbbridge into dumper base

Basically the same. Only the type lookup of the inner type needs to be
avoided for performance reasons.

Change-Id: I2747ab44c23b764482b4a063d3618fae2e3c4d46
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2024-06-24 10:41:33 +02:00
parent 9733957862
commit b245912b56
2 changed files with 6 additions and 84 deletions

View File

@@ -629,87 +629,6 @@ class Dumper(DumperBase):
if self.showQObjectNames:
self.tryPutQObjectGuts(value)
def putCStyleArray(self, value: DumperBase.Value):
arrayType = value.type
innerType = arrayType.target()
address = value.address()
if address:
self.putValue('@0x%x' % address, priority=-1)
else:
self.putEmptyValue()
self.putType(arrayType)
displayFormat = self.currentItemFormat()
arrayByteSize = arrayType.size()
n = self.arrayItemCountFromTypeName(value.type.name, 100)
p = value.address()
if displayFormat != DisplayFormat.Raw and p:
if innerType.name.strip() in (
'char',
'int8_t',
'qint8',
'wchar_t',
'unsigned char',
'uint8_t',
'quint8',
'signed char',
'CHAR',
'WCHAR',
'char8_t',
'char16_t',
'char32_t'
):
self.putCharArrayHelper(p, n, innerType, self.currentItemFormat(),
makeExpandable=False)
else:
self.tryPutSimpleFormattedPointer(p, arrayType, innerType,
displayFormat, arrayByteSize)
self.putNumChild(n)
if self.isExpanded():
if n > 100:
addrStep = innerType.size()
with Children(self, n, innerType, addrBase=address, addrStep=addrStep):
for i in self.childRange():
self.putSubItem(i, self.createValue(address + i * addrStep, innerType))
else:
with Children(self):
n = 0
for item in self.listValueChildren(value):
with SubItem(self, n):
n += 1
self.putItem(item)
def putArrayData(self, base, n, innerType, childNumChild=None):
self.checkIntType(base)
self.checkIntType(n)
addrBase = base
innerType = self.createType(innerType)
innerSize = innerType.size()
self.putNumChild(n)
#DumperBase.warn('ADDRESS: 0x%x INNERSIZE: %s INNERTYPE: %s' % (addrBase, innerSize, innerType))
enc = self.type_encoding_cache.get(innerType.typeid, None)
maxNumChild = self.maxArrayCount()
if enc:
self.put('childtype="%s",' % innerType.name)
self.put('addrbase="0x%x",' % addrBase)
self.put('addrstep="0x%x",' % innerSize)
self.put('arrayencoding="%s",' % enc)
self.put('endian="%s",' % self.packCode)
if n > maxNumChild:
self.put('childrenelided="%s",' % n)
n = maxNumChild
self.put('arraydata="')
self.put(self.readMemory(addrBase, n * innerSize))
self.put('",')
else:
with Children(self, n, innerType, childNumChild, maxNumChild,
addrBase=addrBase, addrStep=innerSize):
for i in self.childRange():
self.putSubItem(i, self.createValue(addrBase + i * innerSize, innerType))
def fetchInternalFunctions(self):
coreModuleName = self.qtCoreModuleName()
ns = self.qtNamespace()

View File

@@ -1305,14 +1305,17 @@ class DumperBase():
displayFormat = self.currentItemFormat()
arrayByteSize = arrayType.size()
n = self.arrayItemCountFromTypeName(value.type.name, 100)
if arrayByteSize == 0:
# This should not happen. But it does, see QTCREATORBUG-14755.
# GDB/GCC produce sizeof == 0 for QProcess arr[3]
# And in the Nim string dumper.
itemCount = self.arrayItemCountFromTypeName(value.type.name, 100)
arrayByteSize = int(itemCount) * innerType.size()
arrayByteSize = n * innerType.size()
elif not self.isCdb:
# Do not check the inner type size for cdb since this requires a potentially expensive
# type lookup
n = arrayByteSize // innerType.size()
p = value.address()
if displayFormat != DisplayFormat.Raw and p:
if innerType.name in (