Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>,
	GDB Patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	Jerome Guitton <guitton@adacore.com>
Subject: Re: [PATCH] PR cli/21688: Detect aliases when issuing python/compile/guile commands (and fix last commit)
Date: Fri, 30 Jun 2017 13:02:00 -0000	[thread overview]
Message-ID: <68b70606-368f-63ba-b410-5d03865337df@redhat.com> (raw)
In-Reply-To: <20170630123426.2124-1-sergiodj@redhat.com>


On 06/30/2017 01:34 PM, Sergio Durigan Junior wrote:

> @@ -966,6 +952,8 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
>        const char *cmd_name = p;
>        struct cmd_list_element *cmd
>  	= lookup_cmd_1 (&cmd_name, cmdlist, NULL, 1);
> +      const char *lookup_cmd = skip_spaces_const (cmd_name);
> +      bool inline_cmd = *lookup_cmd != '\0';

The "lookup_cmd" in my suggestion:

~~~~~
 lookup_cmd = skip_spaces_const (cmd_name);
~~~~~

was a typo/pasto from "lookup_cmd_1"...  I meant:

 cmd_name = skip_spaces_const (cmd_name);

Fine with me to use a new variable like you had, but
it should have a name that actually means something
related to the task at hand.  "cmd_arg" or something.

>  	  /* Note that we ignore the inline "guile command" form here.  */
>  	  *command = build_command_line (guile_control, "");
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 06bf5a4..6160c4b 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,6 +1,12 @@
>  2017-06-30  Sergio Durigan Junior  <sergiodj@redhat.com>
>  
>  	PR cli/21688
> +	* gdb.python/py-cmd.exp (test_python_inline_or_multiline): Add new
> +	tests for alias commands and trailing whitespace.
> +
> +2017-06-30  Sergio Durigan Junior  <sergiodj@redhat.com>
> +
> +	PR cli/21688
>  	* gdb.python/py-cmd.exp (test_python_inline_or_multiline): New
>  	procedure.  Call it.
>  
> diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
> index 39bb785..287ecda 100644
> --- a/gdb/testsuite/gdb.python/py-cmd.exp
> +++ b/gdb/testsuite/gdb.python/py-cmd.exp
> @@ -194,12 +194,25 @@ proc test_python_inline_or_multiline { } {
>  	{ "end"                  " >$"            "multi-line first end" }
>  	{ "end"                  "hello\r\n"      "multi-line last end" } }
>  
> +    # This also tests trailing whitespace on the command.
> +    set define_cmd_alias_not_inline {
> +	{ "if 1"                 " >$"            "multi-line if 1 alias" }
> +	{ "py    "               " >$"            "multi-line python command alias" }
> +	{ "print ('hello')"      "  >$"           "multi-line print alias" }
> +	{ "end"                  " >$"            "multi-line first end alias" }
> +	{ "end"                  "hello\r\n"      "multi-line last end alias" } }
> +
>      set define_cmd_inline {
>  	{ "if 1"                      " >$"          "inline if 1" }
>  	{ "python print ('hello')"    " >$"          "inline python command" }
>  	{ "end"                       "hello\r\n"    "inline end" } }
>  
> -    foreach t [list $define_cmd_not_inline $define_cmd_inline] {
> +    set define_cmd_alias_inline {
> +	{ "if 1"                      " >$"          "inline if 1 alias" }
> +	{ "py print ('hello')"    " >$"          "inline python command alias" }
> +	{ "end"                       "hello\r\n"    "inline end alias" } }
> +

Any reason you didn't add a test for the "alias foo=python" case?
We want to be sure that aliases that are not abbreviations are
handled too.  "py" is probably really implemented as a
disambiguating alias, due to "python-interactive", but it could be an 
abbreviation too [py, pyt, pyth], etc.  I think an explicit test for
a non-abbreviation alias would be good, to be sure the code isn't just
doing a "startswith"-like check.  Otherwise, I'm going to ask for a
test that exercises abbreviations, like for example "compil", but you
don't want that. :-)

Thanks,
Pedro Alves


  reply	other threads:[~2017-06-30 13:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  2:05 [PATCH] PR cli/21688: Fix multi-line/inline command differentiation Sergio Durigan Junior
2017-06-29 12:51 ` Jerome Guitton
2017-06-29 19:08 ` Simon Marchi
2017-06-29 19:48   ` Sergio Durigan Junior
2017-06-29 21:06     ` Simon Marchi
2017-06-29 22:21       ` Sergio Durigan Junior
2017-06-30  7:01         ` Simon Marchi
2017-06-30 11:16           ` Sergio Durigan Junior
2017-06-30 11:14         ` Pedro Alves
2017-06-30 11:24           ` Sergio Durigan Junior
2017-06-30 11:30             ` Pedro Alves
2017-06-30 12:33               ` Sergio Durigan Junior
2017-06-30 12:34               ` [PATCH] PR cli/21688: Detect aliases when issuing python/compile/guile commands (and fix last commit) Sergio Durigan Junior
2017-06-30 13:02                 ` Pedro Alves [this message]
2017-06-30 13:33                   ` Sergio Durigan Junior
2017-06-30 13:49                     ` Pedro Alves
2017-06-30 13:51                       ` Sergio Durigan Junior

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=68b70606-368f-63ba-b410-5d03865337df@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guitton@adacore.com \
    --cc=sergiodj@redhat.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