From b8fa0bfa752bb672c66a1d6fdefcdf4cb308a712 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 14 Aug 2009 14:28:15 +0000 Subject: 2009-08-14 Pedro Alves gdb/ * top.c (any_thread_of): Delete. (kill_or_detach): Use any_thread_of_process. * top.c (print_inferior_quit_action): New. (quit_confirm): Rewrite to print info about all inferiors. * target.c (dispose_inferior): New. (target_preopen): Use it. 2009-08-14 Pedro Alves gdb/testsuite/ * gdb.threads/killed.exp, gdb.threads/manythreads.exp, gdb.threads/staticthreads.exp: Adjust to "quit" output changes. --- gdb/target.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'gdb/target.c') diff --git a/gdb/target.c b/gdb/target.c index 6a6c48e..7ee444f 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1904,6 +1904,29 @@ target_pre_inferior (int from_tty) } } +/* Callback for iterate_over_inferiors. Gets rid of the given + inferior. */ + +static int +dispose_inferior (struct inferior *inf, void *args) +{ + struct thread_info *thread; + + thread = any_thread_of_process (inf->pid); + if (thread) + { + switch_to_thread (thread->ptid); + + /* Core inferiors actually should be detached, not killed. */ + if (target_has_execution) + target_kill (); + else + target_detach (NULL, 0); + } + + return 0; +} + /* This is to be called by the open routine before it does anything. */ @@ -1912,11 +1935,12 @@ target_preopen (int from_tty) { dont_repeat (); - if (target_has_execution) + if (have_inferiors ()) { if (!from_tty - || query (_("A program is being debugged already. Kill it? "))) - target_kill (); + || !have_live_inferiors () + || query (_("A program is being debugged already. Kill it? "))) + iterate_over_inferiors (dispose_inferior, NULL); else error (_("Program not killed.")); } -- cgit v1.1