forked from qt-creator/qt-creator
Debugger: Work around for gdb reporting zero array sizes in some cases
Task-number: QTCREATORBUG-23998 Change-Id: I101d032705b66faf50260067f6aa604214f09298 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1089,6 +1089,10 @@ class DumperBase():
|
|||||||
return '_ZN%sE' % ''.join(map(lambda x: '%d%s' % (len(x), x),
|
return '_ZN%sE' % ''.join(map(lambda x: '%d%s' % (len(x), x),
|
||||||
typeName.split('::')))
|
typeName.split('::')))
|
||||||
|
|
||||||
|
def arrayItemCountFromTypeName(self, typeName, fallbackMax=1):
|
||||||
|
itemCount = typeName[typeName.find('[') + 1:typeName.find(']')]
|
||||||
|
return int(itemCount) if itemCount else fallbackMax
|
||||||
|
|
||||||
def putCStyleArray(self, value):
|
def putCStyleArray(self, value):
|
||||||
arrayType = value.type.unqualified()
|
arrayType = value.type.unqualified()
|
||||||
innerType = arrayType.ltarget
|
innerType = arrayType.ltarget
|
||||||
@@ -1107,10 +1111,7 @@ class DumperBase():
|
|||||||
# This should not happen. But it does, see QTCREATORBUG-14755.
|
# This should not happen. But it does, see QTCREATORBUG-14755.
|
||||||
# GDB/GCC produce sizeof == 0 for QProcess arr[3]
|
# GDB/GCC produce sizeof == 0 for QProcess arr[3]
|
||||||
# And in the Nim string dumper.
|
# And in the Nim string dumper.
|
||||||
s = value.type.name
|
itemCount = self.arrayItemCountFromTypeName(value.type.name, 100)
|
||||||
itemCount = s[s.find('[') + 1:s.find(']')]
|
|
||||||
if not itemCount:
|
|
||||||
itemCount = '100'
|
|
||||||
arrayByteSize = int(itemCount) * innerType.size()
|
arrayByteSize = int(itemCount) * innerType.size()
|
||||||
|
|
||||||
n = arrayByteSize // innerType.size()
|
n = arrayByteSize // innerType.size()
|
||||||
|
@@ -341,7 +341,12 @@ class Dumper(DumperBase):
|
|||||||
#DumperBase.warn('ARRAY')
|
#DumperBase.warn('ARRAY')
|
||||||
nativeTargetType = nativeType.target().unqualified()
|
nativeTargetType = nativeType.target().unqualified()
|
||||||
targetType = self.fromNativeType(nativeTargetType)
|
targetType = self.fromNativeType(nativeTargetType)
|
||||||
count = nativeType.sizeof // nativeTargetType.sizeof
|
if nativeType.sizeof == 0:
|
||||||
|
# QTCREATORBUG-23998, note that nativeType.name == None here,
|
||||||
|
# whereas str(nativeType) returns sth like 'QObject [5]'
|
||||||
|
count = self.arrayItemCountFromTypeName(str(nativeType), 1)
|
||||||
|
else:
|
||||||
|
count = nativeType.sizeof // nativeTargetType.sizeof
|
||||||
return self.createArrayType(targetType, count)
|
return self.createArrayType(targetType, count)
|
||||||
|
|
||||||
if code == gdb.TYPE_CODE_TYPEDEF:
|
if code == gdb.TYPE_CODE_TYPEDEF:
|
||||||
|
Reference in New Issue
Block a user