static void remote_store_registers (struct regcache *regcache, int regno);
-static void remote_mourn (void);
+static void remote_mourn (struct target_ops *ops);
static void extended_remote_restart (void);
-static void extended_remote_mourn (void);
+static void extended_remote_mourn (struct target_ops *);
static void remote_mourn_1 (struct target_ops *);
static int remote_async_mask (int new_mask);
-static void remote_detach (char *args, int from_tty);
+static void remote_detach (struct target_ops *ops, char *args, int from_tty);
static void remote_interrupt (int signo);
static void remote_async_inferior_event_handler (gdb_client_data);
static void remote_async_get_pending_events_handler (gdb_client_data);
+static void remote_terminal_ours (void);
+
/* The non-stop remote protocol provisions for one pending stop reply.
This is where we keep it until it is acknowledged. */
static void
notice_new_inferiors (ptid_t currthread)
{
- /* When connecting to a target remote, or to a target
- extended-remote which already was debugging an inferior, we may
- not know about it yet. Add it before adding its child thread, so
- notifications are emitted in a sensible order. */
- if (!in_inferior_list (ptid_get_pid (currthread)))
- add_inferior (ptid_get_pid (currthread));
-
/* If this is a new thread, add it to GDB's thread list.
If we leave it up to WFI to do this, bad things will happen. */
return;
}
+ /* When connecting to a target remote, or to a target
+ extended-remote which already was debugging an inferior, we
+ may not know about it yet. Add it before adding its child
+ thread, so notifications are emitted in a sensible order. */
+ if (!in_inferior_list (ptid_get_pid (currthread)))
+ add_inferior (ptid_get_pid (currthread));
+
/* This is really a new thread. Add it. */
add_thread (currthread);
}
static void
remote_close (int quitting)
{
- if (remote_desc)
- {
- /* Unregister the file descriptor from the event loop. */
- if (target_is_async_p ())
- target_async (NULL, 0);
- serial_close (remote_desc);
- remote_desc = NULL;
- }
+ if (remote_desc == NULL)
+ return; /* already closed */
- /* Make sure we don't leave the async SIGINT signal handler
- installed. */
- signal (SIGINT, handle_sigint);
+ /* Make sure we leave stdin registered in the event loop, and we
+ don't leave the async SIGINT signal handler installed. */
+ remote_terminal_ours ();
+
+ serial_close (remote_desc);
+ remote_desc = NULL;
/* We don't have a connection to the remote stub anymore. Get rid
of all the inferiors and their threads we were controlling. */
getpkt (&rs->buf, &rs->buf_size, 0);
}
+ /* On OSs where the list of libraries is global to all
+ processes, we fetch them early. */
+ if (gdbarch_has_global_solist (target_gdbarch))
+ solib_add (NULL, args->from_tty, args->target, auto_solib_add);
+
/* Next, if the target can specify a description, read it. We do
this before anything involving memory or registers. */
target_find_description ();
if (exec_bfd) /* No use without an exec file. */
remote_check_symbols (symfile_objfile);
}
+
+ /* If code is shared between processes, then breakpoints are global
+ too; Insert them now. */
+ if (gdbarch_has_global_solist (target_gdbarch)
+ && breakpoints_always_inserted_mode ())
+ insert_breakpoints ();
}
/* Open a connection to a remote debugger.
}
static void
-remote_detach (char *args, int from_tty)
+remote_detach (struct target_ops *ops, char *args, int from_tty)
{
remote_detach_1 (args, from_tty, 0);
}
static void
-extended_remote_detach (char *args, int from_tty)
+extended_remote_detach (struct target_ops *ops, char *args, int from_tty)
{
remote_detach_1 (args, from_tty, 1);
}
}
static void
-extended_remote_attach (char *args, int from_tty)
+extended_remote_attach (struct target_ops *ops, char *args, int from_tty)
{
- extended_remote_attach_1 (&extended_remote_ops, args, from_tty);
+ extended_remote_attach_1 (ops, args, from_tty);
}
/* Convert hex digit A to a number. */
}
static void
-remote_mourn (void)
+remote_mourn (struct target_ops *ops)
{
- remote_mourn_1 (&remote_ops);
+ remote_mourn_1 (ops);
}
/* Worker function for remote_mourn. */
}
static void
-extended_remote_mourn (void)
+extended_remote_mourn (struct target_ops *ops)
{
- extended_remote_mourn_1 (&extended_remote_ops);
+ extended_remote_mourn_1 (ops);
}
static int
}
static void
-extended_remote_create_inferior (char *exec_file, char *args,
+extended_remote_create_inferior (struct target_ops *ops,
+ char *exec_file, char *args,
char **env, int from_tty)
{
extended_remote_create_inferior_1 (exec_file, args, env, from_tty);
error (_("Remote I/O error: %s"), safe_strerror (host_error));
}
-static void
-fclose_cleanup (void *file)
-{
- fclose (file);
-}
-
static void
remote_hostio_close_cleanup (void *opaque)
{
file = fopen (local_file, "rb");
if (file == NULL)
perror_with_name (local_file);
- back_to = make_cleanup (fclose_cleanup, file);
+ back_to = make_cleanup_fclose (file);
fd = remote_hostio_open (remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
| FILEIO_O_TRUNC),
file = fopen (local_file, "wb");
if (file == NULL)
perror_with_name (local_file);
- back_to = make_cleanup (fclose_cleanup, file);
+ back_to = make_cleanup_fclose (file);
/* Send up to this many bytes at once. They won't all fit in the
remote packet limit, so we'll transfer slightly fewer. */
return 1;
}
+static int
+remote_supports_multi_process (void)
+{
+ struct remote_state *rs = get_remote_state ();
+ return remote_multi_process_p (rs);
+}
+
static void
init_remote_ops (void)
{
remote_ops.to_terminal_inferior = remote_terminal_inferior;
remote_ops.to_terminal_ours = remote_terminal_ours;
remote_ops.to_supports_non_stop = remote_supports_non_stop;
+ remote_ops.to_supports_multi_process = remote_supports_multi_process;
}
/* Set up the extended remote vector by making a copy of the standard