/* FIXME: do I ever need to call the back-end to give it a
chance at this private data before deleting the thread? */
if (tp->private)
- free (tp->private);
+ xfree (tp->private);
- free (tp);
+ xfree (tp);
}
void
*/
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;
{
struct current_thread_cleanup *old = arg;
restore_current_thread (old->inferior_pid);
- free (old);
+ xfree (old);
}
static struct cleanup *
{
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");
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 (xfree, (void *) saved_cmd);
for (tp = thread_list; tp; tp = tp->next)
if (thread_alive (tp))
{
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);
}
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");
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 (xfree, (void *) saved_cmd);
while (tidlist < cmd)
{
struct thread_info *tp;
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);
}