forked from qt-creator/qt-creator
debugger: fix new wstring dumper encoding
This commit is contained in:
@@ -1829,21 +1829,42 @@ def qdump__std__string(d, item):
|
||||
check(rep['_M_refcount'] >= 0)
|
||||
check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
|
||||
d.unputField("type")
|
||||
p = gdb.Value(data.cast(charType.pointer()))
|
||||
s = ""
|
||||
if str(charType) == "char":
|
||||
d.putType("std::string")
|
||||
elif str(charType) == "wchar_t":
|
||||
d.putType("std::string")
|
||||
d.putType("std::wstring")
|
||||
else:
|
||||
d.putType(baseType)
|
||||
p = gdb.Value(data.cast(charType.pointer()))
|
||||
s = ""
|
||||
format = "%%0%dx" % (2 * charType.sizeof)
|
||||
|
||||
n = qmin(size, 1000)
|
||||
if charType.sizeof == 1:
|
||||
format = "%02x"
|
||||
for i in xrange(size):
|
||||
s += format % int(p.dereference())
|
||||
p += 1
|
||||
d.putValue(s, 6)
|
||||
d.putNumChild(0)
|
||||
elif charType.sizeof == 2:
|
||||
format = "%02x%02x"
|
||||
for i in xrange(size):
|
||||
val = int(p.dereference())
|
||||
s += format % (val % 256, val / 256)
|
||||
p += 1
|
||||
d.putValue(s, 7)
|
||||
else:
|
||||
# FIXME: This is not always a proper solution.
|
||||
format = "%02x%02x%02x%02x"
|
||||
for i in xrange(size):
|
||||
val = int(p.dereference())
|
||||
hi = val / 65536
|
||||
lo = val % 65536
|
||||
s += format % (lo % 256, lo / 256, hi % 256, hi / 256)
|
||||
p += 1
|
||||
d.putValue(s, 8)
|
||||
|
||||
d.putNumChild(0)
|
||||
|
||||
|
||||
def qdump__std__vector(d, item):
|
||||
|
||||
@@ -646,13 +646,20 @@ QString decodeData(const QByteArray &ba, int encoding)
|
||||
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
|
||||
return doubleQuote + QString::fromLatin1(decodedBa) + doubleQuote;
|
||||
}
|
||||
case 7: { // %04x encoded 16 bit data
|
||||
case 7: { // %04x encoded 16 bit data, Little Endian
|
||||
const QChar doubleQuote(QLatin1Char('"'));
|
||||
const QByteArray decodedBa = QByteArray::fromHex(ba);
|
||||
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
|
||||
return doubleQuote + QString::fromUtf16(reinterpret_cast<const ushort *>
|
||||
(decodedBa.data()), decodedBa.size() / 2) + doubleQuote;
|
||||
}
|
||||
case 8: { // %08x encoded 32 bit data, Little Endian
|
||||
const QChar doubleQuote(QLatin1Char('"'));
|
||||
const QByteArray decodedBa = QByteArray::fromHex(ba);
|
||||
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
|
||||
return doubleQuote + QString::fromUcs4(reinterpret_cast<const uint *>
|
||||
(decodedBa.data()), decodedBa.size() / 4) + doubleQuote;
|
||||
}
|
||||
}
|
||||
qDebug() << "ENCODING ERROR: " << encoding;
|
||||
return QCoreApplication::translate("Debugger", "<Encoding error>");
|
||||
|
||||
Reference in New Issue
Block a user