aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c34
-rw-r--r--gdb/cli/cli-setshow.c49
2 files changed, 74 insertions, 9 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 61a7b5a..9bc14b5 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -638,6 +638,22 @@ add_setshow_optional_filename_cmd (const char *name, enum command_class class,
}
+/* Completes on literal "unlimited". Used by integer commands that
+ support a special "unlimited" value. */
+
+static VEC (char_ptr) *
+integer_unlimited_completer (struct cmd_list_element *ignore,
+ const char *text, const char *word)
+{
+ static const char * const keywords[] =
+ {
+ "unlimited",
+ NULL,
+ };
+
+ return complete_on_enum (keywords, text, word);
+}
+
/* Add element named NAME to both the set and show command LISTs (the
list for set/show or some sublist thereof). CLASS is as in
add_cmd. VAR is address of the variable which will contain the
@@ -653,11 +669,15 @@ add_setshow_integer_cmd (const char *name, enum command_class class,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list)
{
+ struct cmd_list_element *set;
+
add_setshow_cmd_full (name, class, var_integer, var,
set_doc, show_doc, help_doc,
set_func, show_func,
set_list, show_list,
- NULL, NULL);
+ &set, NULL);
+
+ set_cmd_completer (set, integer_unlimited_completer);
}
/* Add element named NAME to both the set and show command LISTs (the
@@ -674,11 +694,15 @@ add_setshow_uinteger_cmd (const char *name, enum command_class class,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list)
{
+ struct cmd_list_element *set;
+
add_setshow_cmd_full (name, class, var_uinteger, var,
set_doc, show_doc, help_doc,
set_func, show_func,
set_list, show_list,
- NULL, NULL);
+ &set, NULL);
+
+ set_cmd_completer (set, integer_unlimited_completer);
}
/* Add element named NAME to both the set and show command LISTs (the
@@ -714,11 +738,15 @@ add_setshow_zuinteger_unlimited_cmd (const char *name,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list)
{
+ struct cmd_list_element *set;
+
add_setshow_cmd_full (name, class, var_zuinteger_unlimited, var,
set_doc, show_doc, help_doc,
set_func, show_func,
set_list, show_list,
- NULL, NULL);
+ &set, NULL);
+
+ set_cmd_completer (set, integer_unlimited_completer);
}
/* Add element named NAME to both the set and show command LISTs (the
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index f612369..3e41fd4 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -28,6 +28,7 @@
#include "cli/cli-decode.h"
#include "cli/cli-cmds.h"
#include "cli/cli-setshow.h"
+#include "cli/cli-utils.h"
/* Return true if the change of command parameter should be notified. */
@@ -127,6 +128,20 @@ deprecated_show_value_hack (struct ui_file *ignore_file,
}
}
+/* Returns true if ARG is "unlimited". */
+
+static int
+is_unlimited_literal (const char *arg)
+{
+ size_t len = sizeof ("unlimited") - 1;
+
+ arg = skip_spaces_const (arg);
+
+ return (strncmp (arg, "unlimited", len) == 0
+ && (isspace (arg[len]) || arg[len] == '\0'));
+}
+
+
/* Do a "set" command. ARG is NULL if no argument, or the
text of the argument, and FROM_TTY is nonzero if this command is
being entered directly by the user (i.e. these are just like any
@@ -273,8 +288,17 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
LONGEST val;
if (arg == NULL)
- error_no_arg (_("integer to set it to."));
- val = parse_and_eval_long (arg);
+ {
+ if (c->var_type == var_uinteger)
+ error_no_arg (_("integer to set it to, or \"unlimited\"."));
+ else
+ error_no_arg (_("integer to set it to."));
+ }
+
+ if (c->var_type == var_uinteger && is_unlimited_literal (arg))
+ val = 0;
+ else
+ val = parse_and_eval_long (arg);
if (c->var_type == var_uinteger && val == 0)
val = UINT_MAX;
@@ -300,8 +324,17 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
LONGEST val;
if (arg == NULL)
- error_no_arg (_("integer to set it to."));
- val = parse_and_eval_long (arg);
+ {
+ if (c->var_type == var_integer)
+ error_no_arg (_("integer to set it to, or \"unlimited\"."));
+ else
+ error_no_arg (_("integer to set it to."));
+ }
+
+ if (c->var_type == var_integer && is_unlimited_literal (arg))
+ val = 0;
+ else
+ val = parse_and_eval_long (arg);
if (val == 0 && c->var_type == var_integer)
val = INT_MAX;
@@ -396,8 +429,12 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
LONGEST val;
if (arg == NULL)
- error_no_arg (_("integer to set it to."));
- val = parse_and_eval_long (arg);
+ error_no_arg (_("integer to set it to, or \"unlimited\"."));
+
+ if (is_unlimited_literal (arg))
+ val = -1;
+ else
+ val = parse_and_eval_long (arg);
if (val > INT_MAX)
error (_("integer %s out of range"), plongest (val));