2008-11-09 Vladimir Prus <vladimir@codesourcery.com>
+ Kill pthread_ops_hack
+
+ * target.h (struct target_ops): Make to_attach, to_detach,
+ to_create_inferior and to_mourn_inferior accept a pointer
+ to struct target_ops.
+ (target_attach, target_create_inferior, target_create_inferior):
+ Convert from macros to function. Find the right target to
+ invoke a method of.
+ (find_default_attach, find_default_create_inferior): New parameter
+ ops.
+ * corefile.c (core_file_command): Pass target to to_detach.
+ * corelow.c (core_detach): Add 'ops' parameter.
+ * fork-child.c (fork_inferior): Return the pid. Allow
+ init_trace_fun to be NULL.
+ * inf-ptrace (ptrace_ops_hack): Remove.
+ (inf_ptrace_him): Remove, moving all logic into....
+ (inf_ptrace_create_inferior): ... here. Push the target
+ passed as parameter.
+ (inf_ptrace_mourn_inferior, inf_ptrace_attach, inf_ptrace_detach):
+ Push/pop target passed as parameter, no ptrace_ops_hack.
+ (inf_ptrace_target): Don't remember result.
+ * inferior.h (fork_inferior): Adjust prototype.
+ * linux-nat.c (linux_nat_create_inferior, linux_nat_attach)
+ (linux_nat_detach, linux_nat_mourn_inferior): New parameter ops.
+ Pass it to linux_ops target.
+ * linux-thread-db.c (thread_db_detach, thread_db_mourn_inferior):
+ New parameter ops. Pass it to the target beneath.
+ * remote.c (remote_mourn, extended_remote_mourn, remote_detach)
+ (extended_remote_create_inferior): New parameter ops. Pass it
+ further.
+ * target.c (debug_to_attach, debug_to_detach)
+ (debug_to_mourn_inferior): New parameter ops.
+ (target_create_inferior): New.
+ (update_current_target): Do not inherit to_attach, to_detach,
+ to_create_inferiour, to_mourn_inferior. Do not default
+ to_detach and to_mourn_inferior.
+ (target_detach): Find the right target to use.
+ (target_mourn_inferior): New.
+ (find_default_attach, find_default_create_inferior): New parameter
+ ops. Pass the found target when calling its method.
+ (init_dummy_target): Provide fallback definition of to_detach.
+ (target_attach): New.
+ (debug_to_attach, debug_to_detach, debug_to_create_inferior)
+ (debug_to_mourn_inferiour): New parameter ops.
+ * aix-thread.c: Adjust.
+ * bsd-uthread.c: Adjust.
+ * gnu-nat.c: Adjust.
+ * go32-nat.c: Adjust.
+ * hpux-thread.c: Adjust.
+ * inf-ttrace.c: Ajust.
+ * monitor.c: Adjust.
+ * nto-procfs.c: Adjust.
+ * procfs.c: Adjust.
+ * remote-m32r-sdi.c: Adjust.
+ * remote-mips.c: Adjust.
+ * remote-sim.c: Adjust.
+ * rs6000-nat.c: Adjust.
+ * sol-thread.c: Adjust.
+ * win32-nat.c: Adjust.
+ * dec-thread.c: Adjust.
+
+2008-11-09 Vladimir Prus <vladimir@codesourcery.com>
+
* thread.c (print_thread_info): Eliminate now useless checks
for exited threads.
/* Attach to process specified by ARGS. */
static void
-aix_thread_attach (char *args, int from_tty)
+aix_thread_attach (struct target_ops *ops, char *args, int from_tty)
{
- base_target.to_attach (args, from_tty);
+ base_target.to_attach (&base_target, args, from_tty);
pd_activate (1);
}
/* Detach from the process attached to by aix_thread_attach(). */
static void
-aix_thread_detach (char *args, int from_tty)
+aix_thread_detach (struct target_ops *ops, char *args, int from_tty)
{
pd_disable ();
- base_target.to_detach (args, from_tty);
+ base_target.to_detach (&base_target, args, from_tty);
}
/* Tell the inferior process to continue running thread PID if != -1
/* Clean up after the inferior exits. */
static void
-aix_thread_mourn_inferior (void)
+aix_thread_mourn_inferior (struct target_ops *ops)
{
pd_deactivate ();
- base_target.to_mourn_inferior ();
+ base_target.to_mourn_inferior (&base_target);
}
/* Return whether thread PID is still valid. */
}
static void
-bsd_uthread_mourn_inferior (void)
+bsd_uthread_mourn_inferior (struct target_ops *ops)
{
- find_target_beneath (bsd_uthread_ops_hack)->to_mourn_inferior ();
+ struct target_ops *beneath = find_target_beneath (bsd_uthread_ops_hack);
+ beneath->to_mourn_inferior (beneath);
bsd_uthread_deactivate ();
}
error (_("GDB can't read core files on this machine."));
if (!filename)
- (t->to_detach) (filename, from_tty);
+ (t->to_detach) (t, filename, from_tty);
else
(t->to_open) (filename, from_tty);
}
static void core_open (char *, int);
-static void core_detach (char *, int);
+static void core_detach (struct target_ops *ops, char *, int);
static void core_close (int);
}
static void
-core_detach (char *args, int from_tty)
+core_detach (struct target_ops *ops, char *args, int from_tty)
{
if (args)
error (_("Too many arguments"));
- unpush_target (&core_ops);
+ unpush_target (ops);
reinit_frame_cache ();
if (from_tty)
printf_filtered (_("No core file now.\n"));
debug ("dec_thread_detach");
disable_dec_thread ();
- base_target.to_detach (args, from_tty);
+ base_target.to_detach (&base_target, args, from_tty);
}
/* Return the ptid of the thread that is currently active. */
debug ("dec_thread_mourn_inferior");
disable_dec_thread ();
- base_target.to_mourn_inferior ();
+ base_target.to_mourn_inferior (&base_target);
}
/* The "to_thread_alive" method of the dec_thread_ops. */
/* This function is NOT reentrant. Some of the variables have been
made static to ensure that they survive the vfork call. */
-void
+int
fork_inferior (char *exec_file_arg, char *allargs, char **env,
void (*traceme_fun) (void), void (*init_trace_fun) (int),
void (*pre_trace_fun) (void), char *shell_file_arg)
/* Now that we have a child process, make it our target, and
initialize anything target-vector-specific that needs
initializing. */
- (*init_trace_fun) (pid);
+ if (init_trace_fun)
+ (*init_trace_fun) (pid);
/* We are now in the child process of interest, having exec'd the
correct program, and are poised at the first instruction of the
new program. */
+ return pid;
}
/* Accept NTRAPS traps from the inferior. */
/* Clean up after the inferior dies. */
static void
-gnu_mourn_inferior (void)
+gnu_mourn_inferior (struct target_ops *ops)
{
inf_debug (gnu_current_inf, "rip");
inf_detach (gnu_current_inf);
}
static void
-gnu_create_inferior (char *exec_file, char *allargs, char **env,
+gnu_create_inferior (struct target_ops *ops,
+ char *exec_file, char *allargs, char **env,
int from_tty)
{
struct inf *inf = cur_inf ();
/* Attach to process PID, then initialize for debugging it
and wait for the trace-trap that results from attaching. */
static void
-gnu_attach (char *args, int from_tty)
+gnu_attach (struct target_ops *ops, char *args, int from_tty)
{
int pid;
char *exec_file;
previously attached. It *might* work if the program was
started via fork. */
static void
-gnu_detach (char *args, int from_tty)
+gnu_detach (struct target_ops *ops, char *args, int from_tty)
{
int pid;
static void go32_files_info (struct target_ops *target);
static void go32_stop (ptid_t);
static void go32_kill_inferior (void);
-static void go32_create_inferior (char *exec_file, char *args, char **env, int from_tty);
-static void go32_mourn_inferior (void);
+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 int go32_can_run (void);
static struct target_ops go32_ops;
}
static void
-go32_attach (char *args, int from_tty)
+go32_attach (struct target_ops *ops, char *args, int from_tty)
{
error (_("\
You cannot attach to a running program on this platform.\n\
}
static void
-go32_detach (char *args, int from_tty)
+go32_detach (struct target_ops *ops, char *args, int from_tty)
{
}
}
static void
-go32_mourn_inferior (void)
+go32_mourn_inferior (struct target_ops *ops)
{
/* We need to make sure all the breakpoint enable bits in the DR7
register are reset when the inferior exits. Otherwise, if they
and wait for the trace-trap that results from attaching. */
static void
-hpux_thread_attach (char *args, int from_tty)
+hpux_thread_attach (struct target_ops *ops, char *args, int from_tty)
{
- deprecated_child_ops.to_attach (args, from_tty);
+ deprecated_child_ops.to_attach (&deprecated_child_ops, args, from_tty);
/* XXX - might want to iterate over all the threads and register them. */
}
started via the normal ptrace (PTRACE_TRACEME). */
static void
-hpux_thread_detach (char *args, int from_tty)
+hpux_thread_detach (struct target_ops *ops, char *args, int from_tty)
{
- deprecated_child_ops.to_detach (args, from_tty);
+ deprecated_child_ops.to_detach (&deprecated_child_ops, args, from_tty);
}
/* Resume execution of process PID. If STEP is nozero, then
/* Fork an inferior process, and start debugging it with /proc. */
static void
-hpux_thread_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
+hpux_thread_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
- deprecated_child_ops.to_create_inferior (exec_file, allargs, env, from_tty);
+ deprecated_child_ops.to_create_inferior (&deprecated_child_ops,
+ exec_file, allargs, env, from_tty);
if (hpux_thread_active)
{
static void
hpux_thread_mourn_inferior (void)
{
- deprecated_child_ops.to_mourn_inferior ();
+ deprecated_child_ops.to_mourn_inferior (&deprecated_child_ops);
}
/* Mark our target-struct as eligible for stray "run" and "attach" commands. */
#include "inf-child.h"
#include "gdbthread.h"
-/* HACK: Save the ptrace ops returned by inf_ptrace_target. */
-static struct target_ops *ptrace_ops_hack;
\f
#ifdef PT_GET_PROCESS_STATE
ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0);
}
-/* Start tracing PID. */
+/* Start a new inferior Unix child process. EXEC_FILE is the file to
+ run, ALLARGS is a string containing the arguments to the program.
+ ENV is the environment vector to pass. If FROM_TTY is non-zero, be
+ chatty about it. */
static void
-inf_ptrace_him (int pid)
+inf_ptrace_create_inferior (struct target_ops *ops,
+ char *exec_file, char *allargs, char **env,
+ int from_tty)
{
- push_target (ptrace_ops_hack);
+ int pid;
+
+ pid = fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL,
+ NULL, NULL);
+
+ push_target (ops);
/* On some targets, there must be some explicit synchronization
between the parent and child processes after the debugger
target_post_startup_inferior (pid_to_ptid (pid));
}
-/* Start a new inferior Unix child process. EXEC_FILE is the file to
- run, ALLARGS is a string containing the arguments to the program.
- ENV is the environment vector to pass. If FROM_TTY is non-zero, be
- chatty about it. */
-
-static void
-inf_ptrace_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
-{
- fork_inferior (exec_file, allargs, env, inf_ptrace_me, inf_ptrace_him,
- NULL, NULL);
-}
-
#ifdef PT_GET_PROCESS_STATE
static void
/* Clean up a rotting corpse of an inferior after it died. */
static void
-inf_ptrace_mourn_inferior (void)
+inf_ptrace_mourn_inferior (struct target_ops *ops)
{
int status;
only report its exit status to its original parent. */
waitpid (ptid_get_pid (inferior_ptid), &status, 0);
- unpush_target (ptrace_ops_hack);
+ unpush_target (ops);
generic_mourn_inferior ();
}
be chatty about it. */
static void
-inf_ptrace_attach (char *args, int from_tty)
+inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty)
{
char *exec_file;
pid_t pid;
target, it should decorate the ptid later with more info. */
add_thread_silent (inferior_ptid);
- push_target (ptrace_ops_hack);
+ push_target(ops);
}
#ifdef PT_GET_PROCESS_STATE
specified by ARGS. If FROM_TTY is non-zero, be chatty about it. */
static void
-inf_ptrace_detach (char *args, int from_tty)
+inf_ptrace_detach (struct target_ops *ops, char *args, int from_tty)
{
pid_t pid = ptid_get_pid (inferior_ptid);
int sig = 0;
inferior_ptid = null_ptid;
detach_inferior (pid);
- unpush_target (ptrace_ops_hack);
+ unpush_target (ops);
}
/* Kill the inferior. */
t->to_stop = inf_ptrace_stop;
t->to_xfer_partial = inf_ptrace_xfer_partial;
- ptrace_ops_hack = t;
return t;
}
\f
}
static void
-inf_ttrace_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
+inf_ttrace_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
gdb_assert (inf_ttrace_num_lwps == 0);
gdb_assert (inf_ttrace_num_lwps_in_syscall == 0);
}
static void
-inf_ttrace_mourn_inferior (void)
+inf_ttrace_mourn_inferior (struct target_ops *ops)
{
const int num_buckets = ARRAY_SIZE (inf_ttrace_page_dict.buckets);
int bucket;
}
static void
-inf_ttrace_attach (char *args, int from_tty)
+inf_ttrace_attach (struct target_ops *ops, char *args, int from_tty)
{
char *exec_file;
pid_t pid;
}
static void
-inf_ttrace_detach (char *args, int from_tty)
+inf_ttrace_detach (struct target_ops *ops, char *args, int from_tty)
{
pid_t pid = ptid_get_pid (inferior_ptid);
int sig = 0;
/* From fork-child.c */
-extern void fork_inferior (char *, char *, char **,
- void (*)(void),
- void (*)(int), void (*)(void), char *);
+extern int fork_inferior (char *, char *, char **,
+ void (*)(void),
+ void (*)(int), void (*)(void), char *);
extern void startup_inferior (int);
}
static void
-linux_nat_create_inferior (char *exec_file, char *allargs, char **env,
+linux_nat_create_inferior (struct target_ops *ops,
+ char *exec_file, char *allargs, char **env,
int from_tty)
{
int saved_async = 0;
}
#endif /* HAVE_PERSONALITY */
- linux_ops->to_create_inferior (exec_file, allargs, env, from_tty);
+ linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty);
#ifdef HAVE_PERSONALITY
if (personality_set)
}
static void
-linux_nat_attach (char *args, int from_tty)
+linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
{
struct lwp_info *lp;
int status;
/* FIXME: We should probably accept a list of process id's, and
attach all of them. */
- linux_ops->to_attach (args, from_tty);
+ linux_ops->to_attach (ops, args, from_tty);
if (!target_can_async_p ())
{
}
static void
-linux_nat_detach (char *args, int from_tty)
+linux_nat_detach (struct target_ops *ops, char *args, int from_tty)
{
int pid;
int status;
pid = GET_PID (inferior_ptid);
inferior_ptid = pid_to_ptid (pid);
- linux_ops->to_detach (args, from_tty);
+ linux_ops->to_detach (ops, args, from_tty);
if (target_can_async_p ())
drain_queued_events (pid);
}
static void
-linux_nat_mourn_inferior (void)
+linux_nat_mourn_inferior (struct target_ops *ops)
{
/* Destroy LWP info; it's no longer valid. */
init_lwp_list ();
/* Normal case, no other forks available. */
if (target_can_async_p ())
linux_nat_async (NULL, 0);
- linux_ops->to_mourn_inferior ();
+ linux_ops->to_mourn_inferior (ops);
}
else
/* Multi-fork case. The current inferior_ptid has exited, but
}
static void
-thread_db_detach (char *args, int from_tty)
+thread_db_detach (struct target_ops *ops, char *args, int from_tty)
{
disable_thread_event_reporting ();
- target_beneath->to_detach (args, from_tty);
+ target_beneath->to_detach (target_beneath, args, from_tty);
/* Should this be done by detach_command? */
target_mourn_inferior ();
}
static void
-thread_db_mourn_inferior (void)
+thread_db_mourn_inferior (struct target_ops *ops)
{
/* Forget about the child's process ID. We shouldn't need it
anymore. */
proc_handle.pid = 0;
- target_beneath->to_mourn_inferior ();
+ target_beneath->to_mourn_inferior (target_beneath);
/* Delete the old thread event breakpoints. Do this after mourning
the inferior, so that we don't try to uninsert them. */
remove_thread_event_breakpoints ();
/* Detach thread_db target ops. */
- unpush_target (&thread_db_ops);
+ unpush_target (ops);
using_thread_db = 0;
}
when you want to detach and do something else with your gdb. */
static void
-monitor_detach (char *args, int from_tty)
+monitor_detach (struct target_ops *ops, char *args, int from_tty)
{
pop_target (); /* calls monitor_close to do the real work */
if (from_tty)
/* All we actually do is set the PC to the start address of exec_bfd. */
static void
-monitor_create_inferior (char *exec_file, char *args, char **env,
- int from_tty)
+monitor_create_inferior (struct target_ops *ops, char *exec_file,
+ char *args, char **env, int from_tty)
{
if (args && (*args != '\000'))
error (_("Args are not supported by the monitor."));
instructions. */
static void
-monitor_mourn_inferior (void)
+monitor_mourn_inferior (struct target_ops *ops)
{
unpush_target (targ_ops);
generic_mourn_inferior (); /* Do all the proper things now */
/* Attach to process PID, then initialize for debugging it. */
static void
-procfs_attach (char *args, int from_tty)
+procfs_attach (struct target_ops *ops, char *args, int from_tty)
{
char *exec_file;
int pid;
on signals, etc. We'd better not have left any breakpoints
in the program or it'll die when it hits one. */
static void
-procfs_detach (char *args, int from_tty)
+procfs_detach (struct target_ops *ops, char *args, int from_tty)
{
int siggnal = 0;
int pid;
}
static void
-procfs_mourn_inferior (void)
+procfs_mourn_inferior (struct target_ops *ops)
{
if (!ptid_equal (inferior_ptid, null_ptid))
{
}
static void
-procfs_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
+procfs_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
struct inheritance inherit;
pid_t pid;
*/
static void procfs_open (char *, int);
-static void procfs_attach (char *, int);
-static void procfs_detach (char *, int);
+static void procfs_attach (struct target_ops *, char *, int);
+static void procfs_detach (struct target_ops *, char *, int);
static void procfs_resume (ptid_t, int, enum target_signal);
static int procfs_can_run (void);
static void procfs_stop (ptid_t);
static void procfs_notice_signals (ptid_t);
static void procfs_prepare_to_store (struct regcache *);
static void procfs_kill_inferior (void);
-static void procfs_mourn_inferior (void);
-static void procfs_create_inferior (char *, char *, char **, int);
+static void procfs_mourn_inferior (struct target_ops *ops);
+static void procfs_create_inferior (struct target_ops *, char *,
+ char *, char **, int);
static ptid_t procfs_wait (ptid_t, struct target_waitstatus *);
static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
struct mem_attrib *attrib,
}
static void
-procfs_attach (char *args, int from_tty)
+procfs_attach (struct target_ops *ops, char *args, int from_tty)
{
char *exec_file;
int pid;
}
static void
-procfs_detach (char *args, int from_tty)
+procfs_detach (struct target_ops *ops, char *args, int from_tty)
{
int sig = 0;
int pid = PIDGET (inferior_ptid);
*/
static void
-procfs_mourn_inferior (void)
+procfs_mourn_inferior (struct target_ops *ops)
{
procinfo *pi;
*/
static void
-procfs_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
+procfs_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
char *shell_file = getenv ("SHELL");
char *tryname;
/* This is called not only when we first attach, but also when the
user types "run" after having attached. */
static void
-m32r_create_inferior (char *execfile, char *args, char **env, int from_tty)
+m32r_create_inferior (struct target_ops *ops, char *execfile,
+ char *args, char **env, int from_tty)
{
CORE_ADDR entry_pt;
Use this when you want to detach and do something else
with your gdb. */
static void
-m32r_detach (char *args, int from_tty)
+m32r_detach (struct target_ops *ops, char *args, int from_tty)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "m32r_detach(%d)\n", from_tty);
instructions. */
static void
-m32r_mourn_inferior (void)
+m32r_mourn_inferior (struct target_ops *ops)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "m32r_mourn_inferior()\n");
static void mips_close (int quitting);
-static void mips_detach (char *args, int from_tty);
+static void mips_detach (struct target_ops *ops, char *args, int from_tty);
static void mips_resume (ptid_t ptid, int step,
enum target_signal siggnal);
/* Detach from the remote board. */
static void
-mips_detach (char *args, int from_tty)
+mips_detach (struct target_ops *ops, char *args, int from_tty)
{
if (args)
error ("Argument given to \"detach\" when remotely debugging.");
static void gdbsim_close (int quitting);
-static void gdbsim_detach (char *args, int from_tty);
+static void gdbsim_detach (struct target_ops *ops, char *args, int from_tty);
static void gdbsim_resume (ptid_t ptid, int step, enum target_signal siggnal);
Use this when you want to detach and do something else with your gdb. */
static void
-gdbsim_detach (char *args, int from_tty)
+gdbsim_detach (struct target_ops *ops, char *args, int from_tty)
{
if (remote_debug)
printf_filtered ("gdbsim_detach: args \"%s\"\n", args);
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_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);
/* Set the current architecture from the host running GDB. Called when
starting a child process. */
-static void (*super_create_inferior) (char *exec_file, char *allargs,
- char **env, int from_tty);
+static void (*super_create_inferior) (struct target_ops *,char *exec_file,
+ char *allargs, char **env, int from_tty);
static void
-rs6000_create_inferior (char *exec_file, char *allargs, char **env, int from_tty)
+rs6000_create_inferior (struct target_ops * ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
enum bfd_architecture arch;
unsigned long mach;
bfd abfd;
struct gdbarch_info info;
- super_create_inferior (exec_file, allargs, env, from_tty);
+ super_create_inferior (ops, exec_file, allargs, env, from_tty);
if (__power_rs ())
{
for the trace-trap that results from attaching. */
static void
-sol_thread_attach (char *args, int from_tty)
+sol_thread_attach (struct target_ops *ops, char *args, int from_tty)
{
sol_thread_active = 0;
- procfs_ops.to_attach (args, from_tty);
+ procfs_ops.to_attach (&procfs_ops, args, from_tty);
/* Must get symbols from shared libraries before libthread_db can run! */
solib_add (NULL, from_tty, (struct target_ops *) 0, auto_solib_add);
program was started via the normal ptrace (PTRACE_TRACEME). */
static void
-sol_thread_detach (char *args, int from_tty)
+sol_thread_detach (struct target_ops *ops, char *args, int from_tty)
{
sol_thread_active = 0;
inferior_ptid = pid_to_ptid (PIDGET (main_ph.ptid));
unpush_target (&sol_thread_ops);
- procfs_ops.to_detach (args, from_tty);
+ procfs_ops.to_detach (&procfs_ops, args, from_tty);
}
/* Resume execution of process PTID. If STEP is nozero, then just
/* Fork an inferior process, and start debugging it with /proc. */
static void
-sol_thread_create_inferior (char *exec_file, char *allargs, char **env,
- int from_tty)
+sol_thread_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **env, int from_tty)
{
sol_thread_active = 0;
- procfs_ops.to_create_inferior (exec_file, allargs, env, from_tty);
+ procfs_ops.to_create_inferior (&procfs_ops, exec_file, allargs, env, from_tty);
if (sol_thread_active && !ptid_equal (inferior_ptid, null_ptid))
{
/* Clean up after the inferior dies. */
static void
-sol_thread_mourn_inferior (void)
+sol_thread_mourn_inferior (struct target_ops *ops)
{
sol_thread_active = 0;
unpush_target (&sol_thread_ops);
- procfs_ops.to_mourn_inferior ();
+ procfs_ops.to_mourn_inferior (&procfs_ops);
}
/* Mark our target-struct as eligible for stray "run" and "attach"
}
static void
-sol_core_detach (char *args, int from_tty)
+sol_core_detach (struct target_ops *ops, char *args, int from_tty)
{
unpush_target (&core_ops);
- orig_core_ops.to_detach (args, from_tty);
+ orig_core_ops.to_detach (&orig_core_ops, args, from_tty);
}
static void
static void debug_to_close (int);
-static void debug_to_attach (char *, int);
+static void debug_to_attach (struct target_ops *ops, char *, int);
-static void debug_to_detach (char *, int);
+static void debug_to_detach (struct target_ops *ops, char *, int);
static void debug_to_resume (ptid_t, int, enum target_signal);
static int debug_to_lookup_symbol (char *, CORE_ADDR *);
-static void debug_to_mourn_inferior (void);
+static void debug_to_mourn_inferior (struct target_ops *);
static int debug_to_can_run (void);
(*current_target.to_load) (arg, from_tty);
}
+void target_create_inferior (char *exec_file, char *args,
+ char **env, int from_tty)
+{
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_create_inferior != NULL)
+ {
+ t->to_create_inferior (t, exec_file, args, env, from_tty);
+ return;
+ }
+ }
+
+ internal_error (__FILE__, __LINE__,
+ "could not find a target to create inferior");
+}
+
+
static int
nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct target_ops *t)
INHERIT (to_doc, t);
/* Do not inherit to_open. */
/* Do not inherit to_close. */
- INHERIT (to_attach, t);
+ /* Do not inherit to_attach. */
INHERIT (to_post_attach, t);
INHERIT (to_attach_no_wait, t);
- INHERIT (to_detach, t);
+ /* Do not inherit to_detach. */
/* Do not inherit to_disconnect. */
INHERIT (to_resume, t);
INHERIT (to_wait, t);
INHERIT (to_kill, t);
INHERIT (to_load, t);
INHERIT (to_lookup_symbol, t);
- INHERIT (to_create_inferior, t);
+ /* Do no inherit to_create_inferior. */
INHERIT (to_post_startup_inferior, t);
INHERIT (to_acknowledge_created_inferior, t);
INHERIT (to_insert_fork_catchpoint, t);
INHERIT (to_insert_exec_catchpoint, t);
INHERIT (to_remove_exec_catchpoint, t);
INHERIT (to_has_exited, t);
- INHERIT (to_mourn_inferior, t);
+ /* Do no inherit to_mourn_inferiour. */
INHERIT (to_can_run, t);
INHERIT (to_notice_signals, t);
INHERIT (to_thread_alive, t);
de_fault (to_post_attach,
(void (*) (int))
target_ignore);
- de_fault (to_detach,
- (void (*) (char *, int))
- target_ignore);
de_fault (to_resume,
(void (*) (ptid_t, int, enum target_signal))
noprocess);
de_fault (to_has_exited,
(int (*) (int, int, int *))
return_zero);
- de_fault (to_mourn_inferior,
- (void (*) (void))
- noprocess);
de_fault (to_can_run,
return_zero);
de_fault (to_notice_signals,
void
target_detach (char *args, int from_tty)
{
+ struct target_ops* t;
+
if (gdbarch_has_global_solist (target_gdbarch))
/* Don't remove global breakpoints here. They're removed on
disconnection from the target. */
them before detaching. */
remove_breakpoints ();
- (current_target.to_detach) (args, from_tty);
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_detach != NULL)
+ {
+ t->to_detach (t, args, from_tty);
+ return;
+ }
+ }
+
+ internal_error (__FILE__, __LINE__, "could not find a target to detach");
}
void
"could not find a target to follow fork");
}
+void
+target_mourn_inferior (void)
+{
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_mourn_inferior != NULL)
+ {
+ t->to_mourn_inferior (t);
+ return;
+ }
+ }
+
+ internal_error (__FILE__, __LINE__,
+ "could not find a target to follow mourn inferiour");
+}
+
/* Look for a target which can describe architectural features, starting
from TARGET. If we find one, return its description. */
}
void
-find_default_attach (char *args, int from_tty)
+find_default_attach (struct target_ops *ops, char *args, int from_tty)
{
struct target_ops *t;
t = find_default_run_target ("attach");
- (t->to_attach) (args, from_tty);
+ (t->to_attach) (t, args, from_tty);
return;
}
void
-find_default_create_inferior (char *exec_file, char *allargs, char **env,
+find_default_create_inferior (struct target_ops *ops,
+ char *exec_file, char *allargs, char **env,
int from_tty)
{
struct target_ops *t;
t = find_default_run_target ("run");
- (t->to_create_inferior) (exec_file, allargs, env, from_tty);
+ (t->to_create_inferior) (t, exec_file, allargs, env, from_tty);
return;
}
dummy_target.to_longname = "None";
dummy_target.to_doc = "";
dummy_target.to_attach = find_default_attach;
+ dummy_target.to_detach =
+ (void (*)(struct target_ops *, char *, int))target_ignore;
dummy_target.to_create_inferior = find_default_create_inferior;
dummy_target.to_can_async_p = find_default_can_async_p;
dummy_target.to_is_async_p = find_default_is_async_p;
targ->to_close (quitting);
}
+void
+target_attach (char *args, int from_tty)
+{
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_attach != NULL)
+ {
+ t->to_attach (t, args, from_tty);
+ return;
+ }
+ }
+
+ internal_error (__FILE__, __LINE__,
+ "could not find a target to attach");
+}
+
+
static void
-debug_to_attach (char *args, int from_tty)
+debug_to_attach (struct target_ops *ops, char *args, int from_tty)
{
- debug_target.to_attach (args, from_tty);
+ debug_target.to_attach (&debug_target, args, from_tty);
fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", args, from_tty);
}
}
static void
-debug_to_detach (char *args, int from_tty)
+debug_to_detach (struct target_ops *ops, char *args, int from_tty)
{
- debug_target.to_detach (args, from_tty);
+ debug_target.to_detach (&debug_target, args, from_tty);
fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
}
}
static void
-debug_to_create_inferior (char *exec_file, char *args, char **env,
+debug_to_create_inferior (struct target_ops *ops,
+ char *exec_file, char *args, char **env,
int from_tty)
{
- debug_target.to_create_inferior (exec_file, args, env, from_tty);
+ debug_target.to_create_inferior (ops, exec_file, args, env, from_tty);
fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx, %d)\n",
exec_file, args, from_tty);
}
static void
-debug_to_mourn_inferior (void)
+debug_to_mourn_inferior (struct target_ops *ops)
{
- debug_target.to_mourn_inferior ();
+ debug_target.to_mourn_inferior (&debug_target);
fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
}
to xfree everything (including the "struct target_ops"). */
void (*to_xclose) (struct target_ops *targ, int quitting);
void (*to_close) (int);
- void (*to_attach) (char *, int);
+ void (*to_attach) (struct target_ops *ops, char *, int);
void (*to_post_attach) (int);
- void (*to_detach) (char *, int);
+ void (*to_detach) (struct target_ops *ops, char *, int);
void (*to_disconnect) (struct target_ops *, char *, int);
void (*to_resume) (ptid_t, int, enum target_signal);
ptid_t (*to_wait) (ptid_t, struct target_waitstatus *);
void (*to_kill) (void);
void (*to_load) (char *, int);
int (*to_lookup_symbol) (char *, CORE_ADDR *);
- void (*to_create_inferior) (char *, char *, char **, int);
+ void (*to_create_inferior) (struct target_ops *,
+ char *, char *, char **, int);
void (*to_post_startup_inferior) (ptid_t);
void (*to_acknowledge_created_inferior) (int);
void (*to_insert_fork_catchpoint) (int);
void (*to_insert_exec_catchpoint) (int);
int (*to_remove_exec_catchpoint) (int);
int (*to_has_exited) (int, int, int *);
- void (*to_mourn_inferior) (void);
+ void (*to_mourn_inferior) (struct target_ops *);
int (*to_can_run) (void);
void (*to_notice_signals) (ptid_t ptid);
int (*to_thread_alive) (ptid_t ptid);
should be ready to deliver the status of the process immediately
(without waiting) to an upcoming target_wait call. */
-#define target_attach(args, from_tty) \
- (*current_target.to_attach) (args, from_tty)
+void target_attach (char *, int);
/* Some targets don't generate traps when attaching to the inferior,
or their target_attach implementation takes care of the waiting.
ENV is the environment vector to pass. Errors reported with error().
On VxWorks and various standalone systems, we ignore exec_file. */
-#define target_create_inferior(exec_file, args, env, FROM_TTY) \
- (*current_target.to_create_inferior) (exec_file, args, env, (FROM_TTY))
-
+void target_create_inferior (char *exec_file, char *args,
+ char **env, int from_tty);
/* Some targets (such as ttrace-based HPUX) don't allow us to request
notification of inferior events such as fork and vork immediately
/* The inferior process has died. Do what is right. */
-#define target_mourn_inferior() \
- (*current_target.to_mourn_inferior) ()
+void target_mourn_inferior (void);
/* Does target have enough data to do a run or attach command? */
extern void target_require_runnable (void);
-extern void find_default_attach (char *, int);
+extern void find_default_attach (struct target_ops *, char *, int);
-extern void find_default_create_inferior (char *, char *, char **, int);
+extern void find_default_create_inferior (struct target_ops *,
+ char *, char *, char **, int);
extern struct target_ops *find_run_target (void);
/* Attach to process PID, then initialize for debugging it. */
static void
-win32_attach (char *args, int from_tty)
+win32_attach (struct target_ops *ops, char *args, int from_tty)
{
BOOL ok;
DWORD pid;
}
static void
-win32_detach (char *args, int from_tty)
+win32_detach (struct target_ops *ops, char *args, int from_tty)
{
int detached = 1;
ENV is the environment vector to pass. Errors reported with error(). */
static void
-win32_create_inferior (char *exec_file, char *allargs, char **in_env,
- int from_tty)
+win32_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **in_env, int from_tty)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
}
static void
-win32_mourn_inferior (void)
+win32_mourn_inferior (struct target_ops *ops)
{
(void) win32_continue (DBG_CONTINUE, -1);
i386_cleanup_dregs();
/* Attach to process PID, then initialize for debugging it. */
static void
-win32_attach (char *args, int from_tty)
+win32_attach (struct target_ops *ops, char *args, int from_tty)
{
BOOL ok;
DWORD pid;
}
static void
-win32_detach (char *args, int from_tty)
+win32_detach (struct target_ops *ops, char *args, int from_tty)
{
int detached = 1;
ENV is the environment vector to pass. Errors reported with error(). */
static void
-win32_create_inferior (char *exec_file, char *allargs, char **in_env,
- int from_tty)
+win32_create_inferior (struct target_ops *ops, char *exec_file,
+ char *allargs, char **in_env, int from_tty)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
}
static void
-win32_mourn_inferior (void)
+win32_mourn_inferior (struct target_ops *ops)
{
(void) win32_continue (DBG_CONTINUE, -1);
i386_cleanup_dregs();