"thread apply 1 -- -" vs "frame apply level 0 -- -"
[deliverable/binutils-gdb.git] / gdb / thread.c
index 010cd24e7e18b8af14f96eb8fefb85e5684e9cc8..ea87f51c6e6fd541f664fb26ffde732c61306b6f 100644 (file)
@@ -46,6 +46,7 @@
 #include <algorithm>
 #include "common/gdb_optional.h"
 #include "inline-frame.h"
+#include "stack.h"
 
 /* Definition of struct thread_info exported to gdbthread.h.  */
 
@@ -540,12 +541,12 @@ find_thread_ptid (inferior *inf, ptid_t ptid)
 /* See gdbthread.h.  */
 
 struct thread_info *
-find_thread_by_handle (struct value *thread_handle, struct inferior *inf)
+find_thread_by_handle (gdb::array_view<const gdb_byte> handle,
+                      struct inferior *inf)
 {
-  return target_thread_handle_to_thread_info
-          (value_contents_all (thread_handle),
-           TYPE_LENGTH (value_type (thread_handle)),
-           inf);
+  return target_thread_handle_to_thread_info (handle.data (),
+                                             handle.size (),
+                                             inf);
 }
 
 /*
@@ -1191,7 +1192,8 @@ No selected thread.  See `help thread'.\n");
 /* See gdbthread.h.  */
 
 void
-print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
+print_thread_info (struct ui_out *uiout, const char *requested_threads,
+                  int pid)
 {
   print_thread_info_1 (uiout, requested_threads, 1, pid, 0);
 }
@@ -1461,7 +1463,8 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
   switch_to_thread (thr);
   try
     {
-      std::string cmd_result = execute_command_to_string (cmd, from_tty);
+      std::string cmd_result = execute_command_to_string
+       (cmd, from_tty, gdb_stdout->term_out ());
       if (!flags.silent || cmd_result.length () > 0)
        {
          if (!flags.quiet)
@@ -1482,7 +1485,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
          if (flags.cont)
            printf_filtered ("%s\n", ex.what ());
          else
-           throw_exception (ex);
+           throw;
        }
     }
 }
@@ -1558,7 +1561,6 @@ thread_apply_command (const char *tidlist, int from_tty)
 {
   qcs_flags flags;
   const char *cmd = NULL;
-  const char *cmd_or_flags;
   tid_range_parser parser;
 
   if (tidlist == NULL || *tidlist == '\000')
@@ -1570,26 +1572,24 @@ thread_apply_command (const char *tidlist, int from_tty)
       int inf_num, thr_start, thr_end;
 
       if (!parser.get_tid_range (&inf_num, &thr_start, &thr_end))
-       {
-         cmd = parser.cur_tok ();
-         break;
-       }
+       break;
     }
 
-  cmd_or_flags = cmd;
-  while (cmd != NULL && parse_flags_qcs ("thread apply", &cmd, &flags))
+  cmd = parser.cur_tok ();
+
+  while (parse_flags_qcs ("thread apply", &cmd, &flags))
     ;
 
-  if (cmd == NULL)
+  if (*cmd == '\0')
     error (_("Please specify a command following the thread ID list"));
 
-  if (tidlist == cmd || !isalpha (cmd[0]))
+  if (tidlist == cmd || isdigit (cmd[0]))
     invalid_thread_id_error (cmd);
 
   scoped_restore_current_thread restore_thread;
 
   parser.init (tidlist, current_inferior ()->num);
-  while (!parser.finished () && parser.cur_tok () < cmd_or_flags)
+  while (!parser.finished ())
     {
       struct thread_info *tp = NULL;
       struct inferior *inf;
@@ -1654,7 +1654,7 @@ static void
 tfaas_command (const char *cmd, int from_tty)
 {
   std::string expanded
-    = std::string ("thread apply all -s frame apply all -s ") + cmd;
+    = std::string ("thread apply all -s -- frame apply all -s ") + cmd;
   execute_command (expanded.c_str (), from_tty);
 }
 
@@ -1939,6 +1939,7 @@ void
 _initialize_thread (void)
 {
   static struct cmd_list_element *thread_apply_list = NULL;
+  cmd_list_element *c;
 
   add_info ("threads", info_threads_command,
            _("Display currently known threads.\n\
@@ -1984,10 +1985,12 @@ Apply a command to all threads (ignoring errors and empty output).\n\
 Usage: taas COMMAND\n\
 shortcut for 'thread apply all -s COMMAND'"));
 
-  add_com ("tfaas", class_run, tfaas_command, _("\
+  c = add_com ("tfaas", class_run, tfaas_command, _("\
 Apply a command to all frames of all threads (ignoring errors and empty output).\n\
-Usage: tfaas COMMAND\n\
-shortcut for 'thread apply all -s frame apply all -s COMMAND'"));
+Usage: tfaas [OPTION]... COMMAND\n\
+shortcut for 'thread apply all -s -- frame apply all -s [OPTION]... COMMAND'\n\
+See \"help frame apply all\" for available options."));
+  set_cmd_completer_handle_brkchars (c, frame_apply_all_cmd_completer);
 
   add_cmd ("name", class_run, thread_name_command,
           _("Set the current thread's name.\n\
This page took 0.027847 seconds and 4 git commands to generate.