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"
|
||||
|
||||
# Encodings. Keep that synchronized with DebuggerEncoding in watchutils.h
|
||||
# Encodings. Keep that synchronized with DebuggerEncoding in debuggerprotocol.h
|
||||
Unencoded8Bit, \
|
||||
Base64Encoded8BitWithQuotes, \
|
||||
Base64Encoded16BitWithQuotes, \
|
||||
@@ -484,8 +484,9 @@ Hex2EncodedUInt4, \
|
||||
Hex2EncodedUInt8, \
|
||||
Hex2EncodedFloat4, \
|
||||
Hex2EncodedFloat8, \
|
||||
IPv6AddressAndHexScopeId \
|
||||
= range(28)
|
||||
IPv6AddressAndHexScopeId, \
|
||||
Hex2EncodedUtf8WithoutQuotes \
|
||||
= range(29)
|
||||
|
||||
# Display modes. Keep that synchronized with DebuggerDisplay in watchutils.h
|
||||
StopDisplay, \
|
||||
|
||||
@@ -397,22 +397,6 @@ def importPlainDumpers(args):
|
||||
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
|
||||
|
||||
# Fails on SimulatorQt.
|
||||
|
||||
@@ -49,22 +49,20 @@ def qdump__QByteArray(d, value):
|
||||
d.putArrayData(d.charType(), data, size)
|
||||
|
||||
|
||||
# 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 '?'
|
||||
def str2Utf8hex2(s):
|
||||
# Returns UTF-8 hex-data of string suitable for QByteArray::fromHex()
|
||||
ret = []
|
||||
for c in s.encode('utf-8'):
|
||||
ret.append('%02x' % ord(c))
|
||||
return ''.join(ret)
|
||||
|
||||
def qdump__QChar(d, value):
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -624,6 +624,10 @@ QString decodeData(const QByteArray &ba, int encoding)
|
||||
scopeId.length() / 2));
|
||||
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;
|
||||
return QCoreApplication::translate("Debugger", "<Encoding error>");
|
||||
|
||||
@@ -203,7 +203,8 @@ enum DebuggerEncoding
|
||||
Hex2EncodedUInt8 = 24,
|
||||
Hex2EncodedFloat4 = 25,
|
||||
Hex2EncodedFloat8 = 26,
|
||||
IPv6AddressAndHexScopeId = 27
|
||||
IPv6AddressAndHexScopeId = 27,
|
||||
Hex2EncodedUtf8WithoutQuotes = 28
|
||||
};
|
||||
|
||||
// Keep in sync with dumper.py, symbolgroupvalue.cpp of CDB
|
||||
|
||||
Reference in New Issue
Block a user