Commit eb1b3fb0 authored by hjk's avatar hjk Committed by hjk
Browse files

debugger: make local 8 bit available for displaying char *

Change-Id: I4608f3f861b8f06889199e0401e3b7569587be11
Reviewed-on: http://codereview.qt.nokia.com/1232

Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 98c11649
...@@ -67,8 +67,9 @@ Hex8EncodedLittleEndian, \ ...@@ -67,8 +67,9 @@ Hex8EncodedLittleEndian, \
Hex2EncodedUtf8, \ Hex2EncodedUtf8, \
Hex8EncodedBigEndian, \ Hex8EncodedBigEndian, \
Hex4EncodedBigEndian, \ Hex4EncodedBigEndian, \
Hex4EncodedLittleEndianWithoutQuotes \ Hex4EncodedLittleEndianWithoutQuotes, \
= range(13) Hex2EncodedLocal8Bit \
= range(14)
# Display modes # Display modes
StopDisplay, \ StopDisplay, \
...@@ -1364,12 +1365,9 @@ class Dumper: ...@@ -1364,12 +1365,9 @@ class Dumper:
if value.type.code == gdb.TYPE_CODE_ARRAY: if value.type.code == gdb.TYPE_CODE_ARRAY:
baseptr = value.cast(realtype.pointer()) baseptr = value.cast(realtype.pointer())
if format == 0 or format == 1: if format == 0 or format == 1 or format == 2:
# Explicityly requested Latin1 or UTF-8 formatting. # Explicityly requested Latin1 or UTF-8 formatting.
if format == 0: f = [Hex2EncodedLatin1, Hex2EncodedUtf8, Hex2EncodedLocal8Bit][format]
f = Hex2EncodedLatin1
else:
f = Hex2EncodedUtf8
self.putAddress(value.address) self.putAddress(value.address)
self.putType(realtype) self.putType(realtype)
self.putValue(encodeCharArray(value, 100), f) self.putValue(encodeCharArray(value, 100), f)
...@@ -1484,6 +1482,14 @@ class Dumper: ...@@ -1484,6 +1482,14 @@ class Dumper:
return return
if format == 3: if format == 3:
# Explicityly requested local 8 bit formatting.
self.putAddress(value.address)
self.putType(realtype)
self.putValue(encodeCharArray(value, 100), Hex2EncodedLocal8Bit)
self.putNumChild(0)
return
if format == 4:
# Explitly requested UTF-16 formatting. # Explitly requested UTF-16 formatting.
self.putAddress(value.address) self.putAddress(value.address)
self.putType(realtype) self.putType(realtype)
...@@ -1491,7 +1497,7 @@ class Dumper: ...@@ -1491,7 +1497,7 @@ class Dumper:
self.putNumChild(0) self.putNumChild(0)
return return
if format == 4: if format == 5:
# Explitly requested UCS-4 formatting. # Explitly requested UCS-4 formatting.
self.putAddress(value.address) self.putAddress(value.address)
self.putType(realtype) self.putType(realtype)
......
...@@ -717,12 +717,14 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const ...@@ -717,12 +717,14 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
<< tr("Raw pointer") << tr("Raw pointer")
<< tr("Latin1 string") << tr("Latin1 string")
<< tr("UTF8 string") << tr("UTF8 string")
<< tr("Local 8bit string")
<< tr("UTF16 string") << tr("UTF16 string")
<< tr("UCS4 string"); << tr("UCS4 string");
if (data.type.contains("char[") || data.type.contains("char [")) if (data.type.contains("char[") || data.type.contains("char ["))
return QStringList() return QStringList()
<< tr("Latin1 string") << tr("Latin1 string")
<< tr("UTF8 string"); << tr("UTF8 string")
<< tr("Local 8bit string");
bool ok = false; bool ok = false;
(void)data.value.toULongLong(&ok, 0); (void)data.value.toULongLong(&ok, 0);
if ((isIntType(data.type) && data.type != "bool") || ok) if ((isIntType(data.type) && data.type != "bool") || ok)
......
...@@ -559,27 +559,23 @@ QString decodeData(const QByteArray &ba, int encoding) ...@@ -559,27 +559,23 @@ QString decodeData(const QByteArray &ba, int encoding)
case Hex2EncodedLatin1: { // 6, %02x encoded 8 bit Latin1 data case Hex2EncodedLatin1: { // 6, %02x encoded 8 bit Latin1 data
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";
return doubleQuote + QString::fromLatin1(decodedBa) + doubleQuote; return doubleQuote + QString::fromLatin1(decodedBa) + doubleQuote;
} }
case Hex4EncodedLittleEndian: { // 7, %04x encoded 16 bit data case Hex4EncodedLittleEndian: { // 7, %04x encoded 16 bit data
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";
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 Hex8EncodedLittleEndian: { // 8, %08x encoded 32 bit data case Hex8EncodedLittleEndian: { // 8, %08x encoded 32 bit data
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";
return doubleQuote + QString::fromUcs4(reinterpret_cast<const uint *> return doubleQuote + QString::fromUcs4(reinterpret_cast<const uint *>
(decodedBa.data()), decodedBa.size() / 4) + doubleQuote; (decodedBa.data()), decodedBa.size() / 4) + doubleQuote;
} }
case Hex2EncodedUtf8: { // 9, %02x encoded 8 bit Utf-8 data case Hex2EncodedUtf8: { // 9, %02x encoded 8 bit UTF-8 data
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";
return doubleQuote + QString::fromUtf8(decodedBa) + doubleQuote; return doubleQuote + QString::fromUtf8(decodedBa) + doubleQuote;
} }
case Hex8EncodedBigEndian: { // 10, %08x encoded 32 bit data case Hex8EncodedBigEndian: { // 10, %08x encoded 32 bit data
...@@ -593,7 +589,6 @@ QString decodeData(const QByteArray &ba, int encoding) ...@@ -593,7 +589,6 @@ QString decodeData(const QByteArray &ba, int encoding)
decodedBa[i + 1] = decodedBa.at(i + 2); decodedBa[i + 1] = decodedBa.at(i + 2);
decodedBa[i + 2] = c; decodedBa[i + 2] = c;
} }
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
return doubleQuote + QString::fromUcs4(reinterpret_cast<const uint *> return doubleQuote + QString::fromUcs4(reinterpret_cast<const uint *>
(decodedBa.data()), decodedBa.size() / 4) + doubleQuote; (decodedBa.data()), decodedBa.size() / 4) + doubleQuote;
} }
...@@ -605,16 +600,19 @@ QString decodeData(const QByteArray &ba, int encoding) ...@@ -605,16 +600,19 @@ QString decodeData(const QByteArray &ba, int encoding)
decodedBa[i] = decodedBa.at(i + 1); decodedBa[i] = decodedBa.at(i + 1);
decodedBa[i + 1] = c; decodedBa[i + 1] = c;
} }
//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 Hex4EncodedLittleEndianWithoutQuotes: { // 12, see 7, without quotes case Hex4EncodedLittleEndianWithoutQuotes: { // 12, see 7, without quotes
const QByteArray decodedBa = QByteArray::fromHex(ba); const QByteArray decodedBa = QByteArray::fromHex(ba);
//qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n";
return QString::fromUtf16(reinterpret_cast<const ushort *> return QString::fromUtf16(reinterpret_cast<const ushort *>
(decodedBa.data()), decodedBa.size() / 2); (decodedBa.data()), decodedBa.size() / 2);
} }
case Hex2EncodedLocal8Bit: { // 13, %02x encoded 8 bit UTF-8 data
const QChar doubleQuote(QLatin1Char('"'));
const QByteArray decodedBa = QByteArray::fromHex(ba);
return doubleQuote + QString::fromLocal8Bit(decodedBa) + doubleQuote;
}
} }
qDebug() << "ENCODING ERROR: " << encoding; qDebug() << "ENCODING ERROR: " << encoding;
return QCoreApplication::translate("Debugger", "<Encoding error>"); return QCoreApplication::translate("Debugger", "<Encoding error>");
......
...@@ -68,7 +68,8 @@ enum DebuggerEncoding ...@@ -68,7 +68,8 @@ enum DebuggerEncoding
Hex2EncodedUtf8 = 9, Hex2EncodedUtf8 = 9,
Hex8EncodedBigEndian = 10, Hex8EncodedBigEndian = 10,
Hex4EncodedBigEndian = 11, Hex4EncodedBigEndian = 11,
Hex4EncodedLittleEndianWithoutQuotes = 12 Hex4EncodedLittleEndianWithoutQuotes = 12,
Hex2EncodedLocal8Bit = 13
}; };
bool isEditorDebuggable(Core::IEditor *editor); bool isEditorDebuggable(Core::IEditor *editor);
......
...@@ -1689,29 +1689,66 @@ Foo testStruct() ...@@ -1689,29 +1689,66 @@ Foo testStruct()
return f1; return f1;
} }
void testTypeFormats()
{
// These tests should result in properly displayed umlauts in the
// Locals&Watchers view. It is only support on gdb with Python.
const char *s = "aöa"; namespace formats {
const wchar_t *w = L"aöa";
QString u;
// <== break here
// All: Select UTF-8 in "Change Format for Type" in L&W context menu.
// Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
// Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
if (sizeof(wchar_t) == 4) void testString()
u = QString::fromUcs4((uint *)w); {
else const wchar_t *w = L"aöa";
u = QString::fromUtf16((ushort *)w); QString u;
if (sizeof(wchar_t) == 4)
u = QString::fromUcs4((uint *)w);
else
u = QString::fromUtf16((ushort *)w);
// <== break here
// All: Select UTF-8 in "Change Format for Type" in L&W context menu.
// Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
// Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
dummyStatement(&u, &w);
}
// Make sure to undo "Change Format". void testCharPointers()
Q_UNUSED(s); {
Q_UNUSED(w); // These tests should result in properly displayed umlauts in the
dummyStatement(); // Locals&Watchers view. It is only support on gdb with Python.
}
const char *s = "aöa";
const char *t = "a\xc3\xb6";
const wchar_t *w = L"aöa";
// <== break here
// All: Select UTF-8 in "Change Format for Type" in L&W context menu.
// Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
// Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
// Make sure to undo "Change Format".
dummyStatement(&s, &w);
dummyStatement(&t);
}
void testCharArrays()
{
// These tests should result in properly displayed umlauts in the
// Locals&Watchers view. It is only support on gdb with Python.
const char s[] = "aöa";
const wchar_t w[] = L"aöa";
// <== break here
// All: Select UTF-8 in "Change Format for Type" in L&W context menu.
// Windows: Select UTF-16 in "Change Format for Type" in L&W context menu.
// Other: Select UCS-6 in "Change Format for Type" in L&W context menu.
// Make sure to undo "Change Format".
dummyStatement(&s, &w);
}
void testFormats()
{
testCharPointers();
testCharArrays();
testString();
}
} // namespace formats
void testQTextCursor() void testQTextCursor()
...@@ -3187,7 +3224,8 @@ int main(int argc, char *argv[]) ...@@ -3187,7 +3224,8 @@ int main(int argc, char *argv[])
testStdStack(); testStdStack();
testStdString(); testStdString();
testStdVector(); testStdVector();
testTypeFormats();
formats::testFormats();
testPassByReference(); testPassByReference();
testPlugin(); testPlugin();
......
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