+/* See gdbthread.h. */
+
+void
+print_thread_info (struct ui_out *uiout, const char *requested_threads,
+ int pid)
+{
+ print_thread_info_1 (uiout, requested_threads, 1, pid, 0);
+}
+
+/* The options for the "info threads" command. */
+
+struct info_threads_opts
+{
+ /* For "-gid". */
+ bool show_global_ids = false;
+};
+
+static const gdb::option::option_def info_threads_option_defs[] = {
+
+ gdb::option::flag_option_def<info_threads_opts> {
+ "gid",
+ [] (info_threads_opts *opts) { return &opts->show_global_ids; },
+ N_("Show global thread IDs."),
+ },
+
+};
+
+/* Create an option_def_group for the "info threads" options, with
+ IT_OPTS as context. */
+
+static inline gdb::option::option_def_group
+make_info_threads_options_def_group (info_threads_opts *it_opts)
+{
+ return {{info_threads_option_defs}, it_opts};
+}
+
+/* Implementation of the "info threads" command.
+
+ Note: this has the drawback that it _really_ switches
+ threads, which frees the frame cache. A no-side
+ effects info-threads command would be nicer. */
+
+static void
+info_threads_command (const char *arg, int from_tty)
+{
+ info_threads_opts it_opts;
+
+ auto grp = make_info_threads_options_def_group (&it_opts);
+ gdb::option::process_options
+ (&arg, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp);
+
+ print_thread_info_1 (current_uiout, arg, 0, -1, it_opts.show_global_ids);
+}
+
+/* Completer for the "info threads" command. */
+
+static void
+info_threads_command_completer (struct cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char *word_ignored)
+{
+ const auto grp = make_info_threads_options_def_group (nullptr);
+
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp))
+ return;
+
+ /* Convenience to let the user know what the option can accept. */
+ if (*text == '\0')
+ {
+ gdb::option::complete_on_all_options (tracker, grp);
+ /* Keep this "ID" in sync with what "help info threads"
+ says. */
+ tracker.add_completion (make_unique_xstrdup ("ID"));
+ }
+}
+
+/* See gdbthread.h. */
+
+void
+switch_to_thread_no_regs (struct thread_info *thread)
+{
+ struct inferior *inf = thread->inf;
+
+ set_current_program_space (inf->pspace);
+ set_current_inferior (inf);