diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py index bda79a73060..840a757aabc 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.py +++ b/share/qtcreator/gdbmacros/gdbmacros.py @@ -1829,20 +1829,41 @@ 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) - for i in xrange(size): - s += format % int(p.dereference()) - p += 1 - d.putValue(s, 6) + 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) diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 8137b4744d9..51c45ef7833 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -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 (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 + (decodedBa.data()), decodedBa.size() / 4) + doubleQuote; + } } qDebug() << "ENCODING ERROR: " << encoding; return QCoreApplication::translate("Debugger", "");