Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Jerome Guitton <guitton@adacore.com>
Cc: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [RFA] completion in command definition
Date: Tue, 31 Jan 2017 15:10:00 -0000	[thread overview]
Message-ID: <5e5f54dc-94f8-37a7-e081-4e729fe71938@redhat.com> (raw)
In-Reply-To: <20170131142910.GA22056@adacore.com>

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


  reply	other threads:[~2017-01-31 15:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 14:28 Jerome Guitton
2017-01-10 16:27 ` Simon Marchi
2017-01-11 16:05   ` Jerome Guitton
2017-01-11 16:14     ` Simon Marchi
2017-01-12 10:05       ` Jerome Guitton
2017-01-19 14:55         ` Pedro Alves
2017-01-31 14:29           ` Jerome Guitton
2017-01-31 15:10             ` Pedro Alves [this message]
2017-01-31 15:29               ` Jerome Guitton
2017-01-31 15:53                 ` Pedro Alves
2017-01-31 16:04                   ` Jerome Guitton
2017-01-31 16:05                     ` Pedro Alves
2017-02-08 17:59                       ` Jerome Guitton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e5f54dc-94f8-37a7-e081-4e729fe71938@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guitton@adacore.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox