summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-09-17 15:48:48 +0300
committerOrgad Shaneh <orgads@gmail.com>2017-09-18 11:43:51 +0000
commit2760b9fc67792d84a5abbbba0e1d774fb1883344 (patch)
tree2b4f969cd9dae9076bf07a0c9814d7889edf61e4
parent0b8ab0d78ab9e17d34c0c5bbc37200877f668ebb (diff)
downloadqt-creator-2760b9fc67792d84a5abbbba0e1d774fb1883344.tar.gz
Dumper: Dump CHAR/WCHAR arrays as strings
Change-Id: I78bdb181e27cc858356c9026fc960135b54cdcbb Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--share/qtcreator/debugger/dumper.py8
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp19
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 <stdint.h>\n";
+ "\n#include <stdint.h>"
+ "\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")