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
|
@ -60,13 +60,14 @@ get_ulongest (const char **pp, int trailer)
|
|||
}
|
||||
else
|
||||
{
|
||||
retval = strtoulst (p, pp, 0);
|
||||
if (p == *pp)
|
||||
const char *end = p;
|
||||
retval = strtoulst (p, &end, 0);
|
||||
if (p == end)
|
||||
{
|
||||
/* There is no number here. (e.g. "cond a == b"). */
|
||||
error (_("Expected integer at: %s"), p);
|
||||
}
|
||||
p = *pp;
|
||||
p = end;
|
||||
}
|
||||
|
||||
if (!(isspace (*p) || *p == '\0' || *p == trailer))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue