summaryrefslogtreecommitdiff
path: root/gdb/corefile.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-01-14 21:05:07 +0000
committerTom Tromey <tromey@redhat.com>2013-01-14 21:05:07 +0000
commit44478ab3404a5416c1864f8b47ad28eaca7bb0d9 (patch)
tree19712603f7ece0901405ea9f0598eff0b3f172dc /gdb/corefile.c
parent06d66ee9d97cf451db4bdd7952eca099bc171706 (diff)
downloadbinutils-gdb-44478ab3404a5416c1864f8b47ad28eaca7bb0d9.tar.gz
* cli/cli-decode.c (add_setshow_string_noescape_cmd): Return the
set command. * command.h (add_setshow_string_noescape_cmd): Update. * corefile.c (set_gnutarget_command): Remove trailing whitespace. (complete_set_gnutarget): New function. (_initialize_core): Set the "set gnutarget" completer. gdb/testsuite * gdb.base/completion.exp: Add "set gnutarget" test.
Diffstat (limited to 'gdb/corefile.c')
-rw-r--r--gdb/corefile.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/gdb/corefile.c b/gdb/corefile.c
index e940e3cba3f..b268d4cbc05 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -34,6 +34,7 @@
#include "completer.h"
#include "exceptions.h"
#include "observer.h"
+#include "cli/cli-utils.h"
/* Local function declarations. */
@@ -419,12 +420,40 @@ static void
set_gnutarget_command (char *ignore, int from_tty,
struct cmd_list_element *c)
{
+ char *gend = gnutarget_string + strlen (gnutarget_string);
+
+ gend = remove_trailing_whitespace (gnutarget_string, gend);
+ *gend = '\0';
+
if (strcmp (gnutarget_string, "auto") == 0)
gnutarget = NULL;
else
gnutarget = gnutarget_string;
}
+/* A completion function for "set gnutarget". */
+
+static VEC (char_ptr) *
+complete_set_gnutarget (struct cmd_list_element *cmd, char *text, char *word)
+{
+ static const char **bfd_targets;
+
+ if (bfd_targets == NULL)
+ {
+ int last;
+
+ bfd_targets = bfd_target_list ();
+ for (last = 0; bfd_targets[last] != NULL; ++last)
+ ;
+
+ bfd_targets = xrealloc (bfd_targets, (last + 2) * sizeof (const char **));
+ bfd_targets[last] = "auto";
+ bfd_targets[last + 1] = NULL;
+ }
+
+ return complete_on_enum (bfd_targets, text, word);
+}
+
/* Set the gnutarget. */
void
set_gnutarget (char *newtarget)
@@ -447,14 +476,16 @@ No arg means have no core file. This command has been superseded by the\n\
set_cmd_completer (c, filename_completer);
- add_setshow_string_noescape_cmd ("gnutarget", class_files,
- &gnutarget_string, _("\
+ c = add_setshow_string_noescape_cmd ("gnutarget", class_files,
+ &gnutarget_string, _("\
Set the current BFD target."), _("\
Show the current BFD target."), _("\
Use `set gnutarget auto' to specify automatic detection."),
- set_gnutarget_command,
- show_gnutarget_string,
- &setlist, &showlist);
+ set_gnutarget_command,
+ show_gnutarget_string,
+ &setlist, &showlist);
+ set_cmd_completer (c, complete_set_gnutarget);
+
add_alias_cmd ("g", "gnutarget", class_files, 1, &setlist);
if (getenv ("GNUTARGET"))