This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Printing of strings with special characters
>>>>> "Anton" == Anton Kunze <ak@technosis.de> writes:
Anton> http://websvn.kde.org/trunk/extragear/sdk/kdevelop/debuggers/gdb/printers/
Also, the QStringPrinter code seems suspect to me:
class QStringPrinter:
def __init__(self, val):
self.val = val
def to_string(self):
ret = ""
i = 0
while i < self.val['d']['size']:
if self.val['d']['data'][i] > 256:
#TODO: fix this properly
ret += '?'
else:
ret += chr(self.val['d']['data'][i])
i = i + 1
return ret
This is constructing a string by hand, and using '?' to replace some
characters.
It is better to use Value.string or Value.lazy_string. From the
qstring.h in code search, I gather that this is UTF-16-encoded, so this
should probably read:
return self.val['d']['data'].string(encoding = 'UTF-16', length = self.val['d']['size'])
... though I have never really used Qt, so take with a grain of salt.
Use lazy_string if you have a newer gdb.
Tom