From 78a1beb06e22ae83647e0ef1a356b59a2fe9fad5 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Fri, 29 Oct 2021 14:11:10 +0200 Subject: [PATCH] Debugger: Improve handling of stdint types * Make (u)intX_t known as integral type * Handle uint8_t[] the same way as char[] and unsigned char[] Task-number: QTCREATORBUG-26501 Change-Id: I1eac21be198f8107f088e56daf435b5bb3217120 Reviewed-by: hjk --- share/qtcreator/debugger/dumper.py | 5 ++++- src/plugins/debugger/watchdata.cpp | 14 ++++++++++++-- src/plugins/debugger/watchhandler.cpp | 4 ++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 97b4544a50d..7bdb028eba3 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -1137,6 +1137,7 @@ class DumperBase(): 'char', 'wchar_t', 'unsigned char', + 'uint8_t', 'signed char', 'CHAR', 'WCHAR' @@ -1243,7 +1244,7 @@ class DumperBase(): if innerType.code == TypeCode.Typedef: targetType = innerType.ltarget - if targetType.name in ('char', 'signed char', 'unsigned char', 'CHAR'): + if targetType.name in ('char', 'signed char', 'unsigned char', 'uint8_t', 'CHAR'): # Use UTF-8 as default for char *. self.putType(typeName) (elided, shown, data) = self.readToFirstZero(ptr, 1, limit) @@ -1406,6 +1407,7 @@ class DumperBase(): 'char', 'signed char', 'unsigned char', + 'uint8_t', 'wchar_t', 'CHAR', 'WCHAR' @@ -3628,6 +3630,7 @@ class DumperBase(): 'char': 'int:1', 'signed char': 'int:1', 'unsigned char': 'uint:1', + 'uint8_t': 'uint:1', 'short': 'int:2', 'unsigned short': 'uint:2', 'int': 'int:4', diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index f5173b857c5..49a75cc86f0 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -50,7 +50,12 @@ bool isIntType(const QString &type) case 'c': return type == "char"; case 'i': - return type == "int"; + return type.startsWith("int") && + ( type == "int" + || type == "int8_t" + || type == "int16_t" + || type == "int32_t" + || type == "int64_t"); case 'l': return type == "long" || type == "long int" @@ -86,7 +91,12 @@ bool isIntType(const QString &type) || type == "unsigned long" || type == "unsigned long int" || type == "unsigned long long" - || type == "unsigned long long int")); + || type == "unsigned long long int")) + || (type.startsWith("uint") && + ( type == "uint8_t" + || type == "uint16_t" + || type == "uint32_t" + || type == "uint64_t")); default: return false; } diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 20a5c95108b..ed3fb5de9d2 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -718,10 +718,10 @@ static QString formattedValue(const WatchItem *item) // Append quoted, printable character also for decimal. // FIXME: This is unreliable. - if (item->type.endsWith("char")) { + if (item->type.endsWith("char") || item->type.endsWith("int8_t")) { bool ok; const int code = item->value.toInt(&ok); - bool isUnsigned = item->type == "unsigned char" || item->type == "uchar"; + bool isUnsigned = item->type == "unsigned char" || item->type == "uchar" || item->type == "uint8_t"; if (ok) return reformatCharacter(code, 1, !isUnsigned); } else if (item->type.endsWith("wchar_t")) {