Commit 2760b9fc authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Dumper: Dump CHAR/WCHAR arrays as strings

Change-Id: I78bdb181e27cc858356c9026fc960135b54cdcbb
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 0b8ab0d7
...@@ -1177,7 +1177,7 @@ class DumperBase: ...@@ -1177,7 +1177,7 @@ class DumperBase:
n = arrayByteSize // innerType.size() n = arrayByteSize // innerType.size()
p = value.address() p = value.address()
if displayFormat != RawFormat and p: 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(), self.putCharArrayHelper(p, n, innerType, self.currentItemFormat(),
makeExpandable = False) makeExpandable = False)
else: else:
...@@ -1256,7 +1256,7 @@ class DumperBase: ...@@ -1256,7 +1256,7 @@ class DumperBase:
# This is shared by pointer and array formatting. # This is shared by pointer and array formatting.
def tryPutSimpleFormattedPointer(self, ptr, typeName, innerType, displayFormat, limit): def tryPutSimpleFormattedPointer(self, ptr, typeName, innerType, displayFormat, limit):
if displayFormat == AutomaticFormat: 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 *. # Use UTF-8 as default for char *.
self.putType(typeName) self.putType(typeName)
(elided, shown, data) = self.readToFirstZero(ptr, 1, limit) (elided, shown, data) = self.readToFirstZero(ptr, 1, limit)
...@@ -1265,7 +1265,7 @@ class DumperBase: ...@@ -1265,7 +1265,7 @@ class DumperBase:
self.putArrayData(ptr, shown, innerType) self.putArrayData(ptr, shown, innerType)
return True return True
if innerType.name == 'wchar_t': if innerType.name in ('wchar_t', 'WCHAR'):
self.putType(typeName) self.putType(typeName)
charSize = self.lookupType('wchar_t').size() charSize = self.lookupType('wchar_t').size()
(elided, data) = self.encodeCArray(ptr, charSize, limit) (elided, data) = self.encodeCArray(ptr, charSize, limit)
...@@ -1415,7 +1415,7 @@ class DumperBase: ...@@ -1415,7 +1415,7 @@ class DumperBase:
#warn('INNER: %s' % innerType.name) #warn('INNER: %s' % innerType.name)
if self.autoDerefPointers: if self.autoDerefPointers:
# Generic pointer type with AutomaticFormat, but never dereference char types: # 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) self.putDerefedPointer(value)
return return
......
...@@ -1300,7 +1300,13 @@ void tst_Dumpers::dumper() ...@@ -1300,7 +1300,13 @@ void tst_Dumpers::dumper()
"\n#define BREAK qtcDebugBreakFunction();" "\n#define BREAK qtcDebugBreakFunction();"
"\n\nvoid unused(const void *first,...) { (void) first; }" "\n\nvoid unused(const void *first,...) { (void) first; }"
"\n#else" "\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) if (m_debuggerEngine == LldbEngine)
//#ifdef Q_OS_MAC //#ifdef Q_OS_MAC
...@@ -5197,7 +5203,9 @@ void tst_Dumpers::dumper_data() ...@@ -5197,7 +5203,9 @@ void tst_Dumpers::dumper_data()
"char s[] = \"aöa\";\n" "char s[] = \"aöa\";\n"
"char t[] = \"aöax\";\n" "char t[] = \"aöax\";\n"
"wchar_t w[] = L\"aöa\";\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 [5]") % NoCdbEngine
+ CheckType("s", "char [4]") % CdbEngine + CheckType("s", "char [4]") % CdbEngine
...@@ -5205,7 +5213,12 @@ void tst_Dumpers::dumper_data() ...@@ -5205,7 +5213,12 @@ void tst_Dumpers::dumper_data()
+ CheckType("t", "char [6]") % NoCdbEngine + CheckType("t", "char [6]") % NoCdbEngine
+ CheckType("t", "char [5]") % CdbEngine + CheckType("t", "char [5]") % CdbEngine
+ Check("t.0", "[0]", "97", "char") + 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") QTest::newRow("CharPointers")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment