aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-08-14 14:28:15 +0000
committerPedro Alves <palves@redhat.com>2009-08-14 14:28:15 +0000
commitb8fa0bfa752bb672c66a1d6fdefcdf4cb308a712 (patch)
treee0bb75b8b5543a6b672126496ccc8b85b483a18f /gdb/target.c
parentcc70f101e24176980f0cb5d88d25ee9128b6d0cd (diff)
downloadgdb-b8fa0bfa752bb672c66a1d6fdefcdf4cb308a712.zip
gdb-b8fa0bfa752bb672c66a1d6fdefcdf4cb308a712.tar.gz
gdb-b8fa0bfa752bb672c66a1d6fdefcdf4cb308a712.tar.bz2
2009-08-14 Pedro Alves <pedro@codesourcery.com>
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 <pedro@codesourcery.com> gdb/testsuite/ * gdb.threads/killed.exp, gdb.threads/manythreads.exp, gdb.threads/staticthreads.exp: Adjust to "quit" output changes.
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c30
1 files changed, 27 insertions, 3 deletions
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."));
}