From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4763 invoked by alias); 31 Jan 2017 15:10:10 -0000 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 Received: (qmail 4200 invoked by uid 89); 31 Jan 2017 15:10:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Jan 2017 15:10:03 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E11F3B3D2; Tue, 31 Jan 2017 15:10:03 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0VFA0ma016986; Tue, 31 Jan 2017 10:10:01 -0500 Subject: Re: [RFA] completion in command definition To: Jerome Guitton References: <1484058481-6378-1-git-send-email-guitton@adacore.com> <81874bfd1c99e89162b98d18fa8cb385@polymtl.ca> <20170111160518.GH27546@adacore.com> <677c2a720f77b21fd672c24efc41c878@polymtl.ca> <20170112100506.GK27546@adacore.com> <41f19570-04ab-cd04-eeb3-77170d258c43@redhat.com> <20170131142910.GA22056@adacore.com> Cc: Simon Marchi , gdb-patches@sourceware.org From: Pedro Alves Message-ID: <5e5f54dc-94f8-37a7-e081-4e729fe71938@redhat.com> Date: Tue, 31 Jan 2017 15:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170131142910.GA22056@adacore.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-01/txt/msg00661.txt.bz2 On 01/31/2017 02:29 PM, Jerome Guitton wrote: > Hi Pedro, > > Pedro Alves (palves@redhat.com): >> > OK (but please remember to edit out the question and "attachment" >> > from the commit log). > I've integrated your comments; I can push the patch in attachment > next week, if no objection. A few minor comments below. > > +/* Return non-zero if CMD's name is NAME. */ s/non-zero/true/. > + > +static bool > +command_name_equals (struct cmd_list_element *cmd, const char *name) > +{ > + return (cmd != NULL > + && cmd != CMD_LIST_AMBIGUOUS > + && strcmp (cmd->name, name) == 0); > +} > + > +/* Given an input line P, skip the command and return a pointer to the > + first argument. */ > + > +static const char * > +line_first_arg (const char *p) > +{ > + const char *first_arg = p + find_command_name_length (p); > + > + return skip_spaces_const (first_arg); > +} > + > /* Process one input line. If the command is an "end", return such an > indication to the caller. If PARSE_COMMANDS is true, strip leading > whitespace (trailing whitespace is always stripped) in the line, > @@ -938,9 +959,14 @@ process_next_line (char *p, struct command_line **command, int parse_commands, > We also permit whitespace before end and after. */ > if (p_end - p_start == 3 && startswith (p_start, "end")) > return end_command; > - > + > if (parse_commands) > { > + /* Resolve command abbreviations (e.g. 'ws' for 'while-stepping'). */ > + const char *cmd_name = p; > + struct cmd_list_element *cmd = > + lookup_cmd_1 (&cmd_name, cmdlist, NULL, 1); "=" goes on the next line: struct cmd_list_element *cmd = lookup_cmd_1 (&cmd_name, cmdlist, NULL, 1); > > +# Verify that the command parser properly handles command abbreviations. > +with_test_prefix "command abbreviations in define" { > + set test "define user command: breakmain" > + gdb_test_multiple "define breakmain" "$test" { > + -re "Type commands for definition of \"breakmain\".\r\nEnd with a line saying just \"end\".\r\n>$" { > + pass "$test" > + set test "send body of breakmain" > + gdb_test_multiple "break main\ncommand\necho\nend\nend" "$test" { > + -re "$gdb_prompt $"\ > + {pass "$test"} > + } > + } > + } > + > + gdb_test "breakmain" ".*Breakpoint .*" "run user command" > + > + # If GDB fails to interpret properly the abbrev "command", the last "end" > + # will be missing. Issue it to avoid a desync that would break the other > + # tests in this file. Double space after period. > + gdb_test "end" ".*This command cannot be used at the top level.*" "additional end command" Too-long line. The initial ".*" in "This command" is not necessary; it's implicit. > + > + gdb_test "info break \$bpnum" \ > + "Num Type\[ \]+Disp Enb Address\[ \]+What.* > +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .* > +\[\t \]+echo.*" I think we need to use use multi_line, to avoid problems with "\n" vs "\r" vs "\r\n". "info break shows echo command" > +} > + > + > # Verify that the command parser doesn't require a space after an 'while' > # command in a user defined function. > # > Thanks, Pedro Alves