From 4088142aaeb229390c53957ab465955725d43b17 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Sat, 16 Nov 2002 19:21:44 +0000 Subject: [PATCH] * hppah-nat.c (child_can_follow_vfork_prior_to_exec): Remove. * inftarg.c (child_can_follow_vfork_prior_to_exec): Remove. (init_child_ops): Don't initialize to_can_follow_vfork_prior_to_exec. * infttrace.c (child_can_follow_vfork_prior_to_exec): Remove. * target.c (cleanup_target): Remove reference to to_can_follow_vfork_prior_to_exec. (update_current_target): Likewise. (debug_to_can_follow_vfork_prior_to_exec): Remove. (setup_target_debug): Remove reference to to_can_follow_vfork_prior_to_exec. * target.h (struct target_ops): Remove to_can_follow_vfork_prior_to_exec. (child_can_follow_vfork_prior_to_exec): Remove prototype. (target_can_follow_vfork_prior_to_exec): Remove definition. * config/pa/nm-hppah.h (CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC): Don't define. * infrun.c (follow_vfork_when_exec): Remove. (follow_inferior_fork): Remove references to follow_vfork_when_exec. (follow_exec): Likewise. (handle_inferior_event): Likewise. (keep_going): Likewise. --- gdb/ChangeLog | 24 ++++++++++++ gdb/config/pa/nm-hppah.h | 1 - gdb/hppah-nat.c | 7 ---- gdb/infrun.c | 80 ++++++---------------------------------- gdb/inftarg.c | 14 ------- gdb/infttrace.c | 15 -------- gdb/target.c | 18 --------- gdb/target.h | 15 -------- 8 files changed, 35 insertions(+), 139 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 29eb8e576bd..7ea3e797b23 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,27 @@ +2002-11-16 Daniel Jacobowitz + + * hppah-nat.c (child_can_follow_vfork_prior_to_exec): Remove. + * inftarg.c (child_can_follow_vfork_prior_to_exec): Remove. + (init_child_ops): Don't initialize to_can_follow_vfork_prior_to_exec. + * infttrace.c (child_can_follow_vfork_prior_to_exec): Remove. + * target.c (cleanup_target): Remove reference to + to_can_follow_vfork_prior_to_exec. + (update_current_target): Likewise. + (debug_to_can_follow_vfork_prior_to_exec): Remove. + (setup_target_debug): Remove reference to + to_can_follow_vfork_prior_to_exec. + * target.h (struct target_ops): Remove + to_can_follow_vfork_prior_to_exec. + (child_can_follow_vfork_prior_to_exec): Remove prototype. + (target_can_follow_vfork_prior_to_exec): Remove definition. + * config/pa/nm-hppah.h (CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC): Don't + define. + * infrun.c (follow_vfork_when_exec): Remove. + (follow_inferior_fork): Remove references to follow_vfork_when_exec. + (follow_exec): Likewise. + (handle_inferior_event): Likewise. + (keep_going): Likewise. + 2002-11-15 Andrew Cagney * frame.c (generic_unwind_get_saved_register): Make static. diff --git a/gdb/config/pa/nm-hppah.h b/gdb/config/pa/nm-hppah.h index 7609d67804a..ae0eefac4a4 100644 --- a/gdb/config/pa/nm-hppah.h +++ b/gdb/config/pa/nm-hppah.h @@ -83,7 +83,6 @@ extern int hppa_prepare_to_proceed (void); #define CHILD_REMOVE_VFORK_CATCHPOINT #define CHILD_HAS_FORKED #define CHILD_HAS_VFORKED -#define CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC #define CHILD_INSERT_EXEC_CATCHPOINT #define CHILD_REMOVE_EXEC_CATCHPOINT #define CHILD_HAS_EXECD diff --git a/gdb/hppah-nat.c b/gdb/hppah-nat.c index f10eb5a2bae..5e75d870ef3 100644 --- a/gdb/hppah-nat.c +++ b/gdb/hppah-nat.c @@ -952,13 +952,6 @@ child_has_vforked (int pid, int *childpid) #endif } -int -child_can_follow_vfork_prior_to_exec (void) -{ - /* ptrace doesn't allow this. */ - return 0; -} - int child_insert_exec_catchpoint (int pid) { diff --git a/gdb/infrun.c b/gdb/infrun.c index 88c59c58fd7..3123ca41dff 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -370,21 +370,6 @@ static struct } pending_follow; -/* Some platforms don't allow us to do anything meaningful with a - vforked child until it has exec'd. Vforked processes on such - platforms can only be followed after they've exec'd. - - When this is set to 0, a vfork can be immediately followed, - and an exec can be followed merely as an exec. When this is - set to 1, a vfork event has been seen, but cannot be followed - until the exec is seen. - - (In the latter case, inferior_ptid is still the parent of the - vfork, and pending_follow.fork_event.child_pid is the child. The - appropriate process is followed, according to the setting of - follow-fork-mode.) */ -static int follow_vfork_when_exec; - static const char follow_fork_mode_ask[] = "ask"; static const char follow_fork_mode_both[] = "both"; static const char follow_fork_mode_child[] = "child"; @@ -435,13 +420,10 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, /* Before detaching from the child, remove all breakpoints from it. (This won't actually modify the breakpoint list, but will physically remove the breakpoints from the child.) */ - if (!has_vforked || !follow_vfork_when_exec) - { - detach_breakpoints (child_pid); + detach_breakpoints (child_pid); #ifdef SOLIB_REMOVE_INFERIOR_HOOK - SOLIB_REMOVE_INFERIOR_HOOK (child_pid); + SOLIB_REMOVE_INFERIOR_HOOK (child_pid); #endif - } /* Detach from the child. */ dont_repeat (); @@ -458,15 +440,10 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, followed_child = 1; /* Before detaching from the parent, detach all breakpoints from - the child. But only if we're forking, or if we follow vforks - as soon as they happen. (If we're following vforks only when - the child has exec'd, then it's very wrong to try to write - back the "shadow contents" of inserted breakpoints now -- they - belong to the child's pre-exec'd a.out.) */ - if (!has_vforked || !follow_vfork_when_exec) - { - detach_breakpoints (child_pid); - } + the child. Note that this only works if we're following vforks + right away; if we've exec'd then the breakpoints are already detached + and the shadow contents are out of date. */ + detach_breakpoints (child_pid); /* Before detaching from the parent, remove all breakpoints from it. */ remove_breakpoints (); @@ -497,17 +474,16 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, from the breakpoint package's viewpoint, that's a switch of "threads". We must update the bp's notion of which thread it is for, or it'll be ignored when it triggers... */ - if (step_resume_breakpoint && (!has_vforked || !follow_vfork_when_exec)) + /* As above, if we're following vforks at exec time then resetting the + step resume breakpoint is probably wrong. */ + if (step_resume_breakpoint) breakpoint_re_set_thread (step_resume_breakpoint); /* Reinsert all breakpoints in the child. (The user may've set breakpoints after catching the fork, in which case those actually didn't get set in the child, but only in the parent.) */ - if (!has_vforked || !follow_vfork_when_exec) - { - breakpoint_re_set (); - insert_breakpoints (); - } + breakpoint_re_set (); + insert_breakpoints (); } /* If we're to be following both parent and child, then fork ourselves, @@ -605,23 +581,6 @@ follow_exec (int pid, char *execd_pathname) if (!may_follow_exec) return; - /* Did this exec() follow a vfork()? If so, we must follow the - vfork now too. Do it before following the exec. */ - if (follow_vfork_when_exec && - (pending_follow.kind == TARGET_WAITKIND_VFORKED)) - { - pending_follow.kind = TARGET_WAITKIND_SPURIOUS; - follow_vfork (PIDGET (inferior_ptid), - pending_follow.fork_event.child_pid); - follow_vfork_when_exec = 0; - saved_pid = PIDGET (inferior_ptid); - - /* Did we follow the parent? If so, we're done. If we followed - the child then we must also follow its exec(). */ - if (PIDGET (inferior_ptid) == pending_follow.fork_event.parent_pid) - return; - } - /* This is an exec event that we actually wish to pay attention to. Refresh our symbol table to the newly exec'd program, remove any momentary bp's, etc. @@ -1615,13 +1574,6 @@ handle_inferior_event (struct execution_control_state *ecs) target_post_startup_inferior (pid_to_ptid (pending_follow.fork_event. child_pid)); - follow_vfork_when_exec = !target_can_follow_vfork_prior_to_exec (); - if (follow_vfork_when_exec) - { - target_resume (ecs->ptid, 0, TARGET_SIGNAL_0); - prepare_to_wait (ecs); - return; - } } stop_pc = read_pc (); @@ -3114,16 +3066,6 @@ stop_stepping (struct execution_control_state *ecs) static void keep_going (struct execution_control_state *ecs) { - /* ??rehrauer: ttrace on HP-UX theoretically allows one to debug a - vforked child between its creation and subsequent exit or call to - exec(). However, I had big problems in this rather creaky exec - engine, getting that to work. The fundamental problem is that - I'm trying to debug two processes via an engine that only - understands a single process with possibly multiple threads. - - Hence, this spot is known to have problems when - target_can_follow_vfork_prior_to_exec returns 1. */ - /* Save the pc before execution, to compare with pc after stop. */ prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ prev_func_start = ecs->stop_func_start; /* Ok, since if DECR_PC_AFTER diff --git a/gdb/inftarg.c b/gdb/inftarg.c index e49681192fe..31b196b2c09 100644 --- a/gdb/inftarg.c +++ b/gdb/inftarg.c @@ -573,19 +573,6 @@ child_has_vforked (int pid, int *child_pid) #endif -#if !defined(CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC) -int -child_can_follow_vfork_prior_to_exec (void) -{ - /* This version of Unix doesn't support notification of vfork events. - However, if it did, it probably wouldn't allow vforks to be followed - before the following exec. - */ - return 0; -} -#endif - - #if !defined(CHILD_POST_FOLLOW_VFORK) void child_post_follow_vfork (int parent_pid, int followed_parent, int child_pid, @@ -789,7 +776,6 @@ init_child_ops (void) child_ops.to_remove_vfork_catchpoint = child_remove_vfork_catchpoint; child_ops.to_has_forked = child_has_forked; child_ops.to_has_vforked = child_has_vforked; - child_ops.to_can_follow_vfork_prior_to_exec = child_can_follow_vfork_prior_to_exec; child_ops.to_post_follow_vfork = child_post_follow_vfork; child_ops.to_insert_exec_catchpoint = child_insert_exec_catchpoint; child_ops.to_remove_exec_catchpoint = child_remove_exec_catchpoint; diff --git a/gdb/infttrace.c b/gdb/infttrace.c index a1a789c59a1..98c70b9c6b5 100644 --- a/gdb/infttrace.c +++ b/gdb/infttrace.c @@ -3449,21 +3449,6 @@ child_has_vforked (int tid, int *childpid) #endif -#if defined(CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC) -int -child_can_follow_vfork_prior_to_exec (void) -{ - /* ttrace does allow this. - - ??rehrauer: However, I had major-league problems trying to - convince wait_for_inferior to handle that case. Perhaps when - it is rewritten to grok multiple processes in an explicit way... - */ - return 0; -} -#endif - - #if defined(CHILD_INSERT_EXEC_CATCHPOINT) int child_insert_exec_catchpoint (int tid) diff --git a/gdb/target.c b/gdb/target.c index 51ace7413e6..b9ad14b758f 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -492,9 +492,6 @@ cleanup_target (struct target_ops *t) de_fault (to_has_vforked, (int (*) (int, int *)) return_zero); - de_fault (to_can_follow_vfork_prior_to_exec, - (int (*) (void)) - return_zero); de_fault (to_post_follow_vfork, (void (*) (int, int, int, int)) target_ignore); @@ -629,7 +626,6 @@ update_current_target (void) INHERIT (to_remove_vfork_catchpoint, t); INHERIT (to_has_forked, t); INHERIT (to_has_vforked, t); - INHERIT (to_can_follow_vfork_prior_to_exec, t); INHERIT (to_post_follow_vfork, t); INHERIT (to_insert_exec_catchpoint, t); INHERIT (to_remove_exec_catchpoint, t); @@ -2154,19 +2150,6 @@ debug_to_has_vforked (int pid, int *child_pid) return has_vforked; } -static int -debug_to_can_follow_vfork_prior_to_exec (void) -{ - int can_immediately_follow_vfork; - - can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec (); - - fprintf_unfiltered (gdb_stdlog, "target_can_follow_vfork_prior_to_exec () = %d\n", - can_immediately_follow_vfork); - - return can_immediately_follow_vfork; -} - static void debug_to_post_follow_vfork (int parent_pid, int followed_parent, int child_pid, int followed_child) @@ -2436,7 +2419,6 @@ setup_target_debug (void) current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint; current_target.to_has_forked = debug_to_has_forked; current_target.to_has_vforked = debug_to_has_vforked; - current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec; current_target.to_post_follow_vfork = debug_to_post_follow_vfork; current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint; current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint; diff --git a/gdb/target.h b/gdb/target.h index 5cdb76f387d..c804a9fbbf1 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -280,7 +280,6 @@ struct target_ops int (*to_remove_vfork_catchpoint) (int); int (*to_has_forked) (int, int *); int (*to_has_vforked) (int, int *); - int (*to_can_follow_vfork_prior_to_exec) (void); void (*to_post_follow_vfork) (int, int, int, int); int (*to_insert_exec_catchpoint) (int); int (*to_remove_exec_catchpoint) (int); @@ -563,8 +562,6 @@ extern int child_has_vforked (int, int *); extern void child_acknowledge_created_inferior (int); -extern int child_can_follow_vfork_prior_to_exec (void); - extern void child_post_follow_vfork (int, int, int, int); extern int child_insert_exec_catchpoint (int); @@ -759,18 +756,6 @@ extern void target_load (char *arg, int from_tty); #define target_has_vforked(pid,child_pid) \ (*current_target.to_has_vforked) (pid,child_pid) -/* Some platforms (such as pre-10.20 HP-UX) don't allow us to do - anything to a vforked child before it subsequently calls exec(). - On such platforms, we say that the debugger cannot "follow" the - child until it has vforked. - - This function should be defined to return 1 by those targets - which can allow the debugger to immediately follow a vforked - child, and 0 if they cannot. */ - -#define target_can_follow_vfork_prior_to_exec() \ - (*current_target.to_can_follow_vfork_prior_to_exec) () - /* An inferior process has been created via a vfork() system call. The debugger has followed the parent, the child, or both. The process of setting up for that follow may have required some