With integer commands that support "unlimited", we currently fail to
notice junk after "unlimited":
(gdb) show print elements
Limit on string chars or array elements to print is 200.
(gdb) set print elements unlimited foo
(gdb) show print elements
Limit on string chars or array elements to print is unlimited.
This commit fixes that. After, we get:
(gdb) set print elements unlimited foo
Junk after "unlimited": foo
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-setshow.c (cli/cli-setshow.c): New parameter
'expression'. When parsing an expression, error out if there's
junk after "unlimited".
(parse_cli_var_uinteger, parse_cli_var_zuinteger_unlimited)
(do_set_command): Adjust calls to is_unlimited_literal.
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/settings.exp (test-integer): Test junk after
"unlimited".
2019-06-13 Pedro Alves <palves@redhat.com>
2019-06-13 Pedro Alves <palves@redhat.com>
+ * cli/cli-setshow.c (cli/cli-setshow.c): New parameter
+ 'expression'. When parsing an expression, error out if there's
+ junk after "unlimited".
+ (parse_cli_var_uinteger, parse_cli_var_zuinteger_unlimited)
+ (do_set_command): Adjust calls to is_unlimited_literal.
+
+2019-06-13 Pedro Alves <palves@redhat.com>
+
* compile/compile.c (make_compile_options_def_group): Add braces
around array_view initializer.
* thread.c (make_thread_apply_all_options_def_group)
* compile/compile.c (make_compile_options_def_group): Add braces
around array_view initializer.
* thread.c (make_thread_apply_all_options_def_group)
/* Returns true if ARG is "unlimited". */
static bool
/* Returns true if ARG is "unlimited". */
static bool
-is_unlimited_literal (const char **arg)
+is_unlimited_literal (const char **arg, bool expression)
{
*arg = skip_spaces (*arg);
{
*arg = skip_spaces (*arg);
+ const char *unl_start = *arg;
+
const char *p = skip_to_space (*arg);
size_t len = p - *arg;
const char *p = skip_to_space (*arg);
size_t len = p - *arg;
if (len > 0 && strncmp ("unlimited", *arg, len) == 0)
{
*arg += len;
if (len > 0 && strncmp ("unlimited", *arg, len) == 0)
{
*arg += len;
+
+ /* If parsing an expression (i.e., parsing for a "set" command),
+ anything after "unlimited" is junk. For options, anything
+ after "unlimited" might be a command argument or another
+ option. */
+ if (expression)
+ {
+ const char *after = skip_spaces (*arg);
+ if (*after != '\0')
+ error (_("Junk after \"%.*s\": %s"),
+ (int) len, unl_start, after);
+ }
+
error_no_arg (_("integer to set it to."));
}
error_no_arg (_("integer to set it to."));
}
- if (var_type == var_uinteger && is_unlimited_literal (arg))
+ if (var_type == var_uinteger && is_unlimited_literal (arg, expression))
val = 0;
else if (expression)
val = parse_and_eval_long (*arg);
val = 0;
else if (expression)
val = parse_and_eval_long (*arg);
if (*arg == nullptr)
error_no_arg (_("integer to set it to, or \"unlimited\"."));
if (*arg == nullptr)
error_no_arg (_("integer to set it to, or \"unlimited\"."));
- if (is_unlimited_literal (arg))
+ if (is_unlimited_literal (arg, expression))
val = -1;
else if (expression)
val = parse_and_eval_long (*arg);
val = -1;
else if (expression)
val = parse_and_eval_long (*arg);
error_no_arg (_("integer to set it to."));
}
error_no_arg (_("integer to set it to."));
}
- if (c->var_type == var_integer && is_unlimited_literal (&arg))
+ if (c->var_type == var_integer && is_unlimited_literal (&arg, true))
val = 0;
else
val = parse_and_eval_long (arg);
val = 0;
else
val = parse_and_eval_long (arg);
2019-06-13 Pedro Alves <palves@redhat.com>
2019-06-13 Pedro Alves <palves@redhat.com>
+ * gdb.base/settings.exp (test-integer): Test junk after
+ "unlimited".
+
+2019-06-13 Pedro Alves <palves@redhat.com>
+
* gdb.base/options.exp (test-thread-apply): New.
(top level): Call it.
* gdb.base/options.exp (test-thread-apply): New.
(top level): Call it.
+ # Check junk after "unlimited".
gdb_test "$set_cmd unlimitedu" "No symbol table is loaded.*"
gdb_test "$set_cmd unlimitedu" "No symbol table is loaded.*"
+ if {$variant == "zinteger" || $variant == "zuinteger"} {
+ gdb_test "$set_cmd unlimited u" "No symbol table is loaded.*"
+ gdb_test "$set_cmd unlimited 1" "No symbol table is loaded.*"
+ gdb_test "$set_cmd unlimited -1" "No symbol table is loaded.*"
+ } else {
+ gdb_test "$set_cmd unlimited u" "Junk after \"unlimited\": u"
+ gdb_test "$set_cmd unlimited 1" "Junk after \"unlimited\": 1"
+ gdb_test "$set_cmd unlimited -1" "Junk after \"unlimited\": -1"
+ }
+
test_gdb_complete_none "$set_cmd unlimited "
test_gdb_complete_none "$set_cmd unlimitedu"
test_gdb_complete_none "$set_cmd unlimited u"
test_gdb_complete_none "$set_cmd unlimited "
test_gdb_complete_none "$set_cmd unlimitedu"
test_gdb_complete_none "$set_cmd unlimited u"