From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15372 invoked by alias); 10 Nov 2009 08:06:27 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 15351 invoked by uid 22791); 10 Nov 2009 08:06:25 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <58596C4646708B4BB990C44839973330013A61DE@usplmvpbe001.ent.rt.verigy.net> References: <20091110021158.C3C2576D70@ppluzhnikov.mtv.corp.google.com> <58596C4646708B4BB990C44839973330013A61DE@usplmvpbe001.ent.rt.verigy.net> Date: Tue, 10 Nov 2009 08:06:00 -0000 Message-ID: <8ac60eac0911100006yc31e2acmba7bf9fde33ddfa@mail.gmail.com> Subject: Re: [python] Pretty-printers and addressprint From: Paul Pluzhnikov To: "Elmenthaler, Jens" Cc: gdb@sourceware.org, archer@sourceware.org, dje@google.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-SW-Source: 2009-q4/txt/msg00048.txt.bz2 On Mon, Nov 9, 2009 at 11:25 PM, Elmenthaler, Jens wrote: > The gdb.Value class has a string() method, you could try this in your to_= string method: > =A0 =A0 =A0 =A0return self.val['whybother']['contents'].string() That doesn't quite do what I want, but this almost does: return '"' + self.val['whybother']['contents'].string() + '"' However, consider a modification of the original test: - string x =3D make_string ("this is x"); + string x =3D make_string ("this is x\201\202\203\204"); With the original pretty-printer, this produces: $4 =3D 0x4007e0 "this is x\201\202\203\204" which is exactly what I want, if only it didn't have the address. With proposed patch, it produces exactly what I want: $4 =3D "this is x\201\202\203\204" But this value can't be converted to a python string in ASCII charset: the modified printer produces this: $4 =3D Traceback (most recent call last): File "../../../src/gdb/testsuite/gdb.python/py-prettyprint.py", line 27, in to_string return self.val['whybother']['contents'].string() UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 9: ordinal not in range(128) Unfortunately I frequently deal with non-ascii strings, and the problem just wouldn't go away :-( Previous threads on this subject, e.g. http://sourceware.org/ml/archer/2008-q4/msg00180.html didn't appear to have reached a satisfactory conclusion. Thanks, --=20 Paul Pluzhnikov