From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18459 invoked by alias); 4 Feb 2009 00:32:02 -0000 Received: (qmail 18449 invoked by uid 22791); 4 Feb 2009 00:32:00 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Feb 2009 00:31:55 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id B9E3F10A40; Wed, 4 Feb 2009 00:31:53 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id 8BFA510A3F; Wed, 4 Feb 2009 00:31:53 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1LUVgH-0007x3-1A; Tue, 03 Feb 2009 19:31:53 -0500 Date: Wed, 04 Feb 2009 00:32:00 -0000 From: Daniel Jacobowitz To: Thiago Jung Bauermann Cc: gdb-patches ml Subject: Re: [RFC][python] Add support for commands implemented in Python Message-ID: <20090204003153.GA26840@caradoc.them.org> Mail-Followup-To: Thiago Jung Bauermann , gdb-patches ml References: <1233580405.7000.13.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1233580405.7000.13.camel@localhost.localdomain> User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes 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-02/txt/msg00083.txt.bz2 On Mon, Feb 02, 2009 at 11:13:25AM -0200, Thiago Jung Bauermann wrote: > +@defmethod Command invoke argument from_tty > +This method is called by @value{GDBN} when this command is invoked. > + > +@var{argument} is the argument to the command. The argument > +ordinarily is a string, but may be @code{None}, meaning that there was > +no argument. Any opinion on making it always a string? The 'do I get NULL or an empty string?' ambiguity shows up every time I write a new command in C. If you prefer None, let's document what whitespace trimming does or does not happen before it is converted from a string to None. > +@defmethod Command complete text word > +This method is called by @value{GDBN} when the user attempts @key{TAB} > +completion on this command. > + > +The arguments @var{text} and @var{word} are both strings. @var{text} > +holds the complete command line up to the cursor's location. > +@var{word} holds the last word of the command line; this is computed > +using a word-breaking heuristic. > + > +The @code{invoke} method can return several values: Isn't this @code{complete} method? Same problem repeated below. > +/* A gdb command. For the time being only ordinary commands (not > + set/show commands) are allowed. */ > +struct cmdpy_object > +{ > + PyObject_HEAD > + > + /* The corresponding gdb command object, or NULL if the command is > + no longer installed. */ > + struct cmd_list_element *command; > + > + /* For a prefix command, this is the list of sub-commands. */ > + struct cmd_list_element *sub_list; > +}; What's sub_list for? There's *command->prefixlist too. Overall, I'm confused about why prefix commands are 'special' here. When core GDB adds a command, it doesn't need any new code to handle it as a prefix; just calls add_prefix_cmd. I'd expect to do the same here but fill in a local FUN. > + /* Note: alias and user seem to be special; pseudo appears to be > + unused, and there is no reason to expose tui or xdb, I think. */ Yes, alias and user are special. User is where "define"'d commands go; should there be a command to show all Python-defined commands similar to "show user"? The rest of the code looks fine. -- Daniel Jacobowitz CodeSourcery