Debugger: Add fallback when gdb.Value.cast() fails for typedefs

Fixes: QTCREATORBUG-18450
Change-Id: I9239beb7e1879a284e28a30579129fe487eb2dd2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-12-17 12:27:02 +01:00
parent 40f2f99714
commit 2a67a86c2f
2 changed files with 25 additions and 2 deletions

View File

@@ -247,8 +247,14 @@ class Dumper(DumperBase):
if targetType.code == gdb.TYPE_CODE_ARRAY:
val = self.Value(self)
else:
# Cast may fail (e.g for arrays, see test for Bug5799)
val = self.fromNativeValue(nativeValue.cast(targetType))
try:
# Cast may fail for arrays, for typedefs to __uint128_t with
# gdb.error: That operation is not available on integers
# of more than 8 bytes.
# See test for Bug5799, QTCREATORBUG-18450.
val = self.fromNativeValue(nativeValue.cast(targetType))
except:
val = self.Value(self)
#warn('CREATED TYPEDEF: %s' % val)
else:
val = self.Value(self)

View File

@@ -5383,6 +5383,23 @@ void tst_Dumpers::dumper_data()
+ Check("s32s", "-2147483648", TypeDef("int", "@qint32"));
QTest::newRow("Int128")
<< Data("#include <limits.h>\n",
"using typedef_s128 = __int128_t;\n"
"using typedef_u128 = __uint128_t;\n"
"__int128_t s128 = 12;\n"
"__uint128_t u128 = 12;\n"
"typedef_s128 ts128 = 12;\n"
"typedef_u128 tu128 = 12;\n"
"unused(&u128, &s128, &tu128, &ts128);\n")
// Sic! The expected type is what gcc 8.2.0 records.
+ GdbEngine
+ Check("s128", "12", "__int128")
+ Check("u128", "12", "__int128 unsigned")
+ Check("ts128", "12", "typedef_s128")
+ Check("tu128", "12", "typedef_u128") ;
QTest::newRow("Float")
<< Data("#include <QFloat16>\n",
"qfloat16 f1 = 45.3f; unused(&f1);\n"