From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15370 invoked by alias); 10 Nov 2009 08:06:27 -0000 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 Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Nov 2009 08:06:21 +0000 Received: from zps37.corp.google.com (zps37.corp.google.com [172.25.146.37]) by smtp-out.google.com with ESMTP id nAA86I0f005084; Tue, 10 Nov 2009 00:06:19 -0800 Received: from pxi5 (pxi5.prod.google.com [10.243.27.5]) by zps37.corp.google.com with ESMTP id nAA86G3G023200; Tue, 10 Nov 2009 00:06:16 -0800 Received: by pxi5 with SMTP id 5so2657079pxi.12 for ; Tue, 10 Nov 2009 00:06:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.3.29 with SMTP id 29mr99672wac.208.1257840375600; Tue, 10 Nov 2009 00:06:15 -0800 (PST) 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 10:22: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-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-11/txt/msg00110.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