/* Prototypes for exported functions. */
-void _initialize_thread PARAMS ((void));
+void _initialize_thread (void);
/* Prototypes for local functions. */
static struct thread_info *thread_list = NULL;
static int highest_thread_num;
-static struct thread_info *find_thread_id PARAMS ((int num));
+static struct thread_info *find_thread_id (int num);
-static void thread_command PARAMS ((char *tidstr, int from_tty));
-static void thread_apply_all_command PARAMS ((char *, int));
-static int thread_alive PARAMS ((struct thread_info *));
-static void info_threads_command PARAMS ((char *, int));
-static void thread_apply_command PARAMS ((char *, int));
-static void restore_current_thread PARAMS ((int));
-static void switch_to_thread PARAMS ((int pid));
-static void prune_threads PARAMS ((void));
+static void thread_command (char *tidstr, int from_tty);
+static void thread_apply_all_command (char *, int);
+static int thread_alive (struct thread_info *);
+static void info_threads_command (char *, int);
+static void thread_apply_command (char *, int);
+static void restore_current_thread (int);
+static void switch_to_thread (int pid);
+static void prune_threads (void);
void
init_thread_list ()
}
}
+struct current_thread_cleanup
+{
+ int inferior_pid;
+};
+
+static void
+do_restore_current_thread_cleanup (void *arg)
+{
+ struct current_thread_cleanup *old = arg;
+ restore_current_thread (old->inferior_pid);
+ free (old);
+}
+
+static struct cleanup *
+make_cleanup_restore_current_thread (int inferior_pid)
+{
+ struct current_thread_cleanup *old
+ = xmalloc (sizeof (struct current_thread_cleanup));
+ old->inferior_pid = inferior_pid;
+ return make_cleanup (do_restore_current_thread_cleanup, old);
+}
+
/* Apply a GDB command to a list of threads. List syntax is a whitespace
seperated list of numbers, or ranges, or the keyword `all'. Ranges consist
of two numbers seperated by a hyphen. Examples:
if (cmd == NULL || *cmd == '\000')
error ("Please specify a command following the thread ID list");
- old_chain = make_cleanup ((make_cleanup_func) restore_current_thread,
- (void *) inferior_pid);
+ old_chain = make_cleanup_restore_current_thread (inferior_pid);
for (tp = thread_list; tp; tp = tp->next)
if (thread_alive (tp))
#endif
execute_command (cmd, from_tty);
}
+
+ do_cleanups (old_chain);
}
static void
if (*cmd == '\000')
error ("Please specify a command following the thread ID list");
- old_chain = make_cleanup ((make_cleanup_func) restore_current_thread,
- (void *) inferior_pid);
+ old_chain = make_cleanup_restore_current_thread (inferior_pid);
while (tidlist < cmd)
{
}
}
}
+
+ do_cleanups (old_chain);
}
/* Switch to the specified thread. Will dispatch off to thread_apply_command