* configure.tgt (hppa*-*-bsd*, hppa*-*-osf*, m68*-*-sunos4*,
[deliverable/binutils-gdb.git] / gdb / thread.c
index 9ae251e90c284b7bcbd6eaa015568b3decf5fd2b..7f509765b9c223121e12e9099e793580ddc6a29b 100644 (file)
@@ -191,9 +191,8 @@ find_thread_pid (int pid)
  */
 
 struct thread_info *
-iterate_over_threads (callback, data)
-     int (*callback) ();
-     void *data;
+iterate_over_threads (int (*callback) (struct thread_info *, void *),
+                     void *data)
 {
   struct thread_info *tp;
 
@@ -518,6 +517,8 @@ thread_apply_all_command (char *cmd, int from_tty)
 {
   struct thread_info *tp;
   struct cleanup *old_chain;
+  struct cleanup *saved_cmd_cleanup_chain;
+  char *saved_cmd;
 
   if (cmd == NULL || *cmd == '\000')
     error ("Please specify a command following the thread ID list");
@@ -528,6 +529,10 @@ thread_apply_all_command (char *cmd, int from_tty)
      traversing it for "thread apply all".  MVS */
   target_find_new_threads ();
 
+  /* Save a copy of the command in case it is clobbered by
+     execute_command */
+  saved_cmd = strdup (cmd);
+  saved_cmd_cleanup_chain = make_cleanup (free, (void *) saved_cmd);
   for (tp = thread_list; tp; tp = tp->next)
     if (thread_alive (tp))
       {
@@ -541,8 +546,10 @@ thread_apply_all_command (char *cmd, int from_tty)
                         target_pid_to_str (inferior_pid));
 #endif
        execute_command (cmd, from_tty);
+       strcpy (cmd, saved_cmd); /* Restore exact command used previously */
       }
 
+  do_cleanups (saved_cmd_cleanup_chain);
   do_cleanups (old_chain);
 }
 
@@ -552,6 +559,8 @@ thread_apply_command (char *tidlist, int from_tty)
   char *cmd;
   char *p;
   struct cleanup *old_chain;
+  struct cleanup *saved_cmd_cleanup_chain;
+  char *saved_cmd;
 
   if (tidlist == NULL || *tidlist == '\000')
     error ("Please specify a thread ID list");
@@ -563,6 +572,10 @@ thread_apply_command (char *tidlist, int from_tty)
 
   old_chain = make_cleanup_restore_current_thread (inferior_pid);
 
+  /* Save a copy of the command in case it is clobbered by
+     execute_command */
+  saved_cmd = strdup (cmd);
+  saved_cmd_cleanup_chain = make_cleanup (free, (void *) saved_cmd);
   while (tidlist < cmd)
     {
       struct thread_info *tp;
@@ -609,10 +622,12 @@ thread_apply_command (char *tidlist, int from_tty)
                               target_pid_to_str (inferior_pid));
 #endif
              execute_command (cmd, from_tty);
+             strcpy (cmd, saved_cmd);  /* Restore exact command used previously */
            }
        }
     }
 
+  do_cleanups (saved_cmd_cleanup_chain);
   do_cleanups (old_chain);
 }
 
This page took 0.025987 seconds and 4 git commands to generate.