Commit d7c5ee7e authored by hjk's avatar hjk

Debugger: Fix display selection of char arrays

... by re-using the logic we had for std::string already.

A plain char[] value did not react to Change Display Format,
Latin1 was used unconditionally.

Also rename putStdStringHelper to putCharArrayHelper.

Change-Id: I01fdf796ff49a4c99ead7b9b46274684e18e962b
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 07e1f78c
......@@ -569,7 +569,7 @@ class DumperBase:
elided, shown = self.computeLimit(size, limit)
return elided, self.readMemory(data, shown)
def putStdStringHelper(self, data, size, charSize, displayFormat = AutomaticFormat):
def putCharArrayHelper(self, data, size, charSize, displayFormat = AutomaticFormat):
bytelen = size * charSize
elided, shown = self.computeLimit(bytelen, self.displayStringLimit)
mem = self.readMemory(data, shown)
......@@ -917,18 +917,10 @@ class DumperBase:
arrayByteSize = int(s[s.find('[')+1:s.find(']')]) * ts;
n = int(arrayByteSize / ts)
if displayFormat != RawFormat:
if innerTypeName == "char":
# Use Latin1 as default for char [].
blob = self.readMemory(self.addressOf(value), arrayByteSize)
self.putValue(blob, Hex2EncodedLatin1)
elif innerTypeName == "wchar_t":
blob = self.readMemory(self.addressOf(value), arrayByteSize)
if innerType.sizeof == 2:
self.putValue(blob, Hex4EncodedLittleEndian)
else:
self.putValue(blob, Hex8EncodedLittleEndian)
elif p:
if displayFormat != RawFormat and p:
if innerTypeName == "char" or innerTypeName == "wchar_t":
self.putCharArrayHelper(p, n, ts, self.currentItemFormat())
else:
self.tryPutSimpleFormattedPointer(p, arrayType, innerTypeName,
displayFormat, arrayByteSize)
self.putNumChild(n)
......
......@@ -155,7 +155,7 @@ class PlainDumper:
if isinstance(val, str):
d.putValue(val)
else: # Assuming LazyString
d.putStdStringHelper(val.address, val.length, val.type.sizeof)
d.putCharArrayHelper(val.address, val.length, val.type.sizeof)
d.putNumChild(len(children))
if d.isExpanded():
......
......@@ -419,7 +419,7 @@ def qdump__std__stringHelper1(d, value, charSize, format):
refcount = int(sizePtr[-1]) & 0xffffffff
d.check(refcount >= -1) # Can be -1 accoring to docs.
d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
d.putStdStringHelper(sizePtr, size, charSize, format)
d.putCharArrayHelper(sizePtr, size, charSize, format)
def qdump__std__stringHelper1__QNX(d, value, charSize, format):
size = value['_Mysize']
......@@ -433,7 +433,7 @@ def qdump__std__stringHelper1__QNX(d, value, charSize, format):
refcount = int(sizePtr[-1])
d.check(refcount >= -1) # Can be -1 accoring to docs.
d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
d.putStdStringHelper(sizePtr, size, charSize, format)
d.putCharArrayHelper(sizePtr, size, charSize, format)
def qdump__std____1__string(d, value):
......@@ -447,7 +447,7 @@ def qdump__std____1__string(d, value):
# Short/internal.
size = firstByte / 2
data = base + 1
d.putStdStringHelper(data, size, 1, d.currentItemFormat())
d.putCharArrayHelper(data, size, 1, d.currentItemFormat())
d.putType("std::string")
......@@ -462,7 +462,7 @@ def qdump__std____1__wstring(d, value):
# Short/internal.
size = firstByte / 2
data = base + 4
d.putStdStringHelper(data, size, 4)
d.putCharArrayHelper(data, size, 4)
d.putType("std::xxwstring")
......
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