+2009-03-17 Joel Brobecker <brobecker@adacore.com>
+
+ Add a target_ops parameter to the to_kill method in struct target_ops.
+
+ * target.h (struct target_ops): Add a "target_ops *" parameter to
+ method to_kill.
+ (target_kill): Remove macro. Add declaration.
+ * target.c (debug_to_kill): Delete, no longer necessary.
+ (target_kill): New function.
+ (update_current_target): Stop inheriting the to_kill method.
+ Do not de_fault it to no_process either.
+ (setup_target_debug): Do not set current_target.to_kill.
+ * gnu-nat.c, go32-nat.c, hpux-thread.c, inf-ptrace.c, inf-ttrace.c,
+ linux-nat.c, monitor.c, nto-procfs.c, procfs.c, remote-m32r-sdi.c,
+ remote-mips.c, remote-sim.c, remote.c, windows-nat.c: Update
+ accordingly.
+
2009-03-17 Doug Evans <dje@google.com>
* amd64-linux-nat.c (si_timerid,si_overrun): Provide definition for
\f
static void
-gnu_kill_inferior (void)
+gnu_kill_inferior (struct target_ops *ops)
{
struct proc *task = gnu_current_inf->task;
if (task)
struct target_ops *target);
static void go32_files_info (struct target_ops *target);
static void go32_stop (ptid_t);
-static void go32_kill_inferior (void);
+static void go32_kill_inferior (struct target_ops *ops);
static void go32_create_inferior (struct target_ops *ops, char *exec_file,
char *args, char **env, int from_tty);
static void go32_mourn_inferior (struct target_ops *ops);
}
static void
-go32_kill_inferior (void)
+go32_kill_inferior (struct target_ops *ops)
{
redir_cmdline_delete (&child_cmd);
resume_signal = -1;
if (prog_has_started)
{
go32_stop (inferior_ptid);
- go32_kill_inferior ();
+ go32_kill_inferior (ops);
}
resume_signal = -1;
resume_is_step = 0;
at all times, but it doesn't, probably under an assumption that
the OS cleans up when the debuggee exits. */
i386_cleanup_dregs ();
- go32_kill_inferior ();
+ go32_kill_inferior (ops);
generic_mourn_inferior ();
}
}
static void
-hpux_thread_kill_inferior (void)
+hpux_thread_kill_inferior (struct target_ops *ops)
{
- deprecated_child_ops.to_kill ();
+ deprecated_child_ops.to_kill (&deprecated_child_ops);
}
static void
/* Kill the inferior. */
static void
-inf_ptrace_kill (void)
+inf_ptrace_kill (struct target_ops *ops)
{
pid_t pid = ptid_get_pid (inferior_ptid);
int status;
}
static void
-inf_ttrace_kill (void)
+inf_ttrace_kill (struct target_ops *ops)
{
pid_t pid = ptid_get_pid (inferior_ptid);
}
static void
-linux_nat_kill (void)
+linux_nat_kill (struct target_ops *ops)
{
struct target_waitstatus last;
ptid_t last_ptid;
}
static void
-monitor_kill (void)
+monitor_kill (struct target_ops *ops)
{
return; /* ignore attempts to kill target system */
}
}
static void
-procfs_kill_inferior (void)
+procfs_kill_inferior (struct target_ops *ops)
{
target_mourn_inferior ();
}
static void procfs_store_registers (struct target_ops *,
struct regcache *, int);
static void procfs_notice_signals (ptid_t);
-static void procfs_kill_inferior (void);
+static void procfs_kill_inferior (struct target_ops *ops);
static void procfs_mourn_inferior (struct target_ops *ops);
static void procfs_create_inferior (struct target_ops *, char *,
char *, char **, int);
*/
static void
-procfs_kill_inferior (void)
+procfs_kill_inferior (struct target_ops *ops)
{
if (!ptid_equal (inferior_ptid, null_ptid)) /* ? */
{
}
static void
-m32r_kill (void)
+m32r_kill (struct target_ops *ops)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "m32r_kill()\n");
right port, we could interrupt the process with a break signal. */
static void
-mips_kill (void)
+mips_kill (struct target_ops *ops)
{
if (!mips_wait_flag)
return;
to a different value than GDB thinks it has. The following ensures
that the write_pc() WILL update the PC value: */
struct regcache *regcache = get_current_regcache ();
-
regcache_invalidate (regcache,
gdbarch_pc_regnum (get_regcache_arch (regcache)));
}
static void gdb_os_error (host_callback *, const char *, ...) ATTR_NORETURN;
-static void gdbsim_kill (void);
+static void gdbsim_kill (struct target_ops *);
static void gdbsim_load (char *prog, int fromtty);
and releasing other resources acquired by the simulated program. */
static void
-gdbsim_kill (void)
+gdbsim_kill (struct target_ops *ops)
{
if (remote_debug)
printf_filtered ("gdbsim_kill\n");
args);
if (ptid_equal (inferior_ptid, remote_sim_ptid))
- gdbsim_kill ();
+ gdbsim_kill (target);
remove_breakpoints ();
init_wait_for_inferior ();
static int readchar (int timeout);
-static void remote_kill (void);
+static void remote_kill (struct target_ops *ops);
static int tohex (int nib);
\f
static void
-remote_kill (void)
+remote_kill (struct target_ops *ops)
{
/* Use catch_errors so the user can quit from gdb even when we
aren't on speaking terms with the remote system. */
}
static void
-extended_remote_kill (void)
+extended_remote_kill (struct target_ops *ops)
{
int res;
int pid = ptid_get_pid (inferior_ptid);
static void debug_to_terminal_info (char *, int);
-static void debug_to_kill (void);
-
static void debug_to_load (char *, int);
static int debug_to_lookup_symbol (char *, CORE_ADDR *);
}
void
+target_kill (void)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_kill != NULL)
+ {
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
+
+ t->to_kill (t);
+ return;
+ }
+
+ noprocess ();
+}
+
+void
target_load (char *arg, int from_tty)
{
dcache_invalidate (target_dcache);
INHERIT (to_terminal_ours, t);
INHERIT (to_terminal_save_ours, t);
INHERIT (to_terminal_info, t);
- INHERIT (to_kill, t);
+ /* Do not inherit to_kill. */
INHERIT (to_load, t);
INHERIT (to_lookup_symbol, t);
/* Do no inherit to_create_inferior. */
target_ignore);
de_fault (to_terminal_info,
default_terminal_info);
- de_fault (to_kill,
- (void (*) (void))
- noprocess);
de_fault (to_load,
(void (*) (char *, int))
tcomplain);
}
static void
-debug_to_kill (void)
-{
- debug_target.to_kill ();
-
- fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
-}
-
-static void
debug_to_load (char *args, int from_tty)
{
debug_target.to_load (args, from_tty);
current_target.to_terminal_ours = debug_to_terminal_ours;
current_target.to_terminal_save_ours = debug_to_terminal_save_ours;
current_target.to_terminal_info = debug_to_terminal_info;
- current_target.to_kill = debug_to_kill;
current_target.to_load = debug_to_load;
current_target.to_lookup_symbol = debug_to_lookup_symbol;
current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
void (*to_terminal_ours) (void);
void (*to_terminal_save_ours) (void);
void (*to_terminal_info) (char *, int);
- void (*to_kill) (void);
+ void (*to_kill) (struct target_ops *);
void (*to_load) (char *, int);
int (*to_lookup_symbol) (char *, CORE_ADDR *);
void (*to_create_inferior) (struct target_ops *,
/* Kill the inferior process. Make it go away. */
-#define target_kill() \
- (*current_target.to_kill) ()
+extern void target_kill (void);
/* Load an executable file into the target process. This is expected
to not only bring new code into the target process, but also to
static void windows_stop (ptid_t);
static int windows_thread_alive (struct target_ops *, ptid_t);
-static void windows_kill_inferior (void);
+static void windows_kill_inferior (struct target_ops *);
static enum target_signal last_sig = TARGET_SIGNAL_0;
/* Set if a signal was received from the debugged process */
detach = deprecated_ui_loop_hook (0);
if (detach)
- windows_kill_inferior ();
+ windows_kill_inferior (ops);
}
}
}
}
static void
-windows_kill_inferior (void)
+windows_kill_inferior (struct target_ops *ops)
{
CHECK (TerminateProcess (current_process_handle, 0));