Make gdb::option::complete_options save processed arguments too
Currently, gdb::option::complete_options just discards any processed option argument, because no completer needs that data. When completing "pipe -d XXX gdbcmd XXX" however, the completer needs to know about -d's argument (XXX), in order to know where input is already past the gdb command and the delimiter. In this commit, the fix for that is the factoring out of the save_option_value_in_ctx function and calling it in complete_options. For testing, this makes "maint show test-options-completion-result" show the processed options too, like what the "maint test-options" subcommands output when run. Then, of course, gdb.base/options.exp is adjusted. Doing this exposed a couple latent bugs, which is what the other gdb changes in the patch are for: - in the var_enum case, without the change, we'd end up with a null enum argument, and print: "-enum (null)" - The get_ulongest change is necessary to avoid advancing PP in a case where we end up throwing an error, e.g., when parsing "11x". Without the change the operand pointer shown by "maint show test-options-completion-result" would be left pointing at "x" instead of "11x". gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * cli/cli-option.c (parse_option) <var_enum>: Don't return an option_value with a null enumeration. (complete_options): Save the option values in the context. (save_option_value_in_ctx): New, factored out from ... (process_options): ... here. * cli/cli-utils.c (get_ulongest): Don't advance PP until the end of the function. * maint-test-options.c (test_options_opts::dump): New, factored out from ... (maintenance_test_options_command_mode): ... here. (maintenance_test_options_command_completion_result): Delete. (maintenance_test_options_command_completion_text): Update comment. (maintenance_show_test_options_completion_result): Change prototype. Just print maintenance_test_options_command_completion_text. (save_completion_result): New. (maintenance_test_options_completer_mode): Pass options context to complete_options, and then save a dump. (_initialize_maint_test_options): Use add_cmd to install "maint show test-options-completion-result". gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/options.exp (test-misc, test-flag, test-boolean) (test-uinteger, test-enum): Adjust res_test_gdb_... calls to pass the expected output in the success.
This commit is contained in:
parent
b2b2a21598
commit
41fc454c91
6 changed files with 225 additions and 105 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
2019-07-03 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* cli/cli-option.c (parse_option) <var_enum>: Don't return an
|
||||||
|
option_value with a null enumeration.
|
||||||
|
(complete_options): Save the option values in the context.
|
||||||
|
(save_option_value_in_ctx): New, factored out from ...
|
||||||
|
(process_options): ... here.
|
||||||
|
* cli/cli-utils.c (get_ulongest): Don't advance PP until the end
|
||||||
|
of the function.
|
||||||
|
* maint-test-options.c (test_options_opts::dump): New, factored
|
||||||
|
out from ...
|
||||||
|
(maintenance_test_options_command_mode): ... here.
|
||||||
|
(maintenance_test_options_command_completion_result): Delete.
|
||||||
|
(maintenance_test_options_command_completion_text): Update
|
||||||
|
comment.
|
||||||
|
(maintenance_show_test_options_completion_result): Change
|
||||||
|
prototype. Just print
|
||||||
|
maintenance_test_options_command_completion_text.
|
||||||
|
(save_completion_result): New.
|
||||||
|
(maintenance_test_options_completer_mode): Pass options context to
|
||||||
|
complete_options, and then save a dump.
|
||||||
|
(_initialize_maint_test_options): Use add_cmd to install "maint
|
||||||
|
show test-options-completion-result".
|
||||||
|
|
||||||
2019-07-03 Pedro Alves <palves@redhat.com>
|
2019-07-03 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* NEWS (New commands): Mention "with" and "maint with".
|
* NEWS (New commands): Mention "with" and "maint with".
|
||||||
|
|
|
@ -58,6 +58,8 @@ struct option_def_and_value
|
||||||
gdb::optional<option_value> value;
|
gdb::optional<option_value> value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov);
|
||||||
|
|
||||||
/* Info passed around when handling completion. */
|
/* Info passed around when handling completion. */
|
||||||
struct parse_option_completion_info
|
struct parse_option_completion_info
|
||||||
{
|
{
|
||||||
|
@ -349,11 +351,12 @@ parse_option (gdb::array_view<const option_def_group> options_group,
|
||||||
{
|
{
|
||||||
complete_on_enum (completion->tracker,
|
complete_on_enum (completion->tracker,
|
||||||
match->enums, *args, *args);
|
match->enums, *args, *args);
|
||||||
*args = after_arg;
|
if (completion->tracker.have_completions ())
|
||||||
|
return {};
|
||||||
|
|
||||||
option_value val;
|
/* If we don't have completions, let the
|
||||||
val.enumeration = nullptr;
|
non-completion path throw on invalid enum value
|
||||||
return option_def_and_value {*match, match_ctx, val};
|
below, so that completion processing stops. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,6 +459,11 @@ complete_options (completion_tracker &tracker,
|
||||||
(*args - text);
|
(*args - text);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the caller passed in a context, then it is
|
||||||
|
interested in the option argument values. */
|
||||||
|
if (ov && ov->ctx != nullptr)
|
||||||
|
save_option_value_in_ctx (ov);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -499,6 +507,36 @@ complete_options (completion_tracker &tracker,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save the parsed value in the option's context. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov)
|
||||||
|
{
|
||||||
|
switch (ov->option.type)
|
||||||
|
{
|
||||||
|
case var_boolean:
|
||||||
|
{
|
||||||
|
bool value = ov->value.has_value () ? ov->value->boolean : true;
|
||||||
|
*ov->option.var_address.boolean (ov->option, ov->ctx) = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case var_uinteger:
|
||||||
|
*ov->option.var_address.uinteger (ov->option, ov->ctx)
|
||||||
|
= ov->value->uinteger;
|
||||||
|
break;
|
||||||
|
case var_zuinteger_unlimited:
|
||||||
|
*ov->option.var_address.integer (ov->option, ov->ctx)
|
||||||
|
= ov->value->integer;
|
||||||
|
break;
|
||||||
|
case var_enum:
|
||||||
|
*ov->option.var_address.enumeration (ov->option, ov->ctx)
|
||||||
|
= ov->value->enumeration;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gdb_assert_not_reached ("unhandled option type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* See cli-option.h. */
|
/* See cli-option.h. */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -534,29 +572,7 @@ process_options (const char **args,
|
||||||
|
|
||||||
processed_any = true;
|
processed_any = true;
|
||||||
|
|
||||||
switch (ov->option.type)
|
save_option_value_in_ctx (ov);
|
||||||
{
|
|
||||||
case var_boolean:
|
|
||||||
{
|
|
||||||
bool value = ov->value.has_value () ? ov->value->boolean : true;
|
|
||||||
*ov->option.var_address.boolean (ov->option, ov->ctx) = value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case var_uinteger:
|
|
||||||
*ov->option.var_address.uinteger (ov->option, ov->ctx)
|
|
||||||
= ov->value->uinteger;
|
|
||||||
break;
|
|
||||||
case var_zuinteger_unlimited:
|
|
||||||
*ov->option.var_address.integer (ov->option, ov->ctx)
|
|
||||||
= ov->value->integer;
|
|
||||||
break;
|
|
||||||
case var_enum:
|
|
||||||
*ov->option.var_address.enumeration (ov->option, ov->ctx)
|
|
||||||
= ov->value->enumeration;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
gdb_assert_not_reached ("unhandled option type");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,13 +60,14 @@ get_ulongest (const char **pp, int trailer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retval = strtoulst (p, pp, 0);
|
const char *end = p;
|
||||||
if (p == *pp)
|
retval = strtoulst (p, &end, 0);
|
||||||
|
if (p == end)
|
||||||
{
|
{
|
||||||
/* There is no number here. (e.g. "cond a == b"). */
|
/* There is no number here. (e.g. "cond a == b"). */
|
||||||
error (_("Expected integer at: %s"), p);
|
error (_("Expected integer at: %s"), p);
|
||||||
}
|
}
|
||||||
p = *pp;
|
p = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(isspace (*p) || *p == '\0' || *p == trailer))
|
if (!(isspace (*p) || *p == '\0' || *p == trailer))
|
||||||
|
|
|
@ -133,6 +133,27 @@ struct test_options_opts
|
||||||
const char *enum_opt = test_options_enum_values_xxx;
|
const char *enum_opt = test_options_enum_values_xxx;
|
||||||
unsigned int uint_opt = 0;
|
unsigned int uint_opt = 0;
|
||||||
int zuint_unl_opt = 0;
|
int zuint_unl_opt = 0;
|
||||||
|
|
||||||
|
/* Dump the options to FILE. ARGS is the remainder unprocessed
|
||||||
|
arguments. */
|
||||||
|
void dump (ui_file *file, const char *args) const
|
||||||
|
{
|
||||||
|
fprintf_unfiltered (file,
|
||||||
|
_("-flag %d -xx1 %d -xx2 %d -bool %d "
|
||||||
|
"-enum %s -uint %s -zuint-unl %s -- %s\n"),
|
||||||
|
flag_opt,
|
||||||
|
xx1_opt,
|
||||||
|
xx2_opt,
|
||||||
|
boolean_opt,
|
||||||
|
enum_opt,
|
||||||
|
(uint_opt == UINT_MAX
|
||||||
|
? "unlimited"
|
||||||
|
: pulongest (uint_opt)),
|
||||||
|
(zuint_unl_opt == -1
|
||||||
|
? "unlimited"
|
||||||
|
: plongest (zuint_unl_opt)),
|
||||||
|
args);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Option definitions for the "maintenance test-options" commands. */
|
/* Option definitions for the "maintenance test-options" commands. */
|
||||||
|
@ -226,46 +247,48 @@ maintenance_test_options_command_mode (const char *args,
|
||||||
else
|
else
|
||||||
args = skip_spaces (args);
|
args = skip_spaces (args);
|
||||||
|
|
||||||
printf_unfiltered (_("-flag %d -xx1 %d -xx2 %d -bool %d "
|
opts.dump (gdb_stdout, args);
|
||||||
"-enum %s -uint %s -zuint-unl %s -- %s\n"),
|
|
||||||
opts.flag_opt,
|
|
||||||
opts.xx1_opt,
|
|
||||||
opts.xx2_opt,
|
|
||||||
opts.boolean_opt,
|
|
||||||
opts.enum_opt,
|
|
||||||
(opts.uint_opt == UINT_MAX
|
|
||||||
? "unlimited"
|
|
||||||
: pulongest (opts.uint_opt)),
|
|
||||||
(opts.zuint_unl_opt == -1
|
|
||||||
? "unlimited"
|
|
||||||
: plongest (opts.zuint_unl_opt)),
|
|
||||||
args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Variables used by the "maintenance show
|
/* Variable used by the "maintenance show
|
||||||
test-options-completion-result" command. These variables are
|
test-options-completion-result" command. This variable is stored
|
||||||
stored by the completer of the "maint test-options"
|
by the completer of the "maint test-options" subcommands.
|
||||||
subcommands. */
|
|
||||||
|
|
||||||
/* The result of gdb::option::complete_options. */
|
If the completer returned false, this includes the text at the word
|
||||||
static int maintenance_test_options_command_completion_result;
|
point after gdb::option::complete_options returns. If true, then
|
||||||
/* The text at the word point after gdb::option::complete_options
|
this includes a dump of the processed options. */
|
||||||
returns. */
|
|
||||||
static std::string maintenance_test_options_command_completion_text;
|
static std::string maintenance_test_options_command_completion_text;
|
||||||
|
|
||||||
/* The "maintenance show test-options-completion-result" command. */
|
/* The "maintenance show test-options-completion-result" command. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maintenance_show_test_options_completion_result
|
maintenance_show_test_options_completion_result (const char *args,
|
||||||
(struct ui_file *file, int from_tty,
|
int from_tty)
|
||||||
struct cmd_list_element *c, const char *value)
|
|
||||||
{
|
{
|
||||||
if (maintenance_test_options_command_completion_result)
|
puts_filtered (maintenance_test_options_command_completion_text.c_str ());
|
||||||
fprintf_filtered (file, "1\n");
|
}
|
||||||
|
|
||||||
|
/* Save the completion result in the global variables read by the
|
||||||
|
"maintenance test-options require-delimiter" command. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_completion_result (const test_options_opts &opts, bool res,
|
||||||
|
const char *text)
|
||||||
|
{
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
string_file stream;
|
||||||
|
|
||||||
|
stream.puts ("1 ");
|
||||||
|
opts.dump (&stream, text);
|
||||||
|
maintenance_test_options_command_completion_text
|
||||||
|
= std::move (stream.string ());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fprintf_filtered
|
{
|
||||||
(file, _("0 %s\n"),
|
maintenance_test_options_command_completion_text
|
||||||
maintenance_test_options_command_completion_text.c_str ());
|
= string_printf ("0 %s\n", text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of completer for the "maintenance test-options
|
/* Implementation of completer for the "maintenance test-options
|
||||||
|
@ -278,17 +301,19 @@ maintenance_test_options_completer_mode (completion_tracker &tracker,
|
||||||
const char *text,
|
const char *text,
|
||||||
gdb::option::process_options_mode mode)
|
gdb::option::process_options_mode mode)
|
||||||
{
|
{
|
||||||
|
test_options_opts opts;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
maintenance_test_options_command_completion_result
|
bool res = (gdb::option::complete_options
|
||||||
= gdb::option::complete_options
|
|
||||||
(tracker, &text, mode,
|
(tracker, &text, mode,
|
||||||
make_test_options_options_def_group (nullptr));
|
make_test_options_options_def_group (&opts)));
|
||||||
maintenance_test_options_command_completion_text = text;
|
|
||||||
|
save_completion_result (opts, res, text);
|
||||||
}
|
}
|
||||||
catch (const gdb_exception_error &ex)
|
catch (const gdb_exception_error &ex)
|
||||||
{
|
{
|
||||||
maintenance_test_options_command_completion_result = 1;
|
save_completion_result (opts, true, text);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,17 +470,13 @@ Options:\n\
|
||||||
set_cmd_completer_handle_brkchars
|
set_cmd_completer_handle_brkchars
|
||||||
(cmd, maintenance_test_options_unknown_is_operand_command_completer);
|
(cmd, maintenance_test_options_unknown_is_operand_command_completer);
|
||||||
|
|
||||||
add_setshow_zinteger_cmd ("test-options-completion-result", class_maintenance,
|
add_cmd ("test-options-completion-result", class_maintenance,
|
||||||
&maintenance_test_options_command_completion_result,
|
maintenance_show_test_options_completion_result,
|
||||||
_("\
|
_("\
|
||||||
Set maintenance test-options completion result."), _("\
|
Show maintenance test-options completion result.\n\
|
||||||
Show maintenance test-options completion result."), _("\
|
Shows the results of completing\n\
|
||||||
Show the results of completing\n\
|
|
||||||
\"maint test-options require-delimiter\",\n\
|
\"maint test-options require-delimiter\",\n\
|
||||||
\"maint test-options unknown-is-error\", or\n\
|
\"maint test-options unknown-is-error\", or\n\
|
||||||
\"maint test-options unknown-is-operand\"."),
|
\"maint test-options unknown-is-operand\"."),
|
||||||
NULL,
|
|
||||||
maintenance_show_test_options_completion_result,
|
|
||||||
&maintenance_set_cmdlist,
|
|
||||||
&maintenance_show_cmdlist);
|
&maintenance_show_cmdlist);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2019-07-03 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* gdb.base/options.exp (test-misc, test-flag, test-boolean)
|
||||||
|
(test-uinteger, test-enum): Adjust res_test_gdb_... calls to pass
|
||||||
|
the expected output in the success.
|
||||||
|
|
||||||
2019-07-03 Pedro Alves <palves@redhat.com>
|
2019-07-03 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* lib/completion-support.exp (test_gdb_complete_tab_multiple):
|
* lib/completion-support.exp (test_gdb_complete_tab_multiple):
|
||||||
|
|
|
@ -486,21 +486,27 @@ proc_with_prefix test-misc {variant} {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Completing at "-" should list all options.
|
# Completing at "-" should list all options.
|
||||||
res_test_gdb_complete_multiple "1" "$cmd " "-" "" $all_options
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_none "-"]" \
|
||||||
|
"$cmd " "-" "" $all_options
|
||||||
|
|
||||||
# Now with a double dash.
|
# Now with a double dash.
|
||||||
gdb_test "$cmd --" [expect_none ""]
|
gdb_test "$cmd --" [expect_none ""]
|
||||||
|
|
||||||
# "--" is recognized by options completer, gdb auto-appends a
|
# "--" is recognized by options completer, gdb auto-appends a
|
||||||
# space.
|
# space.
|
||||||
test_completer_recognizes 1 "$cmd --"
|
test_completer_recognizes \
|
||||||
|
"1 [expect_none "--"]" \
|
||||||
|
"$cmd --"
|
||||||
|
|
||||||
# Now with a double dash, plus a dash as operand.
|
# Now with a double dash, plus a dash as operand.
|
||||||
gdb_test "$cmd -- -" [expect_none "-"]
|
gdb_test "$cmd -- -" [expect_none "-"]
|
||||||
res_test_gdb_complete_none "0 -" "$cmd -- -"
|
res_test_gdb_complete_none "0 -" "$cmd -- -"
|
||||||
|
|
||||||
# Completing an unambiguous option just appends an empty space.
|
# Completing an unambiguous option just appends an empty space.
|
||||||
test_completer_recognizes 1 "$cmd -flag"
|
test_completer_recognizes \
|
||||||
|
"1 [expect_none "-flag"]" \
|
||||||
|
"$cmd -flag"
|
||||||
|
|
||||||
# Try running an ambiguous option.
|
# Try running an ambiguous option.
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
|
@ -540,10 +546,14 @@ proc_with_prefix test-flag {variant} {
|
||||||
set cmd [make_cmd $variant]
|
set cmd [make_cmd $variant]
|
||||||
|
|
||||||
# Completing a flag just appends a space.
|
# Completing a flag just appends a space.
|
||||||
test_completer_recognizes 1 "$cmd -flag"
|
test_completer_recognizes \
|
||||||
|
"1 [expect_none "-flag"]" \
|
||||||
|
"$cmd -flag"
|
||||||
|
|
||||||
# Add a dash, and all options should be shown.
|
# Add a dash, and all options should be shown.
|
||||||
test_gdb_complete_multiple "$cmd -flag " "-" "" $all_options
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_flag "-"]" \
|
||||||
|
"$cmd -flag " "-" "" $all_options
|
||||||
|
|
||||||
# Basic smoke tests of accepted / not accepted values.
|
# Basic smoke tests of accepted / not accepted values.
|
||||||
|
|
||||||
|
@ -582,7 +592,9 @@ proc_with_prefix test-flag {variant} {
|
||||||
# "on/off".
|
# "on/off".
|
||||||
|
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_none "1" "$cmd -flag o"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_flag "o"]" \
|
||||||
|
"$cmd -flag o"
|
||||||
|
|
||||||
gdb_test "$cmd -flag o" [expect_none "-flag o"]
|
gdb_test "$cmd -flag o" [expect_none "-flag o"]
|
||||||
} else {
|
} else {
|
||||||
|
@ -612,7 +624,9 @@ proc_with_prefix test-boolean {variant} {
|
||||||
# E.g., "frame apply all -past-main COMMAND".
|
# E.g., "frame apply all -past-main COMMAND".
|
||||||
|
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_multiple 1 "$cmd -bool " "" "" {
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd -bool " "" "" {
|
||||||
"-bool"
|
"-bool"
|
||||||
"-enum"
|
"-enum"
|
||||||
"-flag"
|
"-flag"
|
||||||
|
@ -628,7 +642,9 @@ proc_with_prefix test-boolean {variant} {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add another dash, and "on/off" are no longer offered:
|
# Add another dash, and "on/off" are no longer offered:
|
||||||
res_test_gdb_complete_multiple 1 "$cmd -bool " "-" "" $all_options
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_bool "-"]" \
|
||||||
|
"$cmd -bool " "-" "" $all_options
|
||||||
|
|
||||||
# Basic smoke tests of accepted / not accepted values.
|
# Basic smoke tests of accepted / not accepted values.
|
||||||
|
|
||||||
|
@ -643,20 +659,25 @@ proc_with_prefix test-boolean {variant} {
|
||||||
# However, the completer does recognize them if you start typing
|
# However, the completer does recognize them if you start typing
|
||||||
# the boolean value.
|
# the boolean value.
|
||||||
foreach value {"0" "1"} {
|
foreach value {"0" "1"} {
|
||||||
test_completer_recognizes 1 "$cmd -bool $value"
|
test_completer_recognizes \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd -bool $value"
|
||||||
}
|
}
|
||||||
foreach value {"of" "off"} {
|
foreach value {"of" "off"} {
|
||||||
res_test_gdb_complete_unique 1 \
|
res_test_gdb_complete_unique \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
"$cmd -bool $value" \
|
"$cmd -bool $value" \
|
||||||
"$cmd -bool off"
|
"$cmd -bool off"
|
||||||
}
|
}
|
||||||
foreach value {"y" "ye" "yes"} {
|
foreach value {"y" "ye" "yes"} {
|
||||||
res_test_gdb_complete_unique 1 \
|
res_test_gdb_complete_unique \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
"$cmd -bool $value" \
|
"$cmd -bool $value" \
|
||||||
"$cmd -bool yes"
|
"$cmd -bool yes"
|
||||||
}
|
}
|
||||||
foreach value {"n" "no"} {
|
foreach value {"n" "no"} {
|
||||||
res_test_gdb_complete_unique 1 \
|
res_test_gdb_complete_unique \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
"$cmd -bool $value" \
|
"$cmd -bool $value" \
|
||||||
"$cmd -bool no"
|
"$cmd -bool no"
|
||||||
}
|
}
|
||||||
|
@ -668,7 +689,8 @@ proc_with_prefix test-boolean {variant} {
|
||||||
"enabl"
|
"enabl"
|
||||||
"enable"
|
"enable"
|
||||||
} {
|
} {
|
||||||
res_test_gdb_complete_unique 1 \
|
res_test_gdb_complete_unique \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
"$cmd -bool $value" \
|
"$cmd -bool $value" \
|
||||||
"$cmd -bool enable"
|
"$cmd -bool enable"
|
||||||
}
|
}
|
||||||
|
@ -681,13 +703,16 @@ proc_with_prefix test-boolean {variant} {
|
||||||
"disabl"
|
"disabl"
|
||||||
"disable"
|
"disable"
|
||||||
} {
|
} {
|
||||||
res_test_gdb_complete_unique 1 \
|
res_test_gdb_complete_unique \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
"$cmd -bool $value" \
|
"$cmd -bool $value" \
|
||||||
"$cmd -bool disable"
|
"$cmd -bool disable"
|
||||||
}
|
}
|
||||||
|
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_none "1" "$cmd -bool xxx"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none "xxx"]" \
|
||||||
|
"$cmd -bool xxx"
|
||||||
} else {
|
} else {
|
||||||
res_test_gdb_complete_none "0 xxx" "$cmd -bool xxx"
|
res_test_gdb_complete_none "0 xxx" "$cmd -bool xxx"
|
||||||
}
|
}
|
||||||
|
@ -763,7 +788,9 @@ proc_with_prefix test-boolean {variant} {
|
||||||
# Completing after a boolean option + "o" does list "on/off",
|
# Completing after a boolean option + "o" does list "on/off",
|
||||||
# though.
|
# though.
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_multiple 1 "$cmd -bool " "o" "" {
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_none "o"]" \
|
||||||
|
"$cmd -bool " "o" "" {
|
||||||
"off"
|
"off"
|
||||||
"on"
|
"on"
|
||||||
}
|
}
|
||||||
|
@ -783,17 +810,22 @@ proc_with_prefix test-uinteger {variant option} {
|
||||||
set cmd "[make_cmd $variant] -$option"
|
set cmd "[make_cmd $variant] -$option"
|
||||||
|
|
||||||
# Test completing a uinteger option:
|
# Test completing a uinteger option:
|
||||||
res_test_gdb_complete_multiple 1 "$cmd " "" "" {
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd " "" "" {
|
||||||
"NUMBER"
|
"NUMBER"
|
||||||
"unlimited"
|
"unlimited"
|
||||||
}
|
}
|
||||||
|
|
||||||
# NUMBER above is just a placeholder, make sure we don't complete
|
# NUMBER above is just a placeholder, make sure we don't complete
|
||||||
# it as a valid option.
|
# it as a valid option.
|
||||||
res_test_gdb_complete_none 1 "$cmd NU"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none "NU"]" \
|
||||||
|
"$cmd NU"
|
||||||
|
|
||||||
# "unlimited" is valid though.
|
# "unlimited" is valid though.
|
||||||
res_test_gdb_complete_unique 1 \
|
res_test_gdb_complete_unique \
|
||||||
|
"1 [expect_none "u"]" \
|
||||||
"$cmd u" \
|
"$cmd u" \
|
||||||
"$cmd unlimited"
|
"$cmd unlimited"
|
||||||
|
|
||||||
|
@ -815,24 +847,34 @@ proc_with_prefix test-uinteger {variant option} {
|
||||||
|
|
||||||
# Don't offer completions until we're past the
|
# Don't offer completions until we're past the
|
||||||
# -uinteger/-zuinteger-unlimited argument.
|
# -uinteger/-zuinteger-unlimited argument.
|
||||||
res_test_gdb_complete_none 1 "$cmd 1"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd 1"
|
||||||
|
|
||||||
# A number of invalid values.
|
# A number of invalid values.
|
||||||
foreach value {"x" "x " "1a" "1a " "1-" "1- " "unlimitedx"} {
|
foreach value {"x" "x " "1a" "1a " "1-" "1- " "unlimitedx"} {
|
||||||
res_test_gdb_complete_none 1 "$cmd $value"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none $value]" \
|
||||||
|
"$cmd $value"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try "-1".
|
# Try "-1".
|
||||||
if {$option == "uinteger"} {
|
if {$option == "uinteger"} {
|
||||||
# -1 is invalid uinteger.
|
# -1 is invalid uinteger.
|
||||||
foreach value {"-1" "-1 "} {
|
foreach value {"-1" "-1 "} {
|
||||||
res_test_gdb_complete_none 1 "$cmd $value"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd $value"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# -1 is valid for zuinteger-unlimited.
|
# -1 is valid for zuinteger-unlimited.
|
||||||
res_test_gdb_complete_none 1 "$cmd -1"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd -1"
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_multiple 1 "$cmd -1 " "" "-" $all_options
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_integer $option "unlimited" ""]" \
|
||||||
|
"$cmd -1 " "" "-" $all_options
|
||||||
} else {
|
} else {
|
||||||
res_test_gdb_complete_none "0 " "$cmd -1 "
|
res_test_gdb_complete_none "0 " "$cmd -1 "
|
||||||
}
|
}
|
||||||
|
@ -846,7 +888,9 @@ proc_with_prefix test-uinteger {variant option} {
|
||||||
# - for !require-delimiter commands, completion offers nothing
|
# - for !require-delimiter commands, completion offers nothing
|
||||||
# and returns false.
|
# and returns false.
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_multiple 1 "$cmd 1 " "" "-" $all_options
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_integer $option 1 ""]" \
|
||||||
|
"$cmd 1 " "" "-" $all_options
|
||||||
} else {
|
} else {
|
||||||
res_test_gdb_complete_none "0 " "$cmd 1 "
|
res_test_gdb_complete_none "0 " "$cmd 1 "
|
||||||
}
|
}
|
||||||
|
@ -854,7 +898,9 @@ proc_with_prefix test-uinteger {variant option} {
|
||||||
# Test completing non-option arguments after "-uinteger 1 ".
|
# Test completing non-option arguments after "-uinteger 1 ".
|
||||||
foreach operand {"x" "x " "1a" "1a " "1-" "1- "} {
|
foreach operand {"x" "x " "1a" "1a " "1-" "1- "} {
|
||||||
if {$variant == "require-delimiter"} {
|
if {$variant == "require-delimiter"} {
|
||||||
res_test_gdb_complete_none 1 "$cmd 1 $operand"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_integer $option 1 $operand]" \
|
||||||
|
"$cmd 1 $operand"
|
||||||
} else {
|
} else {
|
||||||
res_test_gdb_complete_none "0 $operand" "$cmd 1 $operand"
|
res_test_gdb_complete_none "0 $operand" "$cmd 1 $operand"
|
||||||
}
|
}
|
||||||
|
@ -864,7 +910,9 @@ proc_with_prefix test-uinteger {variant option} {
|
||||||
if {$variant == "unknown-is-operand"} {
|
if {$variant == "unknown-is-operand"} {
|
||||||
res_test_gdb_complete_none "0 $operand" "$cmd 1 $operand"
|
res_test_gdb_complete_none "0 $operand" "$cmd 1 $operand"
|
||||||
} else {
|
} else {
|
||||||
res_test_gdb_complete_none 1 "$cmd 1 $operand"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_integer $option 1 $operand]" \
|
||||||
|
"$cmd 1 $operand"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -873,7 +921,9 @@ proc_with_prefix test-uinteger {variant option} {
|
||||||
proc_with_prefix test-enum {variant} {
|
proc_with_prefix test-enum {variant} {
|
||||||
set cmd [make_cmd $variant]
|
set cmd [make_cmd $variant]
|
||||||
|
|
||||||
res_test_gdb_complete_multiple 1 "$cmd -enum " "" "" {
|
res_test_gdb_complete_multiple \
|
||||||
|
"1 [expect_none ""]" \
|
||||||
|
"$cmd -enum " "" "" {
|
||||||
"xxx"
|
"xxx"
|
||||||
"yyy"
|
"yyy"
|
||||||
"zzz"
|
"zzz"
|
||||||
|
@ -882,7 +932,9 @@ proc_with_prefix test-enum {variant} {
|
||||||
# Check that "-" where a value is expected does not show the
|
# Check that "-" where a value is expected does not show the
|
||||||
# command's options. I.e., an enum's value is not optional.
|
# command's options. I.e., an enum's value is not optional.
|
||||||
# Check both completion and running the command.
|
# Check both completion and running the command.
|
||||||
res_test_gdb_complete_none 1 "$cmd -enum -"
|
res_test_gdb_complete_none \
|
||||||
|
"1 [expect_none "-"]" \
|
||||||
|
"$cmd -enum -"
|
||||||
gdb_test "$cmd -enum --"\
|
gdb_test "$cmd -enum --"\
|
||||||
"Requires an argument. Valid arguments are xxx, yyy, zzz\\."
|
"Requires an argument. Valid arguments are xxx, yyy, zzz\\."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue