Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Anton Kunze <ak@technosis.de>
Cc: gdb@sourceware.org
Subject: Re: Printing of strings with special characters
Date: Mon, 08 Mar 2010 19:41:00 -0000	[thread overview]
Message-ID: <m37hpmtxdf.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4B94BC31.3020109@technosis.de> (Anton Kunze's message of "Mon, 	08 Mar 2010 09:58:25 +0100")

>>>>> "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


  parent reply	other threads:[~2010-03-08 19:41 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 [this message]
2010-03-09  7:54           ` Anton Kunze
2010-03-09 19:56             ` Niko Sams
2010-03-09 10:29           ` André Pönitz

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=m37hpmtxdf.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=ak@technosis.de \
    --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