diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 1788ba5b5d0..0f32a5ded4e 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -587,16 +587,16 @@ QString quoteUnprintableLatin1(const QByteArray &ba) QString decodeData(const QByteArray &ba, int encoding) { switch (encoding) { - case 0: // unencoded 8 bit data + case Unencoded8Bit: // 0 return quoteUnprintableLatin1(ba); - case 1: { // base64 encoded 8 bit data, used for QByteArray + case Base64Encoded8BitWithQuotes: { // 1, used for QByteArray const QChar doubleQuote(QLatin1Char('"')); QString rc = doubleQuote; rc += quoteUnprintableLatin1(QByteArray::fromBase64(ba)); rc += doubleQuote; return rc; } - case 2: { // base64 encoded 16 bit data, used for QString + case Base64Encoded16BitWithQuotes: { // 2, used for QString const QChar doubleQuote(QLatin1Char('"')); const QByteArray decodedBa = QByteArray::fromBase64(ba); QString rc = doubleQuote; @@ -605,7 +605,7 @@ QString decodeData(const QByteArray &ba, int encoding) rc += doubleQuote; return rc; } - case 3: { // base64 encoded 32 bit data + case Base64Encoded32BitWithQuotes: { // 3 const QByteArray decodedBa = QByteArray::fromBase64(ba); const QChar doubleQuote(QLatin1Char('"')); QString rc = doubleQuote; @@ -614,41 +614,41 @@ QString decodeData(const QByteArray &ba, int encoding) rc += doubleQuote; return rc; } - case 4: { // base64 encoded 16 bit data, without quotes (see 2) + case Base64Encoded16Bit: { // 4, without quotes (see 2) const QByteArray decodedBa = QByteArray::fromBase64(ba); return QString::fromUtf16(reinterpret_cast (decodedBa.data()), decodedBa.size() / 2); } - case 5: { // base64 encoded 8 bit data, without quotes (see 1) + case Base64Encoded8Bit: { // 5, without quotes (see 1) return quoteUnprintableLatin1(QByteArray::fromBase64(ba)); } - case 6: { // %02x encoded 8 bit Latin1 data + case Hex2EncodedLatin1: { // 6, %02x encoded 8 bit Latin1 data const QChar doubleQuote(QLatin1Char('"')); const QByteArray decodedBa = QByteArray::fromHex(ba); //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; return doubleQuote + QString::fromLatin1(decodedBa) + doubleQuote; } - case 7: { // %04x encoded 16 bit data, Little Endian + case Hex4EncodedLittleEndian: { // 7, %04x encoded 16 bit data 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 + case Hex8EncodedLittleEndian: { // 8, %08x encoded 32 bit data 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; } - case 9: { // %02x encoded 8 bit Utf-8 data + case Hex2EncodedUtf8: { // 9, %02x encoded 8 bit Utf-8 data const QChar doubleQuote(QLatin1Char('"')); const QByteArray decodedBa = QByteArray::fromHex(ba); //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; return doubleQuote + QString::fromUtf8(decodedBa) + doubleQuote; } - case 10: { // %08x encoded 32 bit data, Big Endian + case Hex8EncodedBigEndian: { // 10, %08x encoded 32 bit data const QChar doubleQuote(QLatin1Char('"')); QByteArray decodedBa = QByteArray::fromHex(ba); for (int i = 0; i < decodedBa.size(); i += 4) { @@ -663,7 +663,7 @@ QString decodeData(const QByteArray &ba, int encoding) return doubleQuote + QString::fromUcs4(reinterpret_cast (decodedBa.data()), decodedBa.size() / 4) + doubleQuote; } - case 11: { // %04x encoded 16 bit data, Big Endian + case Hex4EncodedBigEndian: { // 11, %04x encoded 16 bit data const QChar doubleQuote(QLatin1Char('"')); QByteArray decodedBa = QByteArray::fromHex(ba); for (int i = 0; i < decodedBa.size(); i += 2) { @@ -675,7 +675,7 @@ QString decodeData(const QByteArray &ba, int encoding) return doubleQuote + QString::fromUtf16(reinterpret_cast (decodedBa.data()), decodedBa.size() / 2) + doubleQuote; } - case 12: { // %04x encoded 16 bit data, Little Endian, without quotes (see 7) + case Hex4EncodedLittleEndianWithoutQuotes: { // 12, see 7, without quotes const QByteArray decodedBa = QByteArray::fromHex(ba); //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; return QString::fromUtf16(reinterpret_cast diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h index c0405bda90f..435128cde61 100644 --- a/src/plugins/debugger/watchutils.h +++ b/src/plugins/debugger/watchutils.h @@ -60,6 +60,24 @@ namespace Internal { class WatchData; class GdbMi; +// Keep in sync with dumper.py +enum DebuggerEncoding +{ + Unencoded8Bit = 0, + Base64Encoded8BitWithQuotes = 1, + Base64Encoded16BitWithQuotes = 2, + Base64Encoded32BitWithQuotes = 3, + Base64Encoded16Bit = 4, + Base64Encoded8Bit = 5, + Hex2EncodedLatin1 = 6, + Hex4EncodedLittleEndian = 7, + Hex8EncodedLittleEndian = 8, + Hex2EncodedUtf8 = 9, + Hex8EncodedBigEndian = 10, + Hex4EncodedBigEndian = 11, + Hex4EncodedLittleEndianWithoutQuotes = 12 +}; + bool isEditorDebuggable(Core::IEditor *editor); QByteArray dotEscape(QByteArray str); QString currentTime(); @@ -104,10 +122,8 @@ QString decodeData(const QByteArray &baIn, int encoding); // of a function from the code model. Shadowed variables will // be reported using the debugger naming conventions '' bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot, - const QString &function, - const QString &file, - int line, - QStringList *uninitializedVariables); + const QString &function, const QString &file, int line, + QStringList *uninitializedVariables); /* Attempt to put common code of the dumper handling into a helper * class.