aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2000-06-23 08:12:27 +0000
committerAndrew Cagney <cagney@redhat.com>2000-06-23 08:12:27 +0000
commit97c3646ff2a8b36e658651abdc0cd8f3c893dc44 (patch)
treeb22716dc60d86e8a9554c2359eb2e04a03a29ade
parentf09ded24229f68245da53149e1ac46a8066057cd (diff)
downloadgdb-97c3646ff2a8b36e658651abdc0cd8f3c893dc44.zip
gdb-97c3646ff2a8b36e658651abdc0cd8f3c893dc44.tar.gz
gdb-97c3646ff2a8b36e658651abdc0cd8f3c893dc44.tar.bz2
Add support for auto_boolean (true, false or auto).
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/TODO30
-rw-r--r--gdb/command.c96
-rw-r--r--gdb/command.h22
4 files changed, 154 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6338d11..73591ae 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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>
* mips-tdep.c (fp_register_arg_p): New function.
diff --git a/gdb/TODO b/gdb/TODO
index d1010b3..d59a8df 100644
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -1123,6 +1123,36 @@ 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
===========================
diff --git a/gdb/command.c b/gdb/command.c
index d9284cd..c7cbbfd 100644
--- a/gdb/command.c
+++ b/gdb/command.c
@@ -327,6 +327,25 @@ add_set_enum_cmd (char *name,
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
command to LIST and return a pointer to the added command (not
necessarily the head of LIST). */
@@ -1530,6 +1549,32 @@ complete_on_enum (const char *enumlist[],
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
parse_binary_operation (arg)
char *arg;
@@ -1544,13 +1589,15 @@ parse_binary_operation (arg)
while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
length--;
- if (!strncmp (arg, "on", length)
- || !strncmp (arg, "1", length)
- || !strncmp (arg, "yes", length))
+ if (strncmp (arg, "on", length) == 0
+ || strncmp (arg, "1", length) == 0
+ || strncmp (arg, "yes", length) == 0
+ || strncmp (arg, "enable", length) == 0)
return 1;
- else if (!strncmp (arg, "off", length)
- || !strncmp (arg, "0", length)
- || !strncmp (arg, "no", length))
+ else if (strncmp (arg, "off", length) == 0
+ || strncmp (arg, "0", length) == 0
+ || strncmp (arg, "no", length) == 0
+ || strncmp (arg, "disable", length) == 0)
return 0;
else
{
@@ -1635,6 +1682,9 @@ do_setshow_command (arg, from_tty, c)
case var_boolean:
*(int *) c->var = parse_binary_operation (arg);
break;
+ case var_auto_boolean:
+ *(enum cmd_auto_boolean *) c->var = parse_auto_binary_operation (arg);
+ break;
case var_uinteger:
if (arg == NULL)
error_no_arg ("integer to set it to.");
@@ -1760,6 +1810,23 @@ do_setshow_command (arg, from_tty, c)
case var_boolean:
fputs_filtered (*(int *) c->var ? "on" : "off", stb->stream);
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:
if (*(unsigned int *) c->var == UINT_MAX)
{
@@ -1813,6 +1880,23 @@ do_setshow_command (arg, from_tty, c)
case var_boolean:
fputs_filtered (*(int *) c->var ? "on" : "off", gdb_stdout);
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:
if (*(unsigned int *) c->var == UINT_MAX)
{
diff --git a/gdb/command.h b/gdb/command.h
index 469df9f..bbafe1b 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -47,12 +47,28 @@ typedef enum 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. */
typedef enum var_types
{
/* "on" or "off". *VAR is an integer which is nonzero for on,
zero for off. */
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
to mean "unlimited", which is stored in *VAR as UINT_MAX. */
var_uinteger,
@@ -299,6 +315,12 @@ extern struct cmd_list_element *add_set_enum_cmd (char *name,
char *doc,
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 *,
struct cmd_list_element
**);