Add support for auto_boolean (true, false or auto).
This commit is contained in:
parent
f09ded2422
commit
97c3646ff2
4 changed files with 154 additions and 6 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
Mon Jun 19 11:29:35 2000 Andrew Cagney <cagney@b1.cygnus.com>
|
||||||
|
|
||||||
|
* command.h (add_set_auto_boolean_cmd): Add declaration.
|
||||||
|
(enum var_types): Add var_auto_boolean.
|
||||||
|
|
||||||
|
* command.c (add_set_auto_boolean_cmd): New function.
|
||||||
|
(do_setshow_command):
|
||||||
|
(parse_binary_operation): Recognize enable and disable.
|
||||||
|
(parse_auto_binary_operation): Parse auto binary variables.
|
||||||
|
|
||||||
|
* TODO: Update
|
||||||
|
|
||||||
Fri Jun 23 16:20:21 2000 Andrew Cagney <cagney@b1.cygnus.com>
|
Fri Jun 23 16:20:21 2000 Andrew Cagney <cagney@b1.cygnus.com>
|
||||||
|
|
||||||
* mips-tdep.c (fp_register_arg_p): New function.
|
* mips-tdep.c (fp_register_arg_p): New function.
|
||||||
|
|
30
gdb/TODO
30
gdb/TODO
|
@ -1121,6 +1121,36 @@ The way GDB throws errors and records them needs a re-think. ui_out
|
||||||
handles the correct output well. It doesn't resolve what to do with
|
handles the correct output well. It doesn't resolve what to do with
|
||||||
output / error-messages when things go wrong.
|
output / error-messages when things go wrong.
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
do_setshow_command contains a 1024 byte buffer.
|
||||||
|
|
||||||
|
The function assumes that there will never be any more than 1024 bytes
|
||||||
|
of enum. It should use mem_file.
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
Should struct cmd_list_element . completer take the command as an
|
||||||
|
argument?
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
Should the bulk of top.c:line_completion_function() be moved to
|
||||||
|
command.[hc]? complete_on_cmdlist() and complete_on_enums() could
|
||||||
|
then be made private.
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
top.c (execute_command): Should a command being valid when the target
|
||||||
|
is running be made an attribute (predicate) to the command rather than
|
||||||
|
an explicit set of tests.
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
top.c (execute_command): Should the bulk of this function be moved
|
||||||
|
into command.[hc] so that top.c doesn't grub around in the command
|
||||||
|
internals?
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
||||||
Architectural Change: Async
|
Architectural Change: Async
|
||||||
|
|
|
@ -327,6 +327,25 @@ add_set_enum_cmd (char *name,
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add element named NAME to command list LIST (the list for set
|
||||||
|
or some sublist thereof).
|
||||||
|
CLASS is as in add_cmd.
|
||||||
|
VAR is address of the variable which will contain the value.
|
||||||
|
DOC is the documentation string. */
|
||||||
|
struct cmd_list_element *
|
||||||
|
add_set_auto_boolean_cmd (char *name,
|
||||||
|
enum command_class class,
|
||||||
|
enum cmd_auto_boolean *var,
|
||||||
|
char *doc,
|
||||||
|
struct cmd_list_element **list)
|
||||||
|
{
|
||||||
|
static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL };
|
||||||
|
struct cmd_list_element *c;
|
||||||
|
c = add_set_cmd (name, class, var_auto_boolean, var, doc, list);
|
||||||
|
c->enums = auto_boolean_enums;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
/* Where SETCMD has already been added, add the corresponding show
|
/* Where SETCMD has already been added, add the corresponding show
|
||||||
command to LIST and return a pointer to the added command (not
|
command to LIST and return a pointer to the added command (not
|
||||||
necessarily the head of LIST). */
|
necessarily the head of LIST). */
|
||||||
|
@ -1530,6 +1549,32 @@ complete_on_enum (const char *enumlist[],
|
||||||
return matchlist;
|
return matchlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum cmd_auto_boolean
|
||||||
|
parse_auto_binary_operation (const char *arg)
|
||||||
|
{
|
||||||
|
if (arg != NULL && *arg != '\0')
|
||||||
|
{
|
||||||
|
int length = strlen (arg);
|
||||||
|
while (isspace (arg[length - 1]) && length > 0)
|
||||||
|
length--;
|
||||||
|
if (strncmp (arg, "on", length) == 0
|
||||||
|
|| strncmp (arg, "1", length) == 0
|
||||||
|
|| strncmp (arg, "yes", length) == 0
|
||||||
|
|| strncmp (arg, "enable", length) == 0)
|
||||||
|
return CMD_AUTO_BOOLEAN_TRUE;
|
||||||
|
else if (strncmp (arg, "off", length) == 0
|
||||||
|
|| strncmp (arg, "0", length) == 0
|
||||||
|
|| strncmp (arg, "no", length) == 0
|
||||||
|
|| strncmp (arg, "disable", length) == 0)
|
||||||
|
return CMD_AUTO_BOOLEAN_FALSE;
|
||||||
|
else if (strncmp (arg, "auto", length) == 0
|
||||||
|
|| (strncmp (arg, "-1", length) == 0 && length > 1))
|
||||||
|
return CMD_AUTO_BOOLEAN_AUTO;
|
||||||
|
}
|
||||||
|
error ("\"on\", \"off\" or \"auto\" expected.");
|
||||||
|
return CMD_AUTO_BOOLEAN_AUTO; /* pacify GCC */
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_binary_operation (arg)
|
parse_binary_operation (arg)
|
||||||
char *arg;
|
char *arg;
|
||||||
|
@ -1544,13 +1589,15 @@ parse_binary_operation (arg)
|
||||||
while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
|
while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
|
||||||
length--;
|
length--;
|
||||||
|
|
||||||
if (!strncmp (arg, "on", length)
|
if (strncmp (arg, "on", length) == 0
|
||||||
|| !strncmp (arg, "1", length)
|
|| strncmp (arg, "1", length) == 0
|
||||||
|| !strncmp (arg, "yes", length))
|
|| strncmp (arg, "yes", length) == 0
|
||||||
|
|| strncmp (arg, "enable", length) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
else if (!strncmp (arg, "off", length)
|
else if (strncmp (arg, "off", length) == 0
|
||||||
|| !strncmp (arg, "0", length)
|
|| strncmp (arg, "0", length) == 0
|
||||||
|| !strncmp (arg, "no", length))
|
|| strncmp (arg, "no", length) == 0
|
||||||
|
|| strncmp (arg, "disable", length) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1635,6 +1682,9 @@ do_setshow_command (arg, from_tty, c)
|
||||||
case var_boolean:
|
case var_boolean:
|
||||||
*(int *) c->var = parse_binary_operation (arg);
|
*(int *) c->var = parse_binary_operation (arg);
|
||||||
break;
|
break;
|
||||||
|
case var_auto_boolean:
|
||||||
|
*(enum cmd_auto_boolean *) c->var = parse_auto_binary_operation (arg);
|
||||||
|
break;
|
||||||
case var_uinteger:
|
case var_uinteger:
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
error_no_arg ("integer to set it to.");
|
error_no_arg ("integer to set it to.");
|
||||||
|
@ -1760,6 +1810,23 @@ do_setshow_command (arg, from_tty, c)
|
||||||
case var_boolean:
|
case var_boolean:
|
||||||
fputs_filtered (*(int *) c->var ? "on" : "off", stb->stream);
|
fputs_filtered (*(int *) c->var ? "on" : "off", stb->stream);
|
||||||
break;
|
break;
|
||||||
|
case var_auto_boolean:
|
||||||
|
switch (*(enum auto_boolean*) c->var)
|
||||||
|
{
|
||||||
|
case CMD_AUTO_BOOLEAN_TRUE:
|
||||||
|
fputs_filtered ("on", stb->stream);
|
||||||
|
break;
|
||||||
|
case CMD_AUTO_BOOLEAN_FALSE:
|
||||||
|
fputs_filtered ("off", stb->stream);
|
||||||
|
break;
|
||||||
|
case CMD_AUTO_BOOLEAN_AUTO:
|
||||||
|
fputs_filtered ("auto", stb->stream);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
internal_error ("do_setshow_command: invalid var_auto_boolean");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case var_uinteger:
|
case var_uinteger:
|
||||||
if (*(unsigned int *) c->var == UINT_MAX)
|
if (*(unsigned int *) c->var == UINT_MAX)
|
||||||
{
|
{
|
||||||
|
@ -1813,6 +1880,23 @@ do_setshow_command (arg, from_tty, c)
|
||||||
case var_boolean:
|
case var_boolean:
|
||||||
fputs_filtered (*(int *) c->var ? "on" : "off", gdb_stdout);
|
fputs_filtered (*(int *) c->var ? "on" : "off", gdb_stdout);
|
||||||
break;
|
break;
|
||||||
|
case var_auto_boolean:
|
||||||
|
switch (*(enum cmd_auto_boolean*) c->var)
|
||||||
|
{
|
||||||
|
case CMD_AUTO_BOOLEAN_TRUE:
|
||||||
|
fputs_filtered ("on", gdb_stdout);
|
||||||
|
break;
|
||||||
|
case CMD_AUTO_BOOLEAN_FALSE:
|
||||||
|
fputs_filtered ("off", gdb_stdout);
|
||||||
|
break;
|
||||||
|
case CMD_AUTO_BOOLEAN_AUTO:
|
||||||
|
fputs_filtered ("auto", gdb_stdout);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
internal_error ("do_setshow_command: invalid var_auto_boolean");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case var_uinteger:
|
case var_uinteger:
|
||||||
if (*(unsigned int *) c->var == UINT_MAX)
|
if (*(unsigned int *) c->var == UINT_MAX)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,12 +47,28 @@ typedef enum cmd_types
|
||||||
}
|
}
|
||||||
cmd_types;
|
cmd_types;
|
||||||
|
|
||||||
|
/* Reasonable values for an AUTO_BOOLEAN variable. */
|
||||||
|
enum cmd_auto_boolean
|
||||||
|
{
|
||||||
|
CMD_AUTO_BOOLEAN_TRUE,
|
||||||
|
CMD_AUTO_BOOLEAN_FALSE,
|
||||||
|
CMD_AUTO_BOOLEAN_AUTO
|
||||||
|
};
|
||||||
|
|
||||||
/* Types of "set" or "show" command. */
|
/* Types of "set" or "show" command. */
|
||||||
typedef enum var_types
|
typedef enum var_types
|
||||||
{
|
{
|
||||||
/* "on" or "off". *VAR is an integer which is nonzero for on,
|
/* "on" or "off". *VAR is an integer which is nonzero for on,
|
||||||
zero for off. */
|
zero for off. */
|
||||||
var_boolean,
|
var_boolean,
|
||||||
|
|
||||||
|
/* "on" / "true" / "enable" or "off" / "false" / "disable" or
|
||||||
|
"auto. *VAR is an ``enum cmd_auto_boolean''. NOTE: In general
|
||||||
|
a custom show command will need to be implemented - one that
|
||||||
|
for "auto" prints both the "auto" and the current auto-selected
|
||||||
|
value. */
|
||||||
|
var_auto_boolean,
|
||||||
|
|
||||||
/* Unsigned Integer. *VAR is an unsigned int. The user can type 0
|
/* Unsigned Integer. *VAR is an unsigned int. The user can type 0
|
||||||
to mean "unlimited", which is stored in *VAR as UINT_MAX. */
|
to mean "unlimited", which is stored in *VAR as UINT_MAX. */
|
||||||
var_uinteger,
|
var_uinteger,
|
||||||
|
@ -299,6 +315,12 @@ extern struct cmd_list_element *add_set_enum_cmd (char *name,
|
||||||
char *doc,
|
char *doc,
|
||||||
struct cmd_list_element **list);
|
struct cmd_list_element **list);
|
||||||
|
|
||||||
|
extern struct cmd_list_element *add_set_auto_boolean_cmd (char *name,
|
||||||
|
enum command_class class,
|
||||||
|
enum cmd_auto_boolean *var,
|
||||||
|
char *doc,
|
||||||
|
struct cmd_list_element **list);
|
||||||
|
|
||||||
extern struct cmd_list_element *add_show_from_set (struct cmd_list_element *,
|
extern struct cmd_list_element *add_show_from_set (struct cmd_list_element *,
|
||||||
struct cmd_list_element
|
struct cmd_list_element
|
||||||
**);
|
**);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue