convert to_follow_fork
authorTom Tromey <tromey@redhat.com>
Wed, 18 Dec 2013 21:38:04 +0000 (14:38 -0700)
committerTom Tromey <tromey@redhat.com>
Wed, 19 Feb 2014 14:48:11 +0000 (07:48 -0700)
2014-02-19  Tom Tromey  <tromey@redhat.com>

* target-delegates.c: Rebuild.
* target.c (default_follow_fork): New function.
(target_follow_fork): Unconditionally delegate.
* target.h (struct target_ops) <to_follow_fork>: Use
TARGET_DEFAULT_FUNC.

gdb/ChangeLog
gdb/target-delegates.c
gdb/target.c
gdb/target.h

index 2dceb4c..2e28138 100644 (file)
@@ -1,6 +1,14 @@
 2014-02-19  Tom Tromey  <tromey@redhat.com>
 
        * target-delegates.c: Rebuild.
+       * target.c (default_follow_fork): New function.
+       (target_follow_fork): Unconditionally delegate.
+       * target.h (struct target_ops) <to_follow_fork>: Use
+       TARGET_DEFAULT_FUNC.
+
+2014-02-19  Tom Tromey  <tromey@redhat.com>
+
+       * target-delegates.c: Rebuild.
        * target.c (target_kill): Unconditionally delegate.
        * target.h (struct target_ops) <to_kill>: Use
        TARGET_DEFAULT_NORETURN.
index 3c6b312..ebecbeb 100644 (file)
@@ -452,6 +452,13 @@ tdefault_remove_vfork_catchpoint (struct target_ops *self, int arg1)
 }
 
 static int
+delegate_follow_fork (struct target_ops *self, int arg1, int arg2)
+{
+  self = self->beneath;
+  return self->to_follow_fork (self, arg1, arg2);
+}
+
+static int
 delegate_insert_exec_catchpoint (struct target_ops *self, int arg1)
 {
   self = self->beneath;
@@ -1230,6 +1237,8 @@ install_delegators (struct target_ops *ops)
     ops->to_insert_vfork_catchpoint = delegate_insert_vfork_catchpoint;
   if (ops->to_remove_vfork_catchpoint == NULL)
     ops->to_remove_vfork_catchpoint = delegate_remove_vfork_catchpoint;
+  if (ops->to_follow_fork == NULL)
+    ops->to_follow_fork = delegate_follow_fork;
   if (ops->to_insert_exec_catchpoint == NULL)
     ops->to_insert_exec_catchpoint = delegate_insert_exec_catchpoint;
   if (ops->to_remove_exec_catchpoint == NULL)
@@ -1389,6 +1398,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_remove_fork_catchpoint = tdefault_remove_fork_catchpoint;
   ops->to_insert_vfork_catchpoint = tdefault_insert_vfork_catchpoint;
   ops->to_remove_vfork_catchpoint = tdefault_remove_vfork_catchpoint;
+  ops->to_follow_fork = default_follow_fork;
   ops->to_insert_exec_catchpoint = tdefault_insert_exec_catchpoint;
   ops->to_remove_exec_catchpoint = tdefault_remove_exec_catchpoint;
   ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint;
index 3d27eda..9afb317 100644 (file)
@@ -60,6 +60,9 @@ static void default_rcmd (struct target_ops *, char *, struct ui_file *);
 static ptid_t default_get_ada_task_ptid (struct target_ops *self,
                                         long lwp, long tid);
 
+static int default_follow_fork (struct target_ops *self, int follow_child,
+                               int detach_fork);
+
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
@@ -2632,31 +2635,29 @@ target_program_signals (int numsigs, unsigned char *program_signals)
     }
 }
 
+static int
+default_follow_fork (struct target_ops *self, int follow_child,
+                    int detach_fork)
+{
+  /* 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
    follow forks.  */
 
 int
 target_follow_fork (int follow_child, int detach_fork)
 {
-  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, detach_fork);
-
-         if (targetdebug)
-           fprintf_unfiltered (gdb_stdlog,
-                               "target_follow_fork (%d, %d) = %d\n",
-                               follow_child, detach_fork, retval);
-         return retval;
-       }
-    }
+  int retval = current_target.to_follow_fork (&current_target,
+                                             follow_child, detach_fork);
 
-  /* 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"));
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog,
+                       "target_follow_fork (%d, %d) = %d\n",
+                       follow_child, detach_fork, retval);
+  return retval;
 }
 
 void
index 5b6ada7..a35f7e6 100644 (file)
@@ -533,7 +533,8 @@ struct target_ops
       TARGET_DEFAULT_RETURN (1);
     int (*to_remove_vfork_catchpoint) (struct target_ops *, int)
       TARGET_DEFAULT_RETURN (1);
-    int (*to_follow_fork) (struct target_ops *, int, int);
+    int (*to_follow_fork) (struct target_ops *, int, int)
+      TARGET_DEFAULT_FUNC (default_follow_fork);
     int (*to_insert_exec_catchpoint) (struct target_ops *, int)
       TARGET_DEFAULT_RETURN (1);
     int (*to_remove_exec_catchpoint) (struct target_ops *, int)