+using isrc_flag_option_def
+ = gdb::option::flag_option_def<filename_partial_match_opts>;
+
+static const gdb::option::option_def info_sources_option_defs[] = {
+
+ isrc_flag_option_def {
+ "dirname",
+ [] (filename_partial_match_opts *opts) { return &opts->dirname; },
+ N_("Show only the files having a dirname matching REGEXP."),
+ },
+
+ isrc_flag_option_def {
+ "basename",
+ [] (filename_partial_match_opts *opts) { return &opts->basename; },
+ N_("Show only the files having a basename matching REGEXP."),
+ },
+
+};
+
+/* Create an option_def_group for the "info sources" options, with
+ ISRC_OPTS as context. */
+
+static inline gdb::option::option_def_group
+make_info_sources_options_def_group (filename_partial_match_opts *isrc_opts)
+{
+ return {{info_sources_option_defs}, isrc_opts};
+}
+
+/* Prints the header message for the source files that will be printed
+ with the matching info present in DATA. SYMBOL_MSG is a message
+ that tells what will or has been done with the symbols of the
+ matching source files. */
+
+static void
+print_info_sources_header (const char *symbol_msg,
+ const struct output_source_filename_data *data)
+{
+ puts_filtered (symbol_msg);
+ if (!data->regexp.empty ())
+ {
+ if (data->partial_match.dirname)
+ printf_filtered (_("(dirname matching regular expression \"%s\")"),
+ data->regexp.c_str ());
+ else if (data->partial_match.basename)
+ printf_filtered (_("(basename matching regular expression \"%s\")"),
+ data->regexp.c_str ());
+ else
+ printf_filtered (_("(filename matching regular expression \"%s\")"),
+ data->regexp.c_str ());
+ }
+ puts_filtered ("\n");
+}
+
+/* Completer for "info sources". */
+
+static void
+info_sources_command_completer (cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char *word)
+{
+ const auto group = make_info_sources_options_def_group (nullptr);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, group))
+ return;
+}
+