From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4189 invoked by alias); 25 Mar 2008 18:52:16 -0000 Received: (qmail 4180 invoked by uid 22791); 25 Mar 2008 18:52:15 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Mar 2008 18:51:50 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m2PIphBX000659; Tue, 25 Mar 2008 14:51:43 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m2PIphTL009168; Tue, 25 Mar 2008 14:51:43 -0400 Received: from opsy.redhat.com (vpn-14-254.rdu.redhat.com [10.11.14.254]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m2PIphL7005261; Tue, 25 Mar 2008 14:51:43 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 3C32B508244; Tue, 25 Mar 2008 11:56:05 -0600 (MDT) To: Jim Blandy Cc: Thiago Jung Bauermann , gdb ml Subject: Re: repo to work on python scripting support References: <1205538908.6643.138.camel@localhost.localdomain> <1206369478.29533.15.camel@localhost.localdomain> <20080325114520.GA21688@caradoc.them.org> <8f2776cb0803251118o316d261erb340d67bb0580967@mail.gmail.com> <20080325183004.GA20107@caradoc.them.org> From: Tom Tromey Reply-To: Tom Tromey X-Attribution: Tom Date: Tue, 25 Mar 2008 19:18:00 -0000 In-Reply-To: <20080325183004.GA20107@caradoc.them.org> (Daniel Jacobowitz's message of "Tue\, 25 Mar 2008 14\:30\:05 -0400") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (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: 2008-03/txt/msg00225.txt.bz2 >>>>> "Daniel" == Daniel Jacobowitz writes: Jim> On Tue, Mar 25, 2008 at 11:18:12AM -0700, Jim Blandy wrote: Jim> I don't know the most Pythonish way of doing things, but it seems to Jim> me that Python could register not functions, but objects, to be Jim> callable with $(). Daniel> Hmm, I've worked with some packages that did similar things using Daniel> mandatory docstrings. We could use decorators. http://wiki.python.org/moin/PythonDecorators Well, assuming they exist. I'm not really that up on the current state of Python. For this particular thing I would be just as happy with some explicit constructor thing: class Strcmp(GdbFunction): def __init__(self): Strcmp.__init__(self, 'strcmp', 'ee') def invoke(expr1, expr2): lalala You could also use a real data structure and named constants: Strcmp.__init__(self, 'strcmp', (gdb.EXPRESSION, gdb.EXPRESSION)) .. or what have you. Aside from the interactive spec, the current gdb-python support for command objects already works this way. A command subclass has to pass in the user-visible command name at construction time. FWIW here's the code I wrote to override "edit" and turn it into an annotation-based command: class Edit(gdb.Command): def __init__(self): gdb.Command.__init__(self, "edit", gdb.COMMAND_NONE) def invoke(self, arg, fromtty): if gdb.show('annotate') > -1: loc = gdb.decode_line(arg) if loc: loc = loc[0] if loc.symtab.to_fullname(): print "\n\x1a\x1asource %s:%d:0:beg:0x0" \ % (loc.symtab.to_fullname(), loc.get_line()) # Install it. Edit() Just to be clear, I don't really want to consider anything in this area as fixed. Advice and input about how everything should fit together is really helpful. Tom