2008-10-15 Pedro Alves <pedro@codesourcery.com>
+ * remote.c (remote_close): Unregister remote_desc from the event
+ loop. Always restore the SIGINT handler. Discard all inferiors
+ here.
+ (remote_detach_1, remote_disconnect): Don't unregister the file
+ descriptor from the event loop here.
+ (interrupt_query, readchar, getpkt_sane): Pop the target instead
+ of morning the current inferior.
+ (remote_kill): Don't unregister the file descriptor from the event
+ loop here.
+ (remote_mourn_1): Don't discard inferiors here.
+
+2008-10-15 Pedro Alves <pedro@codesourcery.com>
+
* breakpoint.c (breakpoint_init_inferior): Clean up the moribund
locations list.
(moribund_breakpoint_here_p): Record the moribund
remote_close (int quitting)
{
if (remote_desc)
- serial_close (remote_desc);
- remote_desc = NULL;
+ {
+ /* Unregister the file descriptor from the event loop. */
+ if (target_is_async_p ())
+ target_async (NULL, 0);
+ serial_close (remote_desc);
+ remote_desc = NULL;
+ }
+
+ /* Make sure we don't leave the async SIGINT signal handler
+ installed. */
+ signal (SIGINT, handle_sigint);
+
+ /* We don't have a connection to the remote stub anymore. Get rid
+ of all the inferiors and their threads we were controlling. */
+ discard_all_inferiors ();
+
+ generic_mourn_inferior ();
}
/* Query the remote side for the text, data and bss offsets. */
else
error (_("Can't detach process."));
- /* Unregister the file descriptor from the event loop. */
- if (target_is_async_p ())
- serial_async (remote_desc, NULL, 0);
-
if (from_tty)
{
if (remote_multi_process_p (rs))
if (args)
error (_("Argument given to \"disconnect\" when remotely debugging."));
- /* Unregister the file descriptor from the event loop. */
- if (target_is_async_p ())
- serial_async (remote_desc, NULL, 0);
-
/* Make sure we unpush even the extended remote targets; mourn
won't do it. So call remote_mourn_1 directly instead of
target_mourn_inferior. */
if (query ("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? "))
{
- target_mourn_inferior ();
- signal (SIGINT, handle_sigint);
+ pop_target ();
deprecated_throw_reason (RETURN_QUIT);
}
switch ((enum serial_rc) ch)
{
case SERIAL_EOF:
- target_mourn_inferior ();
+ pop_target ();
error (_("Remote connection closed"));
/* no return */
case SERIAL_ERROR:
if (forever) /* Watchdog went off? Kill the target. */
{
QUIT;
- target_mourn_inferior ();
+ pop_target ();
error (_("Watchdog timeout has expired. Target detached."));
}
if (remote_debug)
static void
remote_kill (void)
{
- /* Unregister the file descriptor from the event loop. */
- if (target_is_async_p ())
- serial_async (remote_desc, NULL, 0);
-
/* Use catch_errors so the user can quit from gdb even when we
aren't on speaking terms with the remote system. */
catch_errors ((catch_errors_ftype *) putpkt, "k", "", RETURN_MASK_ERROR);
static void
remote_mourn_1 (struct target_ops *target)
{
- /* Get rid of all the inferiors and their threads we were
- controlling. */
- discard_all_inferiors ();
-
unpush_target (target);
- generic_mourn_inferior ();
+
+ /* remote_close takes care of cleaning up. */
}
static int