From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35196 invoked by alias); 19 May 2019 19:23:55 -0000 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 Received: (qmail 35188 invoked by uid 89); 19 May 2019 19:23:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=codebase, pretty-printers, GDBINIT, $gdbinit X-HELO: mail-ed1-f41.google.com Received: from mail-ed1-f41.google.com (HELO mail-ed1-f41.google.com) (209.85.208.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 19 May 2019 19:23:50 +0000 Received: by mail-ed1-f41.google.com with SMTP id l25so20155527eda.9 for ; Sun, 19 May 2019 12:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=etIvO/zcnPwESkbdRXk7Lcrwjsbf0EC7SzY64+r9Zrk=; b=t9mLTztiAHDdu1r+JnYyc9bGn13rUyRHe0sdCtZcBdjbXOHifP7r+nXHHgJ8CQQfXy S51V7po4fNU1gT3YHdVGrUFaIsnM0CnM6xCamwBPCriJ+9a6uOxyPEJrcGeJbijx3BAn ILkMV8Q0YnhSnkmKokmZuW1jGkPf3222/cBtxDQ66wM7hz55bKXiYWmHB66SDnzcf5hx 4a4nMIq/vkOflDUIrsFuVrneDGWyOjEtAZOTthZ5eUhq6bUUn6h3v7Mtnj2rScoOHpuu yHBGSF5sM4IlAnIXlsBpKdARtrGGim9Z5iLJ6Q56hesJAATQ5p4vhx+ePQwQzL+RkEao 3qjw== MIME-Version: 1.0 References: In-Reply-To: From: Jean-Marc Saffroy Date: Mon, 20 May 2019 14:57:00 -0000 Message-ID: Subject: Re: Reloading pretty-printers To: =?UTF-8?B?8J+QnQ==?= Cc: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-05/txt/msg00035.txt.bz2 Hi, On Sun, May 19, 2019 at 3:00 PM =F0=9F=90=9D wrote: > Hello, > > I'm writing some pretty-printers for a codebase, and when I modify the > python files with gdb running, I can't seem to use the new version. > giving `source $GDBINIT` or `source $PRETTYPRINTERDOTPY` gives > `pretty-printer already registered` > > Is there a solution to this other than restarting gdb? > When I faced the same problem, I found it useful to simply generate a random name when registering the pretty printer: def _build_pretty_printer(): > # hack: random name allows reloading in the same gdb session! > pp =3D gdb.printing.RegexpCollectionPrettyPrinter( > "xxx.%d"%(random.randint(0, 1000000))) > pp.add_printer('BIGNUM', '^bignum_st$', BNPrinter) > return pp > > gdb.printing.register_pretty_printer( > gdb.current_objfile(), > _build_pretty_printer()) > > Cheers, JM --=20 Jean-Marc Saffroy - saffroy@gmail.com