Make gdb::option::complete_options save processed arguments too
authorPedro Alves <palves@redhat.com>
Wed, 3 Jul 2019 15:57:48 +0000 (16:57 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 3 Jul 2019 15:58:30 +0000 (16:58 +0100)
commit41fc454c915057d9c5536617370c5eb2a5f71323
treee4c833f477121ca24ce4b069c857374eb2603437
parentb2b2a2159876fa8db57ce017b949cafc6f1a32df
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.
gdb/ChangeLog
gdb/cli/cli-option.c
gdb/cli/cli-utils.c
gdb/maint-test-options.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/options.exp
This page took 0.026941 seconds and 4 git commands to generate.