* top.c (any_thread_of, kill_or_detach): New functions.
(quit_target): Iterate over all inferiors, killing or detaching accordingly.
This commit is contained in:
parent
181e7f9393
commit
54a012c9c7
2 changed files with 46 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
|||
2008-09-22 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
* top.c (any_thread_of, kill_or_detach): New functions.
|
||||
(quit_target): Iterate over all inferiors, killing or detaching
|
||||
accordingly.
|
||||
|
||||
2008-09-22 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
Remove the attach_flag global, and make it per-inferior.
|
||||
|
|
50
gdb/top.c
50
gdb/top.c
|
@ -1204,27 +1204,57 @@ quit_confirm (void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Helper routine for quit_force that requires error handling. */
|
||||
|
||||
struct qt_args
|
||||
{
|
||||
char *args;
|
||||
int from_tty;
|
||||
};
|
||||
|
||||
/* Callback for iterate_over_threads. Finds any thread of inferior
|
||||
given by ARG (really an int*). */
|
||||
|
||||
static int
|
||||
any_thread_of (struct thread_info *thread, void *arg)
|
||||
{
|
||||
int pid = * (int *)arg;
|
||||
|
||||
if (PIDGET (thread->ptid) == pid)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback for iterate_over_inferiors. Kills or detaches the given
|
||||
inferior, depending on how we originally gained control of it. */
|
||||
|
||||
static int
|
||||
kill_or_detach (struct inferior *inf, void *args)
|
||||
{
|
||||
struct qt_args *qt = args;
|
||||
struct thread_info *thread;
|
||||
|
||||
thread = iterate_over_threads (any_thread_of, &inf->pid);
|
||||
if (thread)
|
||||
{
|
||||
switch_to_thread (thread->ptid);
|
||||
if (inf->attach_flag)
|
||||
target_detach (qt->args, qt->from_tty);
|
||||
else
|
||||
target_kill ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper routine for quit_force that requires error handling. */
|
||||
|
||||
static int
|
||||
quit_target (void *arg)
|
||||
{
|
||||
struct qt_args *qt = (struct qt_args *)arg;
|
||||
|
||||
if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
|
||||
{
|
||||
struct inferior *inf = current_inferior ();
|
||||
if (inf->attach_flag)
|
||||
target_detach (qt->args, qt->from_tty);
|
||||
else
|
||||
target_kill ();
|
||||
}
|
||||
/* Kill or detach all inferiors. */
|
||||
iterate_over_inferiors (kill_or_detach, qt);
|
||||
|
||||
/* Give all pushed targets a chance to do minimal cleanup, and pop
|
||||
them all out. */
|
||||
|
|
Loading…
Reference in a new issue