From: Pedro Alves Date: Tue, 25 Jun 2019 15:58:50 +0000 (+0100) Subject: Make complete_options save arguments too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d3081ce815ec3f43e79ee922acca40d98dc4986;p=thirdparty%2Fbinutils-gdb.git Make complete_options save arguments too --- diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 9a53ec0592d..eccabd220de 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -58,6 +58,8 @@ struct option_def_and_value gdb::optional value; }; +static void save_option_value_in_ctx (gdb::optional &ov); + /* Info passed around when handling completion. */ struct parse_option_completion_info { @@ -456,6 +458,11 @@ complete_options (completion_tracker &tracker, (*args - text); 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 { @@ -499,6 +506,36 @@ complete_options (completion_tracker &tracker, return false; } +/* Save the parsed value in the option's context. */ + +static void +save_option_value_in_ctx (gdb::optional &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. */ bool @@ -534,29 +571,7 @@ process_options (const char **args, processed_any = true; - 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"); - } + save_option_value_in_ctx (ov); } }