From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3783 invoked by alias); 2 Feb 2009 22:18:06 -0000 Received: (qmail 3775 invoked by uid 22791); 2 Feb 2009 22:18:06 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_74,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; Mon, 02 Feb 2009 22:18:02 +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 n12MHwkL010593; Mon, 2 Feb 2009 17:17:59 -0500 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 n12MHwH2028131; Mon, 2 Feb 2009 17:17:58 -0500 Received: from opsy.redhat.com (vpn-12-182.rdu.redhat.com [10.11.12.182]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n12MHvpK012734; Mon, 2 Feb 2009 17:17:58 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 3E4F75080FB; Mon, 2 Feb 2009 15:17:51 -0700 (MST) To: Alfredo Ortega Cc: gdb-patches@sourceware.org Subject: Re: Use external editor in 'commands' command References: From: Tom Tromey Reply-To: tromey@redhat.com Date: Mon, 02 Feb 2009 22:18:00 -0000 In-Reply-To: (Alfredo Ortega's message of "Mon\, 19 Jan 2009 09\:45\:31 -0200") 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-02/txt/msg00042.txt.bz2 >>>>> "Alfredo" == Alfredo Ortega writes: Alfredo> 1) Following the suggestion of Tom Tromey, i made "commands" Alfredo> a prefix command, and now it is "commands edit n". Your patch does this using strncmp -- but gdb already has built-in machinery for prefix commands. See add_prefix_cmd. So, the idea here would be to change _initialize_breakpoint to use add_prefix_cmd, instead of add_com, when creating the "commands" command. Then, you'd have a separate function to implement "commands edit". Maybe this means introducing a helper function to do some of the work, I don't know. Alfredo> This is a much better patch, but also is a much bigger one (I already Alfredo> sent the FSF form that Tom suggested), so surely there are plenty of Alfredo> errors. Corrections are welcomed. A few nits inline. Alfredo> +#define COMMANDS_EDCOMMAND "edit" With the prefix change, you won't need this. Alfredo> + /* Edit commands with external editor */ In the GNU style, comments are full sentences that start with a capital letter and end with a period and two spaces. This one is missing the period, but others are incorrect in other ways. Alfredo> + /* discard the "edit" command */ E.g., this one... Alfredo> + get_number (&p); Alfredo> + bnum = get_number (&p); Two calls to get_number seems suspect. Alfredo> + /* vitmp = tempnam(NULL,".gdb"); this is more secure according to man mkstemp, but gcc complains... */ There's no need for this comment, IMO. Alfredo> + if (!(vitmp = make_temp_file (NULL))) GNU style prohibits assignments in conditionals. Alfredo> + { Alfredo> + error (_("Can't create temporary file for editing.")); Alfredo> + return; Alfredo> + } The "error" function never returns. It calls longjmp. So, this return is not needed. This occurs in a few spots. Alfredo> + l = b->commands; Alfredo> + while (l) Alfredo> + { Alfredo> + fsize = 0; Alfredo> + fsize += fwrite (l->line, 1, strlen (l->line), tmpstream); I think you should probably use "print_command_lines" to print the breakpoint commands to a file. Alfredo> + sysret = system (cmdline); Alfredo> + xfree (cmdline); Alfredo> + if (sysret < 0) I think this should also check "sysret" when it is >= 0, and fail if the editor does not exit with status 0. Thanks for working on this, Tom