2015-08-07 Pedro Alves <palves@redhat.com>
+ * darwin-nat.c (darwin_stop): Rename to ...
+ (darwin_interrupt): ... this.
+ (_initialize_darwin_inferior): Adjust.
+ * gnu-nat.c (gnu_stop): Delete.
+ (gnu_target): Don't install gnu_stop.
+ * inf-ptrace.c (inf_ptrace_stop): Rename to ...
+ (inf_ptrace_interrupt): ... this.
+ (inf_ptrace_target): Adjust.
+ * infcmd.c (interrupt_target_1): Use target_interrupt instead of
+ target_stop.
+ * linux-nat (linux_nat_stop): Rename to ...
+ (linux_nat_interrupt): ... this.
+ (linux_nat_stop): Reimplement.
+ (linux_nat_add_target): Install linux_nat_interrupt.
+ * nto-procfs.c (nto_interrupt_twice): Rename to ...
+ (nto_handle_sigint_twice): ... this.
+ (nto_interrupt): Rename to ...
+ (nto_handle_sigint): ... this. Call target_interrupt instead of
+ target_stop.
+ (procfs_wait): Adjust.
+ (procfs_stop): Rename to ...
+ (procfs_interrupt): ... this.
+ (init_procfs_targets): Adjust.
+ * procfs.c (procfs_stop): Rename to ...
+ (procfs_interrupt): ... this.
+ (procfs_target): Adjust.
+ * remote-m32r-sdi.c (m32r_stop): Rename to ...
+ (m32r_interrupt): ... this.
+ (init_m32r_ops): Adjust.
+ * remote-sim.c (gdbsim_stop_inferior): Rename to ...
+ (gdbsim_interrupt_inferior): ... this.
+ (gdbsim_stop): Rename to ...
+ (gdbsim_interrupt): ... this.
+ (gdbsim_cntrl_c): Adjust.
+ (init_gdbsim_ops): Adjust.
+ * remote.c (sync_remote_interrupt): Adjust comments.
+ (remote_stop_as): Rename to ...
+ (remote_interrupt_as): ... this.
+ (remote_stop): Adjust comment.
+ (remote_interrupt): New function.
+ (init_remote_ops): Install remote_interrupt.
+ * target.c (target_interrupt): New function.
+ * target.h (struct target_ops) <to_interrupt>: New field.
+ (target_interrupt): New declaration.
+ * windows-nat.c (windows_stop): Rename to ...
+ (windows_interrupt): ... this.
+ * target-delegates.c: Regenerate.
+
+2015-08-07 Pedro Alves <palves@redhat.com>
+
* signal-while-stepping-over-bp-other-thread.exp: Expect "restart
threads" as alternative to "switching back to stepped thread".
#define PTRACE(CMD, PID, ADDR, SIG) \
darwin_ptrace(#CMD, CMD, (PID), (ADDR), (SIG))
-static void darwin_stop (struct target_ops *self, ptid_t);
+static void darwin_interrupt (struct target_ops *self, ptid_t);
static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step,
enum gdb_signal signal);
}
static void
-darwin_stop (struct target_ops *self, ptid_t t)
+darwin_interrupt (struct target_ops *self, ptid_t t)
{
struct inferior *inf = current_inferior ();
darwin_ops->to_wait = darwin_wait_to;
darwin_ops->to_mourn_inferior = darwin_mourn_inferior;
darwin_ops->to_kill = darwin_kill_inferior;
- darwin_ops->to_stop = darwin_stop;
+ darwin_ops->to_interrupt = darwin_interrupt;
darwin_ops->to_resume = darwin_resume_to;
darwin_ops->to_thread_alive = darwin_thread_alive;
darwin_ops->to_pid_to_str = darwin_pid_to_str;
target_mourn_inferior ();
}
-/* Stop the inferior. */
+/* Interrupt the inferior. */
static void
-inf_ptrace_stop (struct target_ops *self, ptid_t ptid)
+inf_ptrace_interrupt (struct target_ops *self, ptid_t ptid)
{
/* Send a SIGINT to the process group. This acts just like the user
typed a ^C on the controlling terminal. Note that using a
t->to_mourn_inferior = inf_ptrace_mourn_inferior;
t->to_thread_alive = inf_ptrace_thread_alive;
t->to_pid_to_str = inf_ptrace_pid_to_str;
- t->to_stop = inf_ptrace_stop;
+ t->to_interrupt = inf_ptrace_interrupt;
t->to_xfer_partial = inf_ptrace_xfer_partial;
#if defined (PT_IO) && defined (PIOD_READ_AUXV)
t->to_auxv_parse = inf_ptrace_auxv_parse;
ptid = minus_one_ptid;
else
ptid = inferior_ptid;
- target_stop (ptid);
+ target_interrupt (ptid);
/* Tag the thread as having been explicitly requested to stop, so
other parts of gdb know not to resume this thread automatically,
static void
linux_nat_stop (struct target_ops *self, ptid_t ptid)
{
- if (target_is_non_stop_p ())
+ iterate_over_lwps (ptid, linux_nat_stop_lwp, NULL);
+}
+
+static void
+linux_nat_interrupt (struct target_ops *self, ptid_t ptid)
+{
+ if (non_stop)
iterate_over_lwps (ptid, linux_nat_stop_lwp, NULL);
else
- linux_ops->to_stop (linux_ops, ptid);
+ linux_ops->to_interrupt (linux_ops, ptid);
}
static void
super_close = t->to_close;
t->to_close = linux_nat_close;
- /* Methods for non-stop support. */
t->to_stop = linux_nat_stop;
+ t->to_interrupt = linux_nat_interrupt;
t->to_supports_multi_process = linux_nat_supports_multi_process;
/* The user typed ^C twice. */
static void
-nto_interrupt_twice (int signo)
+nto_handle_sigint_twice (int signo)
{
signal (signo, ofunc);
interrupt_query ();
- signal (signo, nto_interrupt_twice);
+ signal (signo, nto_handle_sigint_twice);
}
static void
-nto_interrupt (int signo)
+nto_handle_sigint (int signo)
{
/* If this doesn't work, try more severe steps. */
- signal (signo, nto_interrupt_twice);
+ signal (signo, nto_handle_sigint_twice);
- target_stop (inferior_ptid);
+ target_interrupt (inferior_ptid);
}
static ptid_t
devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);
while (!(status.flags & _DEBUG_FLAG_ISTOP))
{
- ofunc = (void (*)()) signal (SIGINT, nto_interrupt);
+ ofunc = (void (*)()) signal (SIGINT, nto_handle_sigint);
sigwaitinfo (&set, &info);
signal (SIGINT, ofunc);
devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);
}
static void
-procfs_stop (struct target_ops *self, ptid_t ptid)
+procfs_interrupt (struct target_ops *self, ptid_t ptid)
{
devctl (ctl_fd, DCMD_PROC_STOP, NULL, 0, 0);
}
t->to_thread_alive = procfs_thread_alive;
t->to_update_thread_list = procfs_update_thread_list;
t->to_pid_to_str = procfs_pid_to_str;
- t->to_stop = procfs_stop;
+ t->to_interrupt = procfs_interrupt;
t->to_have_continuable_watchpoint = 1;
t->to_extra_thread_info = nto_extra_thread_info;
static void procfs_detach (struct target_ops *, const char *, int);
static void procfs_resume (struct target_ops *,
ptid_t, int, enum gdb_signal);
-static void procfs_stop (struct target_ops *self, ptid_t);
+static void procfs_interrupt (struct target_ops *self, ptid_t);
static void procfs_files_info (struct target_ops *);
static void procfs_fetch_registers (struct target_ops *,
struct regcache *, int);
t->to_xfer_partial = procfs_xfer_partial;
t->to_pass_signals = procfs_pass_signals;
t->to_files_info = procfs_files_info;
- t->to_stop = procfs_stop;
+ t->to_interrupt = procfs_interrupt;
t->to_update_thread_list = procfs_update_thread_list;
t->to_thread_alive = procfs_thread_alive;
kill(SIGINT) to the child's process group. */
static void
-procfs_stop (struct target_ops *self, ptid_t ptid)
+procfs_interrupt (struct target_ops *self, ptid_t ptid)
{
kill (-inferior_process_group (), SIGINT);
}
}
static void
-m32r_stop (struct target_ops *self, ptid_t ptid)
+m32r_interrupt (struct target_ops *self, ptid_t ptid)
{
if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "m32r_stop()\n");
+ fprintf_unfiltered (gdb_stdlog, "m32r_interrupt()\n");
send_cmd (SDI_STOP_CPU);
m32r_ops.to_load = m32r_load;
m32r_ops.to_create_inferior = m32r_create_inferior;
m32r_ops.to_mourn_inferior = m32r_mourn_inferior;
- m32r_ops.to_stop = m32r_stop;
+ m32r_ops.to_interrupt = m32r_interrupt;
m32r_ops.to_log_command = serial_log_command;
m32r_ops.to_thread_alive = m32r_thread_alive;
m32r_ops.to_pid_to_str = m32r_pid_to_str;
static void gdbsim_mourn_inferior (struct target_ops *target);
-static void gdbsim_stop (struct target_ops *self, ptid_t ptid);
+static void gdbsim_interrupt (struct target_ops *self, ptid_t ptid);
void simulator_command (char *args, int from_tty);
error (_("The program is not being run."));
}
-/* Notify the simulator of an asynchronous request to stop.
+/* Notify the simulator of an asynchronous request to interrupt.
- The simulator shall ensure that the stop request is eventually
+ The simulator shall ensure that the interrupt request is eventually
delivered to the simulator. If the call is made while the
- simulator is not running then the stop request is processed when
+ simulator is not running then the interrupt request is processed when
the simulator is next resumed.
For simulators that do not support this operation, just abort. */
static int
-gdbsim_stop_inferior (struct inferior *inf, void *arg)
+gdbsim_interrupt_inferior (struct inferior *inf, void *arg)
{
struct sim_inferior_data *sim_data
= get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
}
static void
-gdbsim_stop (struct target_ops *self, ptid_t ptid)
+gdbsim_interrupt (struct target_ops *self, ptid_t ptid)
{
struct sim_inferior_data *sim_data;
if (ptid_equal (ptid, minus_one_ptid))
{
- iterate_over_inferiors (gdbsim_stop_inferior, NULL);
+ iterate_over_inferiors (gdbsim_interrupt_inferior, NULL);
}
else
{
error (_("Can't stop pid %d. No inferior found."),
ptid_get_pid (ptid));
- gdbsim_stop_inferior (inf, NULL);
+ gdbsim_interrupt_inferior (inf, NULL);
}
}
static void
gdbsim_cntrl_c (int signo)
{
- gdbsim_stop (NULL, minus_one_ptid);
+ gdbsim_interrupt (NULL, minus_one_ptid);
}
static ptid_t
gdbsim_ops.to_load = gdbsim_load;
gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
gdbsim_ops.to_mourn_inferior = gdbsim_mourn_inferior;
- gdbsim_ops.to_stop = gdbsim_stop;
+ gdbsim_ops.to_interrupt = gdbsim_interrupt;
gdbsim_ops.to_thread_alive = gdbsim_thread_alive;
gdbsim_ops.to_pid_to_str = gdbsim_pid_to_str;
gdbsim_ops.to_stratum = process_stratum;
packet. */
static void (*ofunc) (int);
-/* The command line interface's stop routine. This function is installed
- as a signal handler for SIGINT. The first time a user requests a
- stop, we call remote_stop to send a break or ^C. If there is no
+/* The command line interface's interrupt routine. This function is installed
+ as a signal handler for SIGINT. The first time a user requests an
+ interrupt, we call remote_interrupt to send a break or ^C. If there is no
response from the target (it didn't stop when the user requested it),
we ask the user if he'd like to detach from the target. */
+
static void
sync_remote_interrupt (int signo)
{
error (_("Stopping %s failed: %s"), target_pid_to_str (ptid), rs->buf);
}
-/* All-stop version of target_stop. Sends a break or a ^C to stop the
- remote target. It is undefined which thread of which process
- reports the stop. */
+/* All-stop version of target_interrupt. Sends a break or a ^C to
+ interrupt the remote target. It is undefined which thread of which
+ process reports the interrupt. */
static void
-remote_stop_as (ptid_t ptid)
+remote_interrupt_as (ptid_t ptid)
{
struct remote_state *rs = get_remote_state ();
send_interrupt_sequence ();
}
-/* This is the generic stop called via the target vector. When a target
- interrupt is requested, either by the command line or the GUI, we
- will eventually end up here. */
+/* Implement the to_stop function for the remote targets. */
static void
remote_stop (struct target_ops *self, ptid_t ptid)
if (non_stop)
remote_stop_ns (ptid);
else
- remote_stop_as (ptid);
+ {
+ /* We don't currently have a way to transparently pause the
+ remote target in all-stop mode. Interrupt it instead. */
+ remote_interrupt_as (ptid);
+ }
+}
+
+/* Implement the to_interrupt function for the remote targets. */
+
+static void
+remote_interrupt (struct target_ops *self, ptid_t ptid)
+{
+ if (remote_debug)
+ fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n");
+
+ if (non_stop)
+ {
+ /* We don't currently have a way to ^C the remote target in
+ non-stop mode. Stop it (with no signal) instead. */
+ remote_stop_ns (ptid);
+ }
+ else
+ remote_interrupt_as (ptid);
}
/* Ask the user what to do when an interrupt is received. */
remote_ops.to_extra_thread_info = remote_threads_extra_info;
remote_ops.to_get_ada_task_ptid = remote_get_ada_task_ptid;
remote_ops.to_stop = remote_stop;
+ remote_ops.to_interrupt = remote_interrupt;
remote_ops.to_xfer_partial = remote_xfer_partial;
remote_ops.to_rcmd = remote_rcmd;
remote_ops.to_pid_to_exec_file = remote_pid_to_exec_file;
}
static void
+delegate_interrupt (struct target_ops *self, ptid_t arg1)
+{
+ self = self->beneath;
+ self->to_interrupt (self, arg1);
+}
+
+static void
+tdefault_interrupt (struct target_ops *self, ptid_t arg1)
+{
+}
+
+static void
+debug_interrupt (struct target_ops *self, ptid_t arg1)
+{
+ fprintf_unfiltered (gdb_stdlog, "-> %s->to_interrupt (...)\n", debug_target.to_shortname);
+ debug_target.to_interrupt (&debug_target, arg1);
+ fprintf_unfiltered (gdb_stdlog, "<- %s->to_interrupt (", debug_target.to_shortname);
+ target_debug_print_struct_target_ops_p (&debug_target);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_ptid_t (arg1);
+ fputs_unfiltered (")\n", gdb_stdlog);
+}
+
+static void
delegate_rcmd (struct target_ops *self, const char *arg1, struct ui_file *arg2)
{
self = self->beneath;
ops->to_thread_name = delegate_thread_name;
if (ops->to_stop == NULL)
ops->to_stop = delegate_stop;
+ if (ops->to_interrupt == NULL)
+ ops->to_interrupt = delegate_interrupt;
if (ops->to_rcmd == NULL)
ops->to_rcmd = delegate_rcmd;
if (ops->to_pid_to_exec_file == NULL)
ops->to_extra_thread_info = tdefault_extra_thread_info;
ops->to_thread_name = tdefault_thread_name;
ops->to_stop = tdefault_stop;
+ ops->to_interrupt = tdefault_interrupt;
ops->to_rcmd = default_rcmd;
ops->to_pid_to_exec_file = tdefault_pid_to_exec_file;
ops->to_log_command = tdefault_log_command;
ops->to_extra_thread_info = debug_extra_thread_info;
ops->to_thread_name = debug_thread_name;
ops->to_stop = debug_stop;
+ ops->to_interrupt = debug_interrupt;
ops->to_rcmd = debug_rcmd;
ops->to_pid_to_exec_file = debug_pid_to_exec_file;
ops->to_log_command = debug_log_command;
(*current_target.to_stop) (¤t_target, ptid);
}
+void
+target_interrupt (ptid_t ptid)
+{
+ if (!may_stop)
+ {
+ warning (_("May not interrupt or stop the target, ignoring attempt"));
+ return;
+ }
+
+ (*current_target.to_interrupt) (¤t_target, ptid);
+}
+
/* See target/target.h. */
void
TARGET_DEFAULT_RETURN (NULL);
void (*to_stop) (struct target_ops *, ptid_t)
TARGET_DEFAULT_IGNORE ();
+ void (*to_interrupt) (struct target_ops *, ptid_t)
+ TARGET_DEFAULT_IGNORE ();
void (*to_rcmd) (struct target_ops *,
const char *command, struct ui_file *output)
TARGET_DEFAULT_FUNC (default_rcmd);
extern void target_stop (ptid_t ptid);
+/* Interrupt the target just like the user typed a ^C on the
+ inferior's controlling terminal. (For instance, under Unix, this
+ should act like SIGINT). This function is asynchronous. */
+
+extern void target_interrupt (ptid_t ptid);
+
/* Send the specified COMMAND to the target's monitor
(shell,interpreter) for execution. The result of the query is
placed in OUTBUF. */
#define DEBUG_MEM(x) if (debug_memory) printf_unfiltered x
#define DEBUG_EXCEPT(x) if (debug_exceptions) printf_unfiltered x
-static void windows_stop (struct target_ops *self, ptid_t);
+static void windows_interrupt (struct target_ops *self, ptid_t);
static int windows_thread_alive (struct target_ops *, ptid_t);
static void windows_kill_inferior (struct target_ops *);
^C on the controlling terminal. */
static void
-windows_stop (struct target_ops *self, ptid_t ptid)
+windows_interrupt (struct target_ops *self, ptid_t ptid)
{
DEBUG_EVENTS (("gdb: GenerateConsoleCtrlEvent (CTRLC_EVENT, 0)\n"));
CHECK (GenerateConsoleCtrlEvent (CTRL_C_EVENT, current_event.dwProcessId));
t->to_mourn_inferior = windows_mourn_inferior;
t->to_thread_alive = windows_thread_alive;
t->to_pid_to_str = windows_pid_to_str;
- t->to_stop = windows_stop;
+ t->to_interrupt = windows_interrupt;
t->to_pid_to_exec_file = windows_pid_to_exec_file;
t->to_get_ada_task_ptid = windows_get_ada_task_ptid;
t->to_get_tib_address = windows_get_tib_address;