readline, for proper testing of TAB completion.
These maintenance commands support options of all the different
- available kinds of commands (boolean, enum, flag, uinteger):
+ available kinds of commands (boolean, enum, flag, string, uinteger):
(gdb) maint test-options require-delimiter -[TAB]
- -bool -enum -flag -uinteger -xx1 -xx2
+ -bool -enum -flag -string -uinteger -xx1 -xx2
(gdb) maint test-options require-delimiter -bool o[TAB]
off on
struct test_options_opts
{
- int flag_opt = 0;
- int xx1_opt = 0;
- int xx2_opt = 0;
- int boolean_opt = 0;
+ bool flag_opt = false;
+ bool xx1_opt = false;
+ bool xx2_opt = false;
+ bool boolean_opt = false;
const char *enum_opt = test_options_enum_values_xxx;
unsigned int uint_opt = 0;
int zuint_unl_opt = 0;
+ char *string_opt = nullptr;
+
+ test_options_opts () = default;
+
+ DISABLE_COPY_AND_ASSIGN (test_options_opts);
+
+ ~test_options_opts ()
+ {
+ xfree (string_opt);
+ }
/* Dump the options to FILE. ARGS is the remainder unprocessed
arguments. */
{
fprintf_unfiltered (file,
_("-flag %d -xx1 %d -xx2 %d -bool %d "
- "-enum %s -uint %s -zuint-unl %s -- %s\n"),
+ "-enum %s -uint %s -zuint-unl %s -string '%s' -- %s\n"),
flag_opt,
xx1_opt,
xx2_opt,
(zuint_unl_opt == -1
? "unlimited"
: plongest (zuint_unl_opt)),
+ (string_opt != nullptr
+ ? string_opt
+ : ""),
args);
}
};
nullptr, /* show_doc */
nullptr, /* help_doc */
},
+
+ /* A string option. */
+ gdb::option::string_option_def<test_options_opts> {
+ "string",
+ [] (test_options_opts *opts) { return &opts->string_opt; },
+ nullptr, /* show_cmd_cb */
+ N_("A string option."),
+ },
};
/* Create an option_def_group for the test_options_opts options, with
Usage: maint test-options require-delimiter [[OPTION]... --] [OPERAND]...\n\
\n\
Options:\n\
-\n\
%OPTIONS%\n\
+\n\
If you specify any command option, you must use a double dash (\"--\")\n\
to mark the end of option processing."),
def_group);
Usage: maint test-options unknown-is-error [OPTION]... [OPERAND]...\n\
\n\
Options:\n\
-\n\
%OPTIONS%"),
def_group);
Usage: maint test-options unknown-is-operand [OPTION]... [OPERAND]...\n\
\n\
Options:\n\
-\n\
%OPTIONS%"),
def_group);