Commit ed4278ab authored by hjk's avatar hjk
Browse files

debugger: fix new wstring dumper encoding

parent 72ecc8a4
...@@ -1829,20 +1829,41 @@ def qdump__std__string(d, item): ...@@ -1829,20 +1829,41 @@ def qdump__std__string(d, item):
check(rep['_M_refcount'] >= 0) check(rep['_M_refcount'] >= 0)
check(0 <= size and size <= alloc and alloc <= 100*1000*1000) check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
d.unputField("type") d.unputField("type")
p = gdb.Value(data.cast(charType.pointer()))
s = ""
if str(charType) == "char": if str(charType) == "char":
d.putType("std::string") d.putType("std::string")
elif str(charType) == "wchar_t": elif str(charType) == "wchar_t":
d.putType("std::string") d.putType("std::wstring")
else: else:
d.putType(baseType) d.putType(baseType)
p = gdb.Value(data.cast(charType.pointer()))
s = ""
format = "%%0%dx" % (2 * charType.sizeof)
n = qmin(size, 1000) n = qmin(size, 1000)
for i in xrange(size): if charType.sizeof == 1:
s += format % int(p.dereference()) format = "%02x"
p += 1 for i in xrange(size):
d.putValue(s, 6) 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) d.putNumChild(0)
......
...@@ -646,13 +646,20 @@ QString decodeData(const QByteArray &ba, int encoding) ...@@ -646,13 +646,20 @@ QString decodeData(const QByteArray &ba, int encoding)
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
return doubleQuote + QString::fromLatin1(decodedBa) + doubleQuote; 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 QChar doubleQuote(QLatin1Char('"'));
const QByteArray decodedBa = QByteArray::fromHex(ba); const QByteArray decodedBa = QByteArray::fromHex(ba);
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
return doubleQuote + QString::fromUtf16(reinterpret_cast<const ushort *> return doubleQuote + QString::fromUtf16(reinterpret_cast<const ushort *>
(decodedBa.data()), decodedBa.size() / 2) + doubleQuote; (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; qDebug() << "ENCODING ERROR: " << encoding;
return QCoreApplication::translate("Debugger", "<Encoding error>"); return QCoreApplication::translate("Debugger", "<Encoding error>");
......
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