* inf-child.c (inf_child_follow_fork): Add OPS argument.
authorDaniel Jacobowitz <drow@false.org>
Sun, 4 Sep 2005 16:18:20 +0000 (16:18 +0000)
committerDaniel Jacobowitz <drow@false.org>
Sun, 4 Sep 2005 16:18:20 +0000 (16:18 +0000)
* inf-ptrace.c (inf_ptrace_follow_fork): Likewise.
* inf-ttrace.c (inf_ttrace_follow_fork): Likewise.
* inftarg.c (child_follow_fork): Likewise.
* linux-nat.c (child_follow_fork): Likewise.  Use ops instead of
&deprecated_child_ops.
* target.c (update_current_target): Do not inherit to_follow_fork.
(target_follow_fork): New function.
(debug_to_follow_fork): Remove.
(setup_target_debug): Don't set to_follow_fork.
* target.h (struct target_ops): Add struct target_ops * to
to_follow_fork.
(child_follow_fork): Add struct target_ops * argument.
(target_follow_fork): Replace macro with prototype.

gdb/ChangeLog
gdb/inf-child.c
gdb/inf-ptrace.c
gdb/inf-ttrace.c
gdb/inftarg.c
gdb/linux-nat.c
gdb/target.c
gdb/target.h

index c791019c21d9675c9cfe2912fdd2674aef1f3c34..764d8a9ec5d4c40b4ab91936f0c40e6eb016bece 100644 (file)
@@ -1,3 +1,20 @@
+2005-09-04  Daniel Jacobowitz  <dan@debian.org>
+
+       * inf-child.c (inf_child_follow_fork): Add OPS argument.
+       * inf-ptrace.c (inf_ptrace_follow_fork): Likewise.
+       * inf-ttrace.c (inf_ttrace_follow_fork): Likewise.
+       * inftarg.c (child_follow_fork): Likewise.
+       * linux-nat.c (child_follow_fork): Likewise.  Use ops instead of
+       &deprecated_child_ops.
+       * target.c (update_current_target): Do not inherit to_follow_fork.
+       (target_follow_fork): New function.
+       (debug_to_follow_fork): Remove.
+       (setup_target_debug): Don't set to_follow_fork.
+       * target.h (struct target_ops): Add struct target_ops * to
+       to_follow_fork.
+       (child_follow_fork): Add struct target_ops * argument.
+       (target_follow_fork): Replace macro with prototype.
+
 2005-09-02  Kevin Buettner  <kevinb@redhat.com>
 
        * mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Use ARRAY_SIZE.
index 31bdd29176cb4c2d65fc30e335ee4781e0a555b0..96330097e5231395123f2aafc883e5195e4f0cd7 100644 (file)
@@ -2,7 +2,7 @@
    Unix.
 
    Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+   1998, 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -121,7 +121,7 @@ inf_child_remove_vfork_catchpoint (int pid)
 }
 
 static int
-inf_child_follow_fork (int follow_child)
+inf_child_follow_fork (struct target_ops *ops, int follow_child)
 {
   /* This version of Unix doesn't support following fork or vfork
      events.  */
index 78892aa393196ce61344f82fe7304375cf53143c..07ebb9d41205dc93ed5441e0d02338e6704beafc 100644 (file)
@@ -44,7 +44,7 @@ static struct target_ops *ptrace_ops_hack;
 #ifdef PT_GET_PROCESS_STATE
 
 static int
-inf_ptrace_follow_fork (int follow_child)
+inf_ptrace_follow_fork (struct target_ops *ops, int follow_child)
 {
   pid_t pid, fpid;
   ptrace_state_t pe;
index 41393550573e638238ccca1b635bb44773508a35..a9087afa5788b5acc442f190d30b4d27009b9105 100644 (file)
@@ -404,7 +404,7 @@ inf_ttrace_stopped_by_watchpoint (void)
 static pid_t inf_ttrace_vfork_ppid = -1;
 
 static int
-inf_ttrace_follow_fork (int follow_child)
+inf_ttrace_follow_fork (struct target_ops *ops, int follow_child)
 {
   pid_t pid, fpid;
   lwpid_t lwpid, flwpid;
index 279f3a7da0bc482de01ec4f2d46327ea19ea46c3..5d7750d65bd152ac4f5853d38ddf96b45eecea85 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-vector operations for controlling Unix child processes, for GDB.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
-   2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+   2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -401,7 +401,7 @@ child_remove_vfork_catchpoint (int pid)
 
 #if !defined(CHILD_FOLLOW_FORK)
 int
-child_follow_fork (int follow_child)
+child_follow_fork (struct target_ops *ops, int follow_child)
 {
   /* This version of Unix doesn't support following fork or vfork events.  */
   return 0;
index 3c2821935ef1de2dd87b254c142bac683ca57165..582bcfb89515e0bd1edbcb740855a8925e49b120 100644 (file)
@@ -334,7 +334,7 @@ child_post_startup_inferior (ptid_t ptid)
 #endif
 
 int
-child_follow_fork (int follow_child)
+child_follow_fork (struct target_ops *ops, int follow_child)
 {
   ptid_t last_ptid;
   struct target_waitstatus last_status;
@@ -466,7 +466,10 @@ child_follow_fork (int follow_child)
        target_detach (NULL, 0);
 
       inferior_ptid = pid_to_ptid (child_pid);
-      push_target (&deprecated_child_ops);
+
+      /* Reinstall ourselves, since we might have been removed in
+        target_detach (which does other necessary cleanup).  */
+      push_target (ops);
 
       /* Reset breakpoints in the child as appropriate.  */
       follow_inferior_reset_breakpoints ();
index 83501e609619d8408705ced086ce3880ec5d75f1..d842f5066bb67d5dfea1f0e0ecc10c5d05c64956 100644 (file)
@@ -422,7 +422,7 @@ update_current_target (void)
       INHERIT (to_remove_fork_catchpoint, t);
       INHERIT (to_insert_vfork_catchpoint, t);
       INHERIT (to_remove_vfork_catchpoint, t);
-      INHERIT (to_follow_fork, t);
+      /* Do not inherit to_follow_fork.  */
       INHERIT (to_insert_exec_catchpoint, t);
       INHERIT (to_remove_exec_catchpoint, t);
       INHERIT (to_reported_exec_events_per_exec_call, t);
@@ -579,9 +579,6 @@ update_current_target (void)
   de_fault (to_remove_vfork_catchpoint, 
            (int (*) (int)) 
            tcomplain);
-  de_fault (to_follow_fork,
-           (int (*) (int)) 
-           target_ignore);
   de_fault (to_insert_exec_catchpoint, 
            (void (*) (int)) 
            tcomplain);
@@ -1500,6 +1497,31 @@ target_async_mask (int mask)
   return saved_async_masked_status;
 }
 
+/* Look through the list of possible targets for a target that can
+   follow forks.  */
+
+int
+target_follow_fork (int follow_child)
+{
+  struct target_ops *t;
+
+  for (t = current_target.beneath; t != NULL; t = t->beneath)
+    {
+      if (t->to_follow_fork != NULL)
+       {
+         int retval = t->to_follow_fork (t, follow_child);
+         if (targetdebug)
+           fprintf_unfiltered (gdb_stdlog, "target_follow_fork (%d) = %d\n",
+                               follow_child, retval);
+         return retval;
+       }
+    }
+
+  /* Some target returned a fork event, but did not know how to follow it.  */
+  internal_error (__FILE__, __LINE__,
+                 "could not find a target to follow fork");
+}
+
 /* Look through the list of possible targets for a target that can
    execute a run or attach command without any other data.  This is
    used to locate the default process stratum.
@@ -2336,17 +2358,6 @@ debug_to_remove_vfork_catchpoint (int pid)
   return retval;
 }
 
-static int
-debug_to_follow_fork (int follow_child)
-{
-  int retval =  debug_target.to_follow_fork (follow_child);
-
-  fprintf_unfiltered (gdb_stdlog, "target_follow_fork (%d) = %d\n",
-                     follow_child, retval);
-
-  return retval;
-}
-
 static void
 debug_to_insert_exec_catchpoint (int pid)
 {
@@ -2539,7 +2550,6 @@ setup_target_debug (void)
   current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
   current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
   current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
-  current_target.to_follow_fork = debug_to_follow_fork;
   current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
   current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
   current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
index 582fa789a675104936762a86b44ccac745bf9c87..f1de230c4632c1b606600a7b711b32febdebc58f 100644 (file)
@@ -1,7 +1,7 @@
 /* Interface between GDB and target environments, including files and processes
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.  Written by John Gilmore.
 
@@ -362,7 +362,7 @@ struct target_ops
     int (*to_remove_fork_catchpoint) (int);
     void (*to_insert_vfork_catchpoint) (int);
     int (*to_remove_vfork_catchpoint) (int);
-    int (*to_follow_fork) (int);
+    int (*to_follow_fork) (struct target_ops *, int);
     void (*to_insert_exec_catchpoint) (int);
     int (*to_remove_exec_catchpoint) (int);
     int (*to_reported_exec_events_per_exec_call) (void);
@@ -582,7 +582,7 @@ extern int child_remove_vfork_catchpoint (int);
 
 extern void child_acknowledge_created_inferior (int);
 
-extern int child_follow_fork (int);
+extern int child_follow_fork (struct target_ops *, int);
 
 extern void child_insert_exec_catchpoint (int);
 
@@ -747,8 +747,7 @@ extern void target_load (char *arg, int from_tty);
    This function returns 1 if the inferior should not be resumed
    (i.e. there is another event pending).  */
 
-#define target_follow_fork(follow_child) \
-     (*current_target.to_follow_fork) (follow_child)
+int target_follow_fork (int follow_child);
 
 /* On some targets, we can catch an inferior exec event when it
    occurs.  These functions insert/remove an already-created
This page took 0.035728 seconds and 4 git commands to generate.