diff options
Diffstat (limited to 'gdb/maint-test-options.c')
-rw-r--r-- | gdb/maint-test-options.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c index 48b68f9..97236c9 100644 --- a/gdb/maint-test-options.c +++ b/gdb/maint-test-options.c @@ -1,6 +1,6 @@ /* Maintenance commands for testing the options framework. - Copyright (C) 2019-2024 Free Software Foundation, Inc. + Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -57,12 +57,13 @@ readline, for proper testing of TAB completion. These maintenance commands support options of all the different - available kinds of commands (boolean, enum, flag, string, uinteger): + available kinds of commands (boolean, enum, flag, string, filename, + uinteger): (gdb) maint test-options require-delimiter -[TAB] - -bool -pinteger-unlimited -xx1 - -enum -string -xx2 - -flag -uinteger-unlimited + -bool -flag -uinteger-unlimited + -enum -pinteger-unlimited -xx1 + -filename -string -xx2 (gdb) maint test-options require-delimiter -bool o[TAB] off on @@ -77,14 +78,14 @@ Invoking the commands makes them print out the options parsed: (gdb) maint test-options unknown-is-error -flag -enum yyy cmdarg - -flag 1 -xx1 0 -xx2 0 -bool 0 -enum yyy -uint-unl 0 -pint-unl 0 -string '' -- cmdarg + -flag 1 -xx1 0 -xx2 0 -bool 0 -enum yyy -uint-unl 0 -pint-unl 0 -string '' -filename '' -- cmdarg (gdb) maint test-options require-delimiter -flag -enum yyy cmdarg - -flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0 -string '' -- -flag -enum yyy cmdarg + -flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0 -string '' -filename '' -- -flag -enum yyy cmdarg (gdb) maint test-options require-delimiter -flag -enum yyy cmdarg -- Unrecognized option at: cmdarg -- (gdb) maint test-options require-delimiter -flag -enum yyy -- cmdarg - -flag 1 -xx1 0 -xx2 0 -bool 0 -enum yyy -uint-unl 0 -pint-unl 0 -string '' -- cmdarg + -flag 1 -xx1 0 -xx2 0 -bool 0 -enum yyy -uint-unl 0 -pint-unl 0 -string '' -filename '' -- cmdarg The "maint show test-options-completion-result" command exists in order to do something similar for completion: @@ -135,6 +136,8 @@ struct test_options_opts unsigned int uint_unl_opt = 0; int pint_unl_opt = 0; std::string string_opt; + std::string filename_opt; + ui_file_style::color color_opt { ui_file_style::MAGENTA }; test_options_opts () = default; @@ -146,7 +149,8 @@ struct test_options_opts { gdb_printf (file, _("-flag %d -xx1 %d -xx2 %d -bool %d " - "-enum %s -uint-unl %s -pint-unl %s -string '%s' -- %s\n"), + "-enum %s -uint-unl %s -pint-unl %s -string '%s' " + "-filename '%s' -color %s -- %s\n"), flag_opt, xx1_opt, xx2_opt, @@ -159,6 +163,8 @@ struct test_options_opts ? "unlimited" : plongest (pint_unl_opt)), string_opt.c_str (), + filename_opt.c_str (), + color_opt.to_string ().c_str (), args); } }; @@ -233,6 +239,22 @@ static const gdb::option::option_def test_options_option_defs[] = { nullptr, /* show_cmd_cb */ N_("A string option."), }, + + /* A filename option. */ + gdb::option::filename_option_def<test_options_opts> { + "filename", + [] (test_options_opts *opts) { return &opts->filename_opt; }, + nullptr, /* show_cmd_cb */ + N_("A filename option."), + }, + + /* A color option. */ + gdb::option::color_option_def<test_options_opts> { + "color", + [] (test_options_opts *opts) { return &opts->color_opt; }, + nullptr, /* show_cmd_cb */ + N_("A color option."), + }, }; /* Create an option_def_group for the test_options_opts options, with @@ -407,9 +429,7 @@ maintenance_test_options_unknown_is_operand_command_completer static cmd_list_element *maintenance_test_options_list; -void _initialize_maint_test_options (); -void -_initialize_maint_test_options () +INIT_GDB_FILE (maint_test_options) { cmd_list_element *cmd; |