From: Yao Qi Date: Thu, 19 Jul 2012 12:48:17 +0000 (+0000) Subject: * cli/cli-setshow.c (do_setshow_command): Handle case 'var_filename' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6ace3df1ec836a2c7aaabbd32877229757fae412;p=binutils-gdb.git * 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: * gdb.base/setshow.exp: Test 'set args ~'. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 171a02edb84..ffaeb2209d7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2012-07-19 Yao Qi + Jan Kratochvil + + * 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'. + 2012-07-18 Doug Evans * common/gdb_vecs.h: Moved here from ./gdb_vecs.h. diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 521ac0e0011..dccf4255429 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 475ac90e1cc..635e577eda1 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/ChangeLog b/gdb/testsuite/ChangeLog index b98d6fa6603..1b22c3c0d33 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-07-19 Yao Qi + + * gdb.base/setshow.exp: Test 'set args ~'. + 2012-07-16 Jan Kratochvil * gdb.base/store.exp (check_set): Import gdb_prompt. diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp index b2183143120..9af5c30346c 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