forked from qt-creator/qt-creator
Debugger: Show actual type for 'gchar *' elements etc
When 'char *' typedefs (and the like) are used, this makes
the actual (i.e. the typedef's) type name shown instead of the
one that the type is a typedef for.
For example, 'gchar' is shown as type for all elements of a 'gchar*'
when expanding that one in the debugger's locals or expressions view.
Original display of text representation for 'char *' typedefs etc.
had been added with commit 70c4889ac9
("Debugger: Show text representation for 'char *' typedefs etc",
2020-06-26). Move the typedef resolution one level down so the
original type name is still available for display.
This also extends the existing 'gchar *' test case accordingly.
Change-Id: I9558360b3bf96906d6dc39a63706bb8ce28c2f1c
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1228,7 +1228,11 @@ class DumperBase():
|
||||
# This is shared by pointer and array formatting.
|
||||
def tryPutSimpleFormattedPointer(self, ptr, typeName, innerType, displayFormat, limit):
|
||||
if displayFormat == DisplayFormat.Automatic:
|
||||
if innerType.name in ('char', 'signed char', 'unsigned char', 'CHAR'):
|
||||
targetType = innerType
|
||||
if innerType.code == TypeCode.Typedef:
|
||||
targetType = innerType.ltarget
|
||||
|
||||
if targetType.name in ('char', 'signed char', 'unsigned char', 'CHAR'):
|
||||
# Use UTF-8 as default for char *.
|
||||
self.putType(typeName)
|
||||
(elided, shown, data) = self.readToFirstZero(ptr, 1, limit)
|
||||
@@ -1237,7 +1241,7 @@ class DumperBase():
|
||||
self.putArrayData(ptr, shown, innerType)
|
||||
return True
|
||||
|
||||
if innerType.name in ('wchar_t', 'WCHAR'):
|
||||
if targetType.name in ('wchar_t', 'WCHAR'):
|
||||
self.putType(typeName)
|
||||
charSize = self.lookupType('wchar_t').size()
|
||||
(elided, data) = self.encodeCArray(ptr, charSize, limit)
|
||||
@@ -1336,10 +1340,7 @@ class DumperBase():
|
||||
return
|
||||
|
||||
displayFormat = self.currentItemFormat(value.type.name)
|
||||
|
||||
innerType = value.type.target() # .unqualified()
|
||||
if innerType.code == TypeCode.Typedef:
|
||||
innerType = innerType.ltarget
|
||||
|
||||
if innerType.name == 'void':
|
||||
#DumperBase.warn('VOID POINTER: %s' % displayFormat)
|
||||
|
||||
@@ -5680,6 +5680,7 @@ void tst_Dumpers::dumper_data()
|
||||
|
||||
+ Check("str1", "\"abc\"", "char *")
|
||||
+ Check("str2", "\"abc\"", "gchar *")
|
||||
+ Check("str2.0", "[0]", "97", "gchar") // 97: ASCII 'a'
|
||||
+ CheckType("u", "unsigned char *")
|
||||
+ CheckType("uu", "unsigned char [3]")
|
||||
+ CheckType("s", "char *")
|
||||
|
||||
Reference in New Issue
Block a user