From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3677 invoked by alias); 9 Apr 2009 16:16:41 -0000 Received: (qmail 3645 invoked by uid 22791); 9 Apr 2009 16:16:36 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Apr 2009 16:16:28 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n39GGP88027137; Thu, 9 Apr 2009 12:16:25 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n39GGQBJ017943; Thu, 9 Apr 2009 12:16:26 -0400 Received: from opsy.redhat.com (vpn-13-49.rdu.redhat.com [10.11.13.49]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n39GGOmL008624; Thu, 9 Apr 2009 12:16:25 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 07A3F3781B3; Thu, 9 Apr 2009 10:16:22 -0600 (MDT) To: Eli Zaretskii Cc: gdb-patches@sourceware.org Subject: Re: Python pretty-printing [5/6] References: <83prfm46rv.fsf@gnu.org> From: Tom Tromey Reply-To: Tom Tromey Date: Thu, 09 Apr 2009 16:16:00 -0000 In-Reply-To: <83prfm46rv.fsf@gnu.org> (Eli Zaretskii's message of "Thu\, 09 Apr 2009 10\:37\:24 +0300") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00177.txt.bz2 Eli> I couldn't quite understand the importance of the version numbers, and Eli> how that would allow GDB to have multiple versions of the same Eli> pretty-printer. I asked myself how the ``right'' version will be Eli> selected in that case. Is the way this works documented somewhere Eli> else? if so, a cross-reference here would be good. If not, I think we Eli> need to say a few words about that. I modified a couple of paragraphs; the text now reads: 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 @value{GDBN} to load multiple versions of your pretty-printers at the same time, because they will have different names). You should write auto-loaded code (@pxref{Auto-loading}) such that it can be evaluated multiple times without changing its meaning. An ideal auto-load file will consist solely of @code{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 @value{GDBN} 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, @value{GDBN} will find the correct printers for the specific version of the library used by each inferior. To continue the @code{std::string} example (@pxref{Pretty Printing}), this code might appear in @code{gdb.libstdcxx.v6}: @smallexample [...] >> +You should write auto-loaded code such that it can be evaluated >> +multiple times without changing its meaning. Eli> Here, I suggest a cross-reference to where auto-loading is described. I added this. Tom