+catch_command_errors (catch_command_errors_const_ftype command,
+ const char *arg, int from_tty)
+{
+ TRY
+ {
+ int was_sync = current_ui->prompt_state == PROMPT_BLOCKED;
+
+ command (arg, from_tty);
+
+ maybe_wait_sync_command_done (was_sync);
+ }
+ CATCH (e, RETURN_MASK_ALL)
+ {
+ return handle_command_errors (e);
+ }
+ END_CATCH
+
+ return 1;
+}
+
+/* Adapter for symbol_file_add_main that translates 'from_tty' to a
+ symfile_add_flags. */
+
+static void
+symbol_file_add_main_adapter (const char *arg, int from_tty)
+{
+ symfile_add_flags add_flags = 0;
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
+
+ symbol_file_add_main (arg, add_flags);
+}
+
+/* Perform validation of the '--readnow' and '--readnever' flags. */
+
+static void
+validate_readnow_readnever ()
+{
+ if (readnever_symbol_files && readnow_symbol_files)
+ {
+ error (_("%s: '--readnow' and '--readnever' cannot be "
+ "specified simultaneously"),
+ gdb_program_name);
+ }
+}
+
+/* Type of this option. */
+enum cmdarg_kind
+{
+ /* Option type -x. */
+ CMDARG_FILE,
+
+ /* Option type -ex. */
+ CMDARG_COMMAND,
+
+ /* Option type -ix. */
+ CMDARG_INIT_FILE,
+
+ /* Option type -iex. */
+ CMDARG_INIT_COMMAND
+};
+
+/* Arguments of --command option and its counterpart. */
+struct cmdarg
+{
+ cmdarg (cmdarg_kind type_, char *string_)
+ : type (type_), string (string_)
+ {}
+
+ /* Type of this option. */
+ enum cmdarg_kind type;
+
+ /* Value of this option - filename or the GDB command itself. String memory
+ is not owned by this structure despite it is 'const'. */
+ char *string;
+};
+
+static void
+captured_main_1 (struct captured_main_args *context)