* 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.
This commit is contained in:
parent
06d66ee9d9
commit
44478ab340
6 changed files with 68 additions and 17 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2013-01-14 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2013-01-14 Tom Tromey <tromey@redhat.com>
|
2013-01-14 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
PR symtab/14442:
|
PR symtab/14442:
|
||||||
|
|
|
@ -597,7 +597,7 @@ add_setshow_string_cmd (char *name, enum command_class class,
|
||||||
|
|
||||||
/* Add element named NAME to both the set and show command LISTs (the
|
/* Add element named NAME to both the set and show command LISTs (the
|
||||||
list for set/show or some sublist thereof). */
|
list for set/show or some sublist thereof). */
|
||||||
void
|
struct cmd_list_element *
|
||||||
add_setshow_string_noescape_cmd (char *name, enum command_class class,
|
add_setshow_string_noescape_cmd (char *name, enum command_class class,
|
||||||
char **var,
|
char **var,
|
||||||
const char *set_doc, const char *show_doc,
|
const char *set_doc, const char *show_doc,
|
||||||
|
@ -607,11 +607,14 @@ add_setshow_string_noescape_cmd (char *name, enum command_class class,
|
||||||
struct cmd_list_element **set_list,
|
struct cmd_list_element **set_list,
|
||||||
struct cmd_list_element **show_list)
|
struct cmd_list_element **show_list)
|
||||||
{
|
{
|
||||||
|
struct cmd_list_element *set_cmd;
|
||||||
|
|
||||||
add_setshow_cmd_full (name, class, var_string_noescape, var,
|
add_setshow_cmd_full (name, class, var_string_noescape, var,
|
||||||
set_doc, show_doc, help_doc,
|
set_doc, show_doc, help_doc,
|
||||||
set_func, show_func,
|
set_func, show_func,
|
||||||
set_list, show_list,
|
set_list, show_list,
|
||||||
NULL, NULL);
|
&set_cmd, NULL);
|
||||||
|
return set_cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add element named NAME to both the set and show command LISTs (the
|
/* Add element named NAME to both the set and show command LISTs (the
|
||||||
|
|
|
@ -291,16 +291,17 @@ extern void add_setshow_string_cmd (char *name,
|
||||||
struct cmd_list_element **set_list,
|
struct cmd_list_element **set_list,
|
||||||
struct cmd_list_element **show_list);
|
struct cmd_list_element **show_list);
|
||||||
|
|
||||||
extern void add_setshow_string_noescape_cmd (char *name,
|
extern struct cmd_list_element *add_setshow_string_noescape_cmd
|
||||||
enum command_class class,
|
(char *name,
|
||||||
char **var,
|
enum command_class class,
|
||||||
const char *set_doc,
|
char **var,
|
||||||
const char *show_doc,
|
const char *set_doc,
|
||||||
const char *help_doc,
|
const char *show_doc,
|
||||||
cmd_sfunc_ftype *set_func,
|
const char *help_doc,
|
||||||
show_value_ftype *show_func,
|
cmd_sfunc_ftype *set_func,
|
||||||
struct cmd_list_element **set_list,
|
show_value_ftype *show_func,
|
||||||
struct cmd_list_element **show_list);
|
struct cmd_list_element **set_list,
|
||||||
|
struct cmd_list_element **show_list);
|
||||||
|
|
||||||
extern void add_setshow_optional_filename_cmd (char *name,
|
extern void add_setshow_optional_filename_cmd (char *name,
|
||||||
enum command_class class,
|
enum command_class class,
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "completer.h"
|
#include "completer.h"
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "observer.h"
|
#include "observer.h"
|
||||||
|
#include "cli/cli-utils.h"
|
||||||
|
|
||||||
/* Local function declarations. */
|
/* Local function declarations. */
|
||||||
|
|
||||||
|
@ -419,12 +420,40 @@ static void
|
||||||
set_gnutarget_command (char *ignore, int from_tty,
|
set_gnutarget_command (char *ignore, int from_tty,
|
||||||
struct cmd_list_element *c)
|
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)
|
if (strcmp (gnutarget_string, "auto") == 0)
|
||||||
gnutarget = NULL;
|
gnutarget = NULL;
|
||||||
else
|
else
|
||||||
gnutarget = gnutarget_string;
|
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. */
|
/* Set the gnutarget. */
|
||||||
void
|
void
|
||||||
set_gnutarget (char *newtarget)
|
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);
|
set_cmd_completer (c, filename_completer);
|
||||||
|
|
||||||
|
|
||||||
add_setshow_string_noescape_cmd ("gnutarget", class_files,
|
c = add_setshow_string_noescape_cmd ("gnutarget", class_files,
|
||||||
&gnutarget_string, _("\
|
&gnutarget_string, _("\
|
||||||
Set the current BFD target."), _("\
|
Set the current BFD target."), _("\
|
||||||
Show the current BFD target."), _("\
|
Show the current BFD target."), _("\
|
||||||
Use `set gnutarget auto' to specify automatic detection."),
|
Use `set gnutarget auto' to specify automatic detection."),
|
||||||
set_gnutarget_command,
|
set_gnutarget_command,
|
||||||
show_gnutarget_string,
|
show_gnutarget_string,
|
||||||
&setlist, &showlist);
|
&setlist, &showlist);
|
||||||
|
set_cmd_completer (c, complete_set_gnutarget);
|
||||||
|
|
||||||
add_alias_cmd ("g", "gnutarget", class_files, 1, &setlist);
|
add_alias_cmd ("g", "gnutarget", class_files, 1, &setlist);
|
||||||
|
|
||||||
if (getenv ("GNUTARGET"))
|
if (getenv ("GNUTARGET"))
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2013-01-14 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* gdb.base/completion.exp: Add "set gnutarget" test.
|
||||||
|
|
||||||
2013-01-14 Tom Tromey <tromey@redhat.com>
|
2013-01-14 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* gdb.dwarf2/dw2-restrict.S: New file.
|
* gdb.dwarf2/dw2-restrict.S: New file.
|
||||||
|
|
|
@ -707,6 +707,9 @@ gdb_test "complete ptype struct some_" "ptype struct some_struct"
|
||||||
gdb_test "complete ptype enum some_" "ptype enum some_enum"
|
gdb_test "complete ptype enum some_" "ptype enum some_enum"
|
||||||
gdb_test "complete ptype union some_" "ptype union some_union"
|
gdb_test "complete ptype union some_" "ptype union some_union"
|
||||||
|
|
||||||
|
|
||||||
|
gdb_test "complete set gnutarget aut" "set gnutarget auto"
|
||||||
|
|
||||||
# Restore globals modified in this test...
|
# Restore globals modified in this test...
|
||||||
set timeout $oldtimeout1
|
set timeout $oldtimeout1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue