From: "André Pönitz" <andre.poenitz@nokia.com>
To: gdb@sourceware.org
Subject: Re: Printing of strings with special characters
Date: Tue, 09 Mar 2010 10:29:00 -0000 [thread overview]
Message-ID: <201003091129.56867.andre.poenitz@nokia.com> (raw)
In-Reply-To: <m37hpmtxdf.fsf@fleche.redhat.com>
On Monday 08 March 2010 20:41:00 Tom Tromey wrote:
> >>>>> "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'])
I think I tried something like that when I started to use gdb/python and it
did not really work for corrupted data (like uninitialized objects or "real"
corruption).
At least I ended up transferring the raw data to the frontend and let that
decide on how to present it.
Andre'
prev parent reply other threads:[~2010-03-09 10:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 11:57 Anton Kunze
2010-03-04 18:09 ` Tom Tromey
2010-03-04 21:25 ` Anton Kunze
2010-03-05 8:33 ` Anton Kunze
2010-03-05 15:41 ` Tom Tromey
2010-03-08 9:00 ` Anton Kunze
2010-03-08 18:03 ` Tom Tromey
2010-03-09 7:49 ` Anton Kunze
2010-03-08 19:41 ` Tom Tromey
2010-03-09 7:54 ` Anton Kunze
2010-03-09 19:56 ` Niko Sams
2010-03-09 10:29 ` André Pönitz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201003091129.56867.andre.poenitz@nokia.com \
--to=andre.poenitz@nokia.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox