From 2760b9fc67792d84a5abbbba0e1d774fb1883344 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 17 Sep 2017 15:48:48 +0300 Subject: Dumper: Dump CHAR/WCHAR arrays as strings Change-Id: I78bdb181e27cc858356c9026fc960135b54cdcbb Reviewed-by: hjk --- share/qtcreator/debugger/dumper.py | 8 ++++---- tests/auto/debugger/tst_dumpers.cpp | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 7314ec8b97..6966a50cf5 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -1177,7 +1177,7 @@ class DumperBase: n = arrayByteSize // innerType.size() p = value.address() if displayFormat != RawFormat and p: - if innerType.name in ('char', 'wchar_t', 'unsigned char', 'signed char'): + if innerType.name in ('char', 'wchar_t', 'unsigned char', 'signed char', 'CHAR', 'WCHAR'): self.putCharArrayHelper(p, n, innerType, self.currentItemFormat(), makeExpandable = False) else: @@ -1256,7 +1256,7 @@ class DumperBase: # This is shared by pointer and array formatting. def tryPutSimpleFormattedPointer(self, ptr, typeName, innerType, displayFormat, limit): if displayFormat == AutomaticFormat: - if innerType.name in ('char', 'signed char', 'unsigned char'): + if innerType.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) @@ -1265,7 +1265,7 @@ class DumperBase: self.putArrayData(ptr, shown, innerType) return True - if innerType.name == 'wchar_t': + if innerType.name in ('wchar_t', 'WCHAR'): self.putType(typeName) charSize = self.lookupType('wchar_t').size() (elided, data) = self.encodeCArray(ptr, charSize, limit) @@ -1415,7 +1415,7 @@ class DumperBase: #warn('INNER: %s' % innerType.name) if self.autoDerefPointers: # Generic pointer type with AutomaticFormat, but never dereference char types: - if innerType.name not in ('char', 'signed char', 'unsigned char', 'wchar_t'): + if innerType.name not in ('char', 'signed char', 'unsigned char', 'wchar_t', 'CHAR', 'WCHAR'): self.putDerefedPointer(value) return diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 6fe3d99bdd..91af07f8f1 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -1300,7 +1300,13 @@ void tst_Dumpers::dumper() "\n#define BREAK qtcDebugBreakFunction();" "\n\nvoid unused(const void *first,...) { (void) first; }" "\n#else" - "\n#include \n"; + "\n#include " + "\n#ifndef _WIN32" + "\ntypedef char CHAR;" + "\ntypedef char *PCHAR;" + "\ntypedef wchar_t WCHAR;" + "\ntypedef wchar_t *PWCHAR;" + "\n#endif\n"; if (m_debuggerEngine == LldbEngine) //#ifdef Q_OS_MAC @@ -5197,7 +5203,9 @@ void tst_Dumpers::dumper_data() "char s[] = \"aöa\";\n" "char t[] = \"aöax\";\n" "wchar_t w[] = L\"aöa\";\n" - "unused(&s, &t, &w);\n") + "CHAR ch[] = \"aöa\";\n" + "WCHAR wch[] = L\"aöa\";\n" + "unused(&s, &t, &w, &ch, &wch);\n") + CheckType("s", "char [5]") % NoCdbEngine + CheckType("s", "char [4]") % CdbEngine @@ -5205,7 +5213,12 @@ void tst_Dumpers::dumper_data() + CheckType("t", "char [6]") % NoCdbEngine + CheckType("t", "char [5]") % CdbEngine + Check("t.0", "[0]", "97", "char") - + CheckType("w", "wchar_t [4]"); + + CheckType("w", "wchar_t [4]") + + Check("ch.0", "[0]", "97", "CHAR") + + CheckType("ch", "CHAR [5]") % NoCdbEngine + + CheckType("ch", "CHAR [4]") % CdbEngine + + Check("wch.0", "[0]", "97", "WCHAR") + + CheckType("wch", "WCHAR [4]"); QTest::newRow("CharPointers") -- cgit v1.2.1