diff options
author | Vladimir Prus <vladimir@codesourcery.com> | 2008-11-09 11:27:18 +0000 |
---|---|---|
committer | Vladimir Prus <vladimir@codesourcery.com> | 2008-11-09 11:27:18 +0000 |
commit | 136d6dae62acd18254ced95f2ae6e6423bcda3c9 (patch) | |
tree | e615203f169c8eed4229e70fdd3b22a231778aee /gdb | |
parent | ed406532765b59fbd78f011179f7174611412e12 (diff) | |
download | gdb-136d6dae62acd18254ced95f2ae6e6423bcda3c9.zip gdb-136d6dae62acd18254ced95f2ae6e6423bcda3c9.tar.gz gdb-136d6dae62acd18254ced95f2ae6e6423bcda3c9.tar.bz2 |
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 63 | ||||
-rw-r--r-- | gdb/aix-thread.c | 12 | ||||
-rw-r--r-- | gdb/bsd-uthread.c | 5 | ||||
-rw-r--r-- | gdb/corefile.c | 2 | ||||
-rw-r--r-- | gdb/corelow.c | 6 | ||||
-rw-r--r-- | gdb/dec-thread.c | 4 | ||||
-rw-r--r-- | gdb/fork-child.c | 6 | ||||
-rw-r--r-- | gdb/gnu-nat.c | 9 | ||||
-rw-r--r-- | gdb/go32-nat.c | 11 | ||||
-rw-r--r-- | gdb/hpux-thread.c | 17 | ||||
-rw-r--r-- | gdb/inf-ptrace.c | 44 | ||||
-rw-r--r-- | gdb/inf-ttrace.c | 10 | ||||
-rw-r--r-- | gdb/inferior.h | 6 | ||||
-rw-r--r-- | gdb/linux-nat.c | 17 | ||||
-rw-r--r-- | gdb/linux-thread-db.c | 10 | ||||
-rw-r--r-- | gdb/monitor.c | 8 | ||||
-rw-r--r-- | gdb/nto-procfs.c | 10 | ||||
-rw-r--r-- | gdb/procfs.c | 19 | ||||
-rw-r--r-- | gdb/remote-m32r-sdi.c | 7 | ||||
-rw-r--r-- | gdb/remote-mips.c | 4 | ||||
-rw-r--r-- | gdb/remote-sim.c | 4 | ||||
-rw-r--r-- | gdb/remote.c | 25 | ||||
-rw-r--r-- | gdb/rs6000-nat.c | 9 | ||||
-rw-r--r-- | gdb/sol-thread.c | 22 | ||||
-rw-r--r-- | gdb/target.c | 114 | ||||
-rw-r--r-- | gdb/target.h | 25 | ||||
-rw-r--r-- | gdb/win32-nat.c | 10 | ||||
-rw-r--r-- | gdb/windows-nat.c | 10 |
28 files changed, 309 insertions, 180 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 42a007f8..704c293 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,68 @@ 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. diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 3377d50..5514094 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -938,19 +938,19 @@ new_objfile (struct objfile *objfile) /* 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 @@ -1667,10 +1667,10 @@ aix_thread_kill (void) /* 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. */ diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 59853ce..f38c825 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -270,9 +270,10 @@ bsd_uthread_solib_unloaded (struct so_list *so) } 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 (); } diff --git a/gdb/corefile.c b/gdb/corefile.c index 2be4e26..af2d1a3 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -74,7 +74,7 @@ core_file_command (char *filename, int from_tty) 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); } diff --git a/gdb/corelow.c b/gdb/corelow.c index 14868e2..35c998c 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -75,7 +75,7 @@ static int gdb_check_format (bfd *); 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); @@ -413,11 +413,11 @@ core_open (char *filename, int from_tty) } 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")); diff --git a/gdb/dec-thread.c b/gdb/dec-thread.c index 7f26166..3de06ed 100644 --- a/gdb/dec-thread.c +++ b/gdb/dec-thread.c @@ -429,7 +429,7 @@ dec_thread_detach (char *args, int from_tty) 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. */ @@ -605,7 +605,7 @@ dec_thread_mourn_inferior (void) 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. */ diff --git a/gdb/fork-child.c b/gdb/fork-child.c index ec6d8cf..75b9d4e 100644 --- a/gdb/fork-child.c +++ b/gdb/fork-child.c @@ -118,7 +118,7 @@ escape_bang_in_quoted_argument (const char *shell_file) /* 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) @@ -408,11 +408,13 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env, /* 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. */ diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 0ebdfe8..56a8b1f 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2042,7 +2042,7 @@ gnu_kill_inferior (void) /* 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); @@ -2074,7 +2074,8 @@ cur_inf (void) } 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 (); @@ -2139,7 +2140,7 @@ gnu_can_run (void) /* 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; @@ -2205,7 +2206,7 @@ gnu_attach (char *args, int from_tty) 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; diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index d978303..a7ab137 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -184,8 +184,9 @@ static int go32_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, 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; @@ -306,7 +307,7 @@ go32_close (int quitting) } 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\ @@ -314,7 +315,7 @@ Use the `run' command to run DJGPP programs.")); } static void -go32_detach (char *args, int from_tty) +go32_detach (struct target_ops *ops, char *args, int from_tty) { } @@ -674,7 +675,7 @@ go32_create_inferior (char *exec_file, char *args, char **env, 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 diff --git a/gdb/hpux-thread.c b/gdb/hpux-thread.c index cd69e19..8d2e65b 100644 --- a/gdb/hpux-thread.c +++ b/gdb/hpux-thread.c @@ -144,9 +144,9 @@ hpux_thread_open (char *arg, int from_tty) 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. */ } @@ -160,9 +160,9 @@ hpux_thread_attach (char *args, int from_tty) 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 @@ -431,10 +431,11 @@ hpux_thread_notice_signals (ptid_t ptid) /* 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) { @@ -487,7 +488,7 @@ hpux_thread_new_objfile (struct objfile *objfile) 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. */ diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 57af79a..bf3d0a8 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -35,8 +35,6 @@ #include "inf-child.h" #include "gdbthread.h" -/* HACK: Save the ptrace ops returned by inf_ptrace_target. */ -static struct target_ops *ptrace_ops_hack; #ifdef PT_GET_PROCESS_STATE @@ -132,12 +130,22 @@ inf_ptrace_me (void) 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 @@ -156,19 +164,6 @@ inf_ptrace_him (int pid) 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 @@ -189,7 +184,7 @@ inf_ptrace_post_startup_inferior (ptid_t pid) /* 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; @@ -199,7 +194,7 @@ inf_ptrace_mourn_inferior (void) 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 (); } @@ -207,7 +202,7 @@ inf_ptrace_mourn_inferior (void) 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; @@ -258,7 +253,7 @@ inf_ptrace_attach (char *args, int from_tty) 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 @@ -282,7 +277,7 @@ inf_ptrace_post_attach (int pid) 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; @@ -314,7 +309,7 @@ inf_ptrace_detach (char *args, int from_tty) inferior_ptid = null_ptid; detach_inferior (pid); - unpush_target (ptrace_ops_hack); + unpush_target (ops); } /* Kill the inferior. */ @@ -644,7 +639,6 @@ inf_ptrace_target (void) t->to_stop = inf_ptrace_stop; t->to_xfer_partial = inf_ptrace_xfer_partial; - ptrace_ops_hack = t; return t; } diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c index 643cfa2..e8b2971 100644 --- a/gdb/inf-ttrace.c +++ b/gdb/inf-ttrace.c @@ -662,8 +662,8 @@ inf_ttrace_him (int pid) } 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); @@ -676,7 +676,7 @@ inf_ttrace_create_inferior (char *exec_file, char *allargs, char **env, } 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; @@ -704,7 +704,7 @@ inf_ttrace_mourn_inferior (void) } 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; @@ -769,7 +769,7 @@ inf_ttrace_attach (char *args, int from_tty) } 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; diff --git a/gdb/inferior.h b/gdb/inferior.h index 029dc31..1be6cc5 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -197,9 +197,9 @@ extern ptid_t procfs_first_available (void); /* 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); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 56ec9cb..913bfec 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1317,7 +1317,8 @@ lin_lwp_attach_lwp (ptid_t ptid) } 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; @@ -1364,7 +1365,7 @@ linux_nat_create_inferior (char *exec_file, char *allargs, char **env, } #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) @@ -1382,7 +1383,7 @@ linux_nat_create_inferior (char *exec_file, char *allargs, char **env, } 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; @@ -1390,7 +1391,7 @@ linux_nat_attach (char *args, int from_tty) /* 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 ()) { @@ -1571,7 +1572,7 @@ detach_callback (struct lwp_info *lp, void *data) } 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; @@ -1612,7 +1613,7 @@ linux_nat_detach (char *args, int from_tty) 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); @@ -3176,7 +3177,7 @@ linux_nat_kill (void) } 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 (); @@ -3186,7 +3187,7 @@ linux_nat_mourn_inferior (void) /* 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 diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index fc85be5..5f98e99 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -780,11 +780,11 @@ detach_thread (ptid_t ptid) } 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 (); @@ -927,20 +927,20 @@ thread_db_wait (ptid_t ptid, struct target_waitstatus *ourstatus) } 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; } diff --git a/gdb/monitor.c b/gdb/monitor.c index c5b0ec6..6b5f820 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -853,7 +853,7 @@ monitor_close (int quitting) 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) @@ -1995,8 +1995,8 @@ monitor_kill (void) /* 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.")); @@ -2012,7 +2012,7 @@ monitor_create_inferior (char *exec_file, char *args, char **env, 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 */ diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index f69aaf2..9bcd2f8 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -518,7 +518,7 @@ procfs_can_run (void) /* 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; @@ -781,7 +781,7 @@ procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite, 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; @@ -914,7 +914,7 @@ procfs_resume (ptid_t ptid, int step, enum target_signal signo) } static void -procfs_mourn_inferior (void) +procfs_mourn_inferior (struct target_ops *ops) { if (!ptid_equal (inferior_ptid, null_ptid)) { @@ -988,8 +988,8 @@ breakup_args (char *scratch, char **argv) } 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; diff --git a/gdb/procfs.c b/gdb/procfs.c index 248dd3a..f1f4d96 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -112,8 +112,8 @@ */ 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); @@ -123,8 +123,9 @@ static void procfs_store_registers (struct regcache *, int); 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, @@ -3602,7 +3603,7 @@ procfs_debug_inferior (procinfo *pi) } 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; @@ -3632,7 +3633,7 @@ procfs_attach (char *args, int from_tty) } 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); @@ -4842,7 +4843,7 @@ procfs_kill_inferior (void) */ static void -procfs_mourn_inferior (void) +procfs_mourn_inferior (struct target_ops *ops) { procinfo *pi; @@ -5111,8 +5112,8 @@ procfs_set_exec_trap (void) */ 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; diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index 5ac6e38..302e063 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -316,7 +316,8 @@ check_mmu_status (void) /* 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; @@ -872,7 +873,7 @@ m32r_wait (ptid_t ptid, struct target_waitstatus *status) 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); @@ -1147,7 +1148,7 @@ m32r_kill (void) 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"); diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index a996124..b4423d5 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -84,7 +84,7 @@ static void lsi_open (char *name, int from_tty); 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); @@ -1652,7 +1652,7 @@ mips_close (int quitting) /* 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."); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index be89db9..62f9cb1 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -84,7 +84,7 @@ static void gdbsim_open (char *args, int from_tty); 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); @@ -604,7 +604,7 @@ gdbsim_close (int quitting) 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); diff --git a/gdb/remote.c b/gdb/remote.c index b36a4b4..5cb36b8 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -105,11 +105,11 @@ static void remote_close (int quitting); 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 *); @@ -133,7 +133,7 @@ static void remote_async (void (*callback) (enum inferior_event_type event_type, 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); @@ -3306,13 +3306,13 @@ remote_detach_1 (char *args, int from_tty, int extended) } 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); } @@ -3435,9 +3435,9 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty) } 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. */ @@ -6452,9 +6452,9 @@ extended_remote_kill (void) } 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. */ @@ -6537,9 +6537,9 @@ extended_remote_mourn_1 (struct target_ops *target) } 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 @@ -6655,7 +6655,8 @@ extended_remote_create_inferior_1 (char *exec_file, char *args, } 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); diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 27632d3..6501def 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -966,17 +966,18 @@ vmap_exec (void) /* 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 ()) { diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 8f99ac1..103a697 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -348,10 +348,10 @@ sol_thread_open (char *arg, int from_tty) 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); @@ -379,12 +379,12 @@ sol_thread_attach (char *args, int from_tty) 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 @@ -753,11 +753,11 @@ sol_thread_notice_signals (ptid_t ptid) /* 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)) { @@ -822,11 +822,11 @@ sol_thread_new_objfile (struct objfile *objfile) /* 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" @@ -1411,10 +1411,10 @@ sol_core_close (int quitting) } 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 diff --git a/gdb/target.c b/gdb/target.c index fa9a941..3901ee7 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -99,9 +99,9 @@ static void debug_to_open (char *, int); 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); @@ -156,7 +156,7 @@ static void debug_to_load (char *, int); 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); @@ -281,6 +281,24 @@ target_load (char *arg, int from_tty) (*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) @@ -394,10 +412,10 @@ update_current_target (void) 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); @@ -428,7 +446,7 @@ update_current_target (void) 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); @@ -439,7 +457,7 @@ update_current_target (void) 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); @@ -496,9 +514,6 @@ update_current_target (void) 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); @@ -602,9 +617,6 @@ update_current_target (void) 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, @@ -1797,6 +1809,8 @@ target_preopen (int from_tty) 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. */ @@ -1806,7 +1820,16 @@ target_detach (char *args, int from_tty) 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 @@ -1865,6 +1888,23 @@ target_follow_fork (int follow_child) "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. */ @@ -2110,23 +2150,24 @@ find_default_run_target (char *do_mesg) } 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; } @@ -2454,6 +2495,8 @@ init_dummy_target (void) 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; @@ -2490,10 +2533,28 @@ target_close (struct target_ops *targ, int quitting) 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); } @@ -2508,9 +2569,9 @@ debug_to_post_attach (int pid) } 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); } @@ -2913,10 +2974,11 @@ debug_to_lookup_symbol (char *name, CORE_ADDR *addrp) } 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); @@ -3020,9 +3082,9 @@ debug_to_has_exited (int pid, int wait_status, int *exit_status) } 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"); } diff --git a/gdb/target.h b/gdb/target.h index a010d2d..05b681d 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -327,9 +327,9 @@ struct target_ops 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 *); @@ -387,7 +387,8 @@ struct target_ops 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); @@ -398,7 +399,7 @@ struct target_ops 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); @@ -580,8 +581,7 @@ void target_close (struct target_ops *targ, int quitting); 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. @@ -831,9 +831,8 @@ extern void target_load (char *arg, int from_tty); 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 @@ -903,8 +902,7 @@ int target_follow_fork (int follow_child); /* 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? */ @@ -1269,9 +1267,10 @@ extern void noprocess (void); 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); diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index cd4d533..5350be6 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -1684,7 +1684,7 @@ out: /* 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; @@ -1740,7 +1740,7 @@ win32_attach (char *args, int from_tty) } static void -win32_detach (char *args, int from_tty) +win32_detach (struct target_ops *ops, char *args, int from_tty) { int detached = 1; @@ -1823,8 +1823,8 @@ win32_open (char *arg, int from_tty) 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; @@ -1951,7 +1951,7 @@ win32_create_inferior (char *exec_file, char *allargs, char **in_env, } static void -win32_mourn_inferior (void) +win32_mourn_inferior (struct target_ops *ops) { (void) win32_continue (DBG_CONTINUE, -1); i386_cleanup_dregs(); diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index cd4d533..5350be6 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1684,7 +1684,7 @@ out: /* 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; @@ -1740,7 +1740,7 @@ win32_attach (char *args, int from_tty) } static void -win32_detach (char *args, int from_tty) +win32_detach (struct target_ops *ops, char *args, int from_tty) { int detached = 1; @@ -1823,8 +1823,8 @@ win32_open (char *arg, int from_tty) 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; @@ -1951,7 +1951,7 @@ win32_create_inferior (char *exec_file, char *allargs, char **in_env, } static void -win32_mourn_inferior (void) +win32_mourn_inferior (struct target_ops *ops) { (void) win32_continue (DBG_CONTINUE, -1); i386_cleanup_dregs(); |