From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22315 invoked by alias); 23 May 2011 15:06:15 -0000 Received: (qmail 22303 invoked by uid 22791); 23 May 2011 15:06:14 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 15:06:00 +0000 Received: from kpbe17.cbf.corp.google.com (kpbe17.cbf.corp.google.com [172.25.105.81]) by smtp-out.google.com with ESMTP id p4NF5vqk017273 for ; Mon, 23 May 2011 08:05:58 -0700 Received: from gwj21 (gwj21.prod.google.com [10.200.10.21]) by kpbe17.cbf.corp.google.com with ESMTP id p4NF5ucM016890 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 23 May 2011 08:05:56 -0700 Received: by gwj21 with SMTP id 21so2743324gwj.2 for ; Mon, 23 May 2011 08:05:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.91.33.1 with SMTP id l1mr3284285agj.207.1306163151164; Mon, 23 May 2011 08:05:51 -0700 (PDT) Received: by 10.90.72.6 with HTTP; Mon, 23 May 2011 08:05:51 -0700 (PDT) In-Reply-To: <1AAE9F25-87D5-44F0-BCF8-B6C3A5D20203@astro.princeton.edu> References: <1AAE9F25-87D5-44F0-BCF8-B6C3A5D20203@astro.princeton.edu> Date: Mon, 23 May 2011 15:06:00 -0000 Message-ID: Subject: Re: Problem redefining python pretty printers From: Doug Evans To: Robert Lupton the Good Cc: gdb 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: 2011-05/txt/msg00124.txt.bz2 On Sat, May 21, 2011 at 6:41 PM, Robert Lupton the Good wrote: > Using the 7.2.90.20110521-cvs (i.e. 7.3-branch) version, the docs say: >> Help on function register_pretty_printer in module gdb.printing: >> >> register_pretty_printer(obj, printer) >> =A0 =A0 Register pretty-printer PRINTER with OBJ. >> >> =A0 =A0 The printer is added to the front of the search list, thus one c= an override >> =A0 =A0 an existing printer if one needs to. > > which makes sense if one's working on a new printer. =A0Unfortunately: > >> (gdb) python import sourcePrinter; sourcePrinter.register(); sourcePrint= er.register() >> Traceback (most recent call last): >> =A0 File "", line 1, in >> =A0 File "/home/rhl/Bugs/gdb-pp/sourcePrinter.py", line 35, in register >> =A0 =A0 gdb.printing.register_pretty_printer(gdb, printer) >> =A0 File "/home/astro/hsc/products/Linux64/external/gdb/7.3-1/share/gdb/= python/gdb/printing.py", line 131, in register_pretty_printer >> =A0 =A0 printer.name) >> RuntimeError: pretty-printer already registered: afw >> Error while executing Python code. > > The routine register is: >> def register(): >> =A0 =A0 printer =3D gdb.printing.RegexpCollectionPrettyPrinter("afw") >> =A0 =A0 gdb.printing.register_pretty_printer(gdb, printer) > > Any advice on what I'm doing wrong? =A0I suppose I could come up with a n= ew name each time, but that seems a little clumsy. You're not doing anything wrong, per se. I think we need to handle this use-case though. gdb could either provide a way to replace an existing pretty-printer or delete it so that it can be re-added.