forked from qt-creator/qt-creator
Debugger: add support for dumping non-ASCII UTF-8 QChar
Change-Id: I87d9557c1e5b945972ddf3f63f8cb064514a3b54 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -456,7 +456,7 @@ def cleanAddress(addr):
|
|||||||
|
|
||||||
# Some "Enums"
|
# Some "Enums"
|
||||||
|
|
||||||
# Encodings. Keep that synchronized with DebuggerEncoding in watchutils.h
|
# Encodings. Keep that synchronized with DebuggerEncoding in debuggerprotocol.h
|
||||||
Unencoded8Bit, \
|
Unencoded8Bit, \
|
||||||
Base64Encoded8BitWithQuotes, \
|
Base64Encoded8BitWithQuotes, \
|
||||||
Base64Encoded16BitWithQuotes, \
|
Base64Encoded16BitWithQuotes, \
|
||||||
@@ -484,8 +484,9 @@ Hex2EncodedUInt4, \
|
|||||||
Hex2EncodedUInt8, \
|
Hex2EncodedUInt8, \
|
||||||
Hex2EncodedFloat4, \
|
Hex2EncodedFloat4, \
|
||||||
Hex2EncodedFloat8, \
|
Hex2EncodedFloat8, \
|
||||||
IPv6AddressAndHexScopeId \
|
IPv6AddressAndHexScopeId, \
|
||||||
= range(28)
|
Hex2EncodedUtf8WithoutQuotes \
|
||||||
|
= range(29)
|
||||||
|
|
||||||
# Display modes. Keep that synchronized with DebuggerDisplay in watchutils.h
|
# Display modes. Keep that synchronized with DebuggerDisplay in watchutils.h
|
||||||
StopDisplay, \
|
StopDisplay, \
|
||||||
|
|||||||
@@ -397,22 +397,6 @@ def importPlainDumpers(args):
|
|||||||
registerCommand("importPlainDumpers", importPlainDumpers)
|
registerCommand("importPlainDumpers", importPlainDumpers)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Fails on Windows.
|
|
||||||
try:
|
|
||||||
import curses.ascii
|
|
||||||
def printableChar(ucs):
|
|
||||||
if curses.ascii.isprint(ucs):
|
|
||||||
return ucs
|
|
||||||
return '?'
|
|
||||||
except:
|
|
||||||
def printableChar(ucs):
|
|
||||||
if ucs >= 32 and ucs <= 126:
|
|
||||||
return ucs
|
|
||||||
return '?'
|
|
||||||
|
|
||||||
|
|
||||||
#gdb.Value.child = impl_Value_child
|
#gdb.Value.child = impl_Value_child
|
||||||
|
|
||||||
# Fails on SimulatorQt.
|
# Fails on SimulatorQt.
|
||||||
|
|||||||
@@ -49,22 +49,20 @@ def qdump__QByteArray(d, value):
|
|||||||
d.putArrayData(d.charType(), data, size)
|
d.putArrayData(d.charType(), data, size)
|
||||||
|
|
||||||
|
|
||||||
# Fails on Windows.
|
def str2Utf8hex2(s):
|
||||||
try:
|
# Returns UTF-8 hex-data of string suitable for QByteArray::fromHex()
|
||||||
import curses.ascii
|
ret = []
|
||||||
def printableChar(ucs):
|
for c in s.encode('utf-8'):
|
||||||
if curses.ascii.isprint(ucs):
|
ret.append('%02x' % ord(c))
|
||||||
return ucs
|
return ''.join(ret)
|
||||||
return '?'
|
|
||||||
except:
|
|
||||||
def printableChar(ucs):
|
|
||||||
if ucs >= 32 and ucs <= 126:
|
|
||||||
return ucs
|
|
||||||
return '?'
|
|
||||||
|
|
||||||
def qdump__QChar(d, value):
|
def qdump__QChar(d, value):
|
||||||
ucs = int(value["ucs"])
|
ucs = int(value["ucs"])
|
||||||
d.putValue("'%c' (%d)" % (printableChar(ucs), ucs))
|
if ucs < 32:
|
||||||
|
ch = '?'
|
||||||
|
else:
|
||||||
|
ch = unichr(ucs)
|
||||||
|
d.putValue(str2Utf8hex2(u"'%s' (%d)" % (ch, ucs)), Hex2EncodedUtf8WithoutQuotes)
|
||||||
d.putNumChild(0)
|
d.putNumChild(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -624,6 +624,10 @@ QString decodeData(const QByteArray &ba, int encoding)
|
|||||||
scopeId.length() / 2));
|
scopeId.length() / 2));
|
||||||
return ip6.toString();
|
return ip6.toString();
|
||||||
}
|
}
|
||||||
|
case Hex2EncodedUtf8WithoutQuotes: { // 28, %02x encoded 8 bit UTF-8 data without quotes
|
||||||
|
const QByteArray decodedBa = QByteArray::fromHex(ba);
|
||||||
|
return QString::fromUtf8(decodedBa);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "ENCODING ERROR: " << encoding;
|
qDebug() << "ENCODING ERROR: " << encoding;
|
||||||
return QCoreApplication::translate("Debugger", "<Encoding error>");
|
return QCoreApplication::translate("Debugger", "<Encoding error>");
|
||||||
|
|||||||
@@ -203,7 +203,8 @@ enum DebuggerEncoding
|
|||||||
Hex2EncodedUInt8 = 24,
|
Hex2EncodedUInt8 = 24,
|
||||||
Hex2EncodedFloat4 = 25,
|
Hex2EncodedFloat4 = 25,
|
||||||
Hex2EncodedFloat8 = 26,
|
Hex2EncodedFloat8 = 26,
|
||||||
IPv6AddressAndHexScopeId = 27
|
IPv6AddressAndHexScopeId = 27,
|
||||||
|
Hex2EncodedUtf8WithoutQuotes = 28
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep in sync with dumper.py, symbolgroupvalue.cpp of CDB
|
// Keep in sync with dumper.py, symbolgroupvalue.cpp of CDB
|
||||||
|
|||||||
Reference in New Issue
Block a user