Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [committed]:[obv] Handle var_string_noescape and var_optional_filename together.
Date: Thu, 19 Jul 2012 07:54:00 -0000	[thread overview]
Message-ID: <78989086.O2ThAENbim@qiyao.dyndns.org> (raw)
In-Reply-To: <20120718152615.GA20923@host2.jankratochvil.net>

On Wednesday, July 18, 2012 05:26:15 PM Jan Kratochvil wrote:
> Just it has a sort-of-regression:
> (gdb) set args ~
> (gdb) show args
> Argument list to give program being debugged when it is started is "~".
> ->
> Argument list to give program being debugged when it is started is
> "/home/jkratoch".
> 

I don't see "set args ~" in testsuite, so I add it into gdb.base/setshow.exp.

> Therefore please modify also:
>   add_setshow_optional_filename_cmd ("args", class_run,
> 
> to rather use add_setshow_string_noescape_cmd together with:
>   set_cmd_completer (set_result, filename_completer);
> 

Done as you suggested.  Regression tested on x86_64 native gdb.  Committed.  
Jan, thanks for the review.

-- 
Yao (齐尧)

gdb:

2012-07-20  Yao Qi  <yao@codesourcery.com>
	      Jan Kratochvil <jan.kratochvil@redhat.com>

	* cli/cli-setshow.c (do_setshow_command): Handle case 'var_filename'
	and case 'var_optional_filename' together.
	* infcmd.c (_initialize_infcmd): Call add_setshow_string_noescape_cmd
	instead of add_setshow_optional_filename_cmd for setshow command
	'args'.  Set completer for 'set args'.

gdb/testsuite:

2012-07-20  Yao Qi  <yao@codesourcery.com>

	* gdb.base/setshow.exp: Test 'set args ~'.
---
 gdb/cli/cli-setshow.c              |   30 +++++++++++++++---------------
 gdb/infcmd.c                       |   15 ++++++++++-----
 gdb/testsuite/gdb.base/setshow.exp |    4 ++++
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 521ac0e..dccf425 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -182,27 +182,27 @@ do_setshow_command (char *arg, int from_tty, struct 
cmd_list_element *c)
 	    xfree (*(char **) c->var);
 	  *(char **) c->var = xstrdup (arg);
 	  break;
-	case var_optional_filename:
-	  if (arg == NULL)
-	    arg = "";
-	  if (*(char **) c->var != NULL)
-	    xfree (*(char **) c->var);
-	  *(char **) c->var = xstrdup (arg);
-	  break;
 	case var_filename:
 	  if (arg == NULL)
 	    error_no_arg (_("filename to set it to."));
+	  /* FALLTHROUGH */
+	case var_optional_filename:
 	  if (*(char **) c->var != NULL)
 	    xfree (*(char **) c->var);
-	  {
-	    /* Clear trailing whitespace of filename.  */
-	    char *ptr = arg + strlen (arg) - 1;
 
-	    while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
-	      ptr--;
-	    *(ptr + 1) = '\0';
-	  }
-	  *(char **) c->var = tilde_expand (arg);
+	  if (arg != NULL)
+	    {
+	      /* Clear trailing whitespace of filename.  */
+	      char *ptr = arg + strlen (arg) - 1;
+
+	      while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+		ptr--;
+	      *(ptr + 1) = '\0';
+
+	      *(char **) c->var = tilde_expand (arg);
+	    }
+	  else
+	    *(char **) c->var = xstrdup ("");
 	  break;
 	case var_boolean:
 	  *(int *) c->var = parse_binary_operation (arg);
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 475ac90..635e577 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2918,6 +2918,7 @@ _initialize_infcmd (void)
 {
   static struct cmd_list_element *info_proc_cmdlist;
   struct cmd_list_element *c = NULL;
+  char *cmd_name;
 
   /* Add the filename of the terminal connected to inferior I/O.  */
   add_setshow_filename_cmd ("inferior-tty", class_run,
@@ -2930,14 +2931,18 @@ Usage: set inferior-tty /dev/pts/1"),
 			    &setlist, &showlist);
   add_com_alias ("tty", "set inferior-tty", class_alias, 0);
 
-  add_setshow_optional_filename_cmd ("args", class_run,
-				     &inferior_args_scratch, _("\
+  cmd_name = "args";
+  add_setshow_string_noescape_cmd (cmd_name, class_run,
+				   &inferior_args_scratch, _("\
 Set argument list to give program being debugged when it is started."), _("\
 Show argument list to give program being debugged when it is started."), _("\
 Follow this command with any number of args, to be passed to the program."),
-				     set_args_command,
-				     show_args_command,
-				     &setlist, &showlist);
+				   set_args_command,
+				   show_args_command,
+				   &setlist, &showlist);
+  c = lookup_cmd (&cmd_name, setlist, "", -1, 1);
+  gdb_assert (c != NULL);
+  set_cmd_completer (c, filename_completer);
 
   c = add_cmd ("environment", no_class, environment_info, _("\
 The environment to give the program, or one variable's value.\n\
diff --git a/gdb/testsuite/gdb.base/setshow.exp 
b/gdb/testsuite/gdb.base/setshow.exp
index b218314..9af5c30 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -87,6 +87,10 @@ gdb_test_no_output "set annotate 0" "set annotate 0"
 gdb_test "show annotate" "Annotation_level is 0..*"  "show annotate (0)" 
 #test annotation_level 0
 gdb_test "info line 1" "Line 1 of .* is at address .* but contains no code.*"  
"annotation_level 0" 
+
+gdb_test_no_output "set args ~"
+gdb_test "show args" "Argument list to give program being debugged when it is 
started is \"~\"..*" \
+    "show args ~"
 #test set args
 gdb_test_no_output "set args foo bar blup baz bubble" "set args" 
 #test show args
-- 
1.7.7.6



  reply	other threads:[~2012-07-19  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 12:41 [obv] " Yao Qi
2012-07-18 13:57 ` Jan Kratochvil
2012-07-18 14:59   ` Yao Qi
2012-07-18 15:26     ` Jan Kratochvil
2012-07-19  7:54       ` Yao Qi [this message]
2012-07-19  7:58         ` [committed]:[obv] " Jan Kratochvil

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=78989086.O2ThAENbim@qiyao.dyndns.org \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /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