+/* Completer for "thread apply [ID list]". */
+
+static void
+thread_apply_command_completer (cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char * /*word*/)
+{
+ /* Don't leave this to complete_options because there's an early
+ return below. */
+ tracker.set_use_custom_word_point (true);
+
+ tid_range_parser parser;
+ parser.init (text, current_inferior ()->num);
+
+ try
+ {
+ while (!parser.finished ())
+ {
+ int inf_num, thr_start, thr_end;
+
+ if (!parser.get_tid_range (&inf_num, &thr_start, &thr_end))
+ break;
+
+ if (parser.in_star_range () || parser.in_thread_range ())
+ parser.skip_range ();
+ }
+ }
+ catch (const gdb_exception_error &ex)
+ {
+ /* get_tid_range throws if it parses a negative number, for
+ example. But a seemingly negative number may be the start of
+ an option instead. */
+ }
+
+ const char *cmd = parser.cur_tok ();
+
+ if (cmd == text)
+ {
+ /* No thread ID list yet. */
+ return;
+ }
+
+ /* Check if we're past a valid thread ID list already. */
+ if (parser.finished ()
+ && cmd > text && !isspace (cmd[-1]))
+ return;
+
+ /* We're past the thread ID list, advance word point. */
+ tracker.advance_custom_word_point_by (cmd - text);
+ text = cmd;
+
+ const auto group = make_thread_apply_options_def_group (nullptr);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, group))
+ return;
+
+ complete_nested_command_line (tracker, text);
+}
+
+/* Completer for "thread apply all". */
+
+static void
+thread_apply_all_command_completer (cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char *word)
+{
+ const auto group = make_thread_apply_all_options_def_group (nullptr,
+ nullptr);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, group))
+ return;
+
+ complete_nested_command_line (tracker, text);
+}
+