From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12101 invoked by alias); 22 Mar 2011 17:00:35 -0000 Received: (qmail 12091 invoked by uid 22791); 22 Mar 2011 17:00:34 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Mar 2011 17:00:27 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2MH0ONg010026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Mar 2011 13:00:24 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2MH0NY2021476; Tue, 22 Mar 2011 13:00:24 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p2MH0MOg014876; Tue, 22 Mar 2011 13:00:23 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 9C921378491; Tue, 22 Mar 2011 11:00:22 -0600 (MDT) From: Tom Tromey To: Kevin Pouget Cc: gdb@sourceware.org Subject: Re: Python objfile-gdb.py file -- how to handle reloading properly ? References: Date: Tue, 22 Mar 2011 17:00:00 -0000 In-Reply-To: (Kevin Pouget's message of "Tue, 22 Mar 2011 10:07:07 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-03/txt/msg00122.txt.bz2 >>>>> "Kevin" == Kevin Pouget writes: Kevin> I'm playing with the objfile-gdb.py loading, and I can't manage to Kevin> support the reloading efficiently: [...] Kevin> which looks like a ugly hack! Did you find any better solution? Yeah, have your hook file be very small and have it import the real printers. The documentation lays out the best approach: We recommend that you put your core pretty-printers into a Python package. If your pretty-printers are for use with a library, we further recommend embedding a version number into the package name. This practice will enable GDB to load multiple versions of your pretty-printers at the same time, because they will have different names. You should write auto-loaded code (*note Auto-loading::) such that it can be evaluated multiple times without changing its meaning. An ideal auto-load file will consist solely of `import's of your printer modules, followed by a call to a register pretty-printers with the current objfile. Taken as a whole, this approach will scale nicely to multiple inferiors, each potentially using a different library version. Embedding a version number in the Python package name will ensure that GDB is able to load both sets of printers simultaneously. Then, because the search for pretty-printers is done by objfile, and because your auto-loaded code took care to register your library's printers with a specific objfile, GDB will find the correct printers for the specific version of the library used by each inferior. Tom