convert to_detach
authorTom Tromey <tromey@redhat.com>
Fri, 13 Dec 2013 20:33:08 +0000 (13:33 -0700)
committerTom Tromey <tromey@redhat.com>
Wed, 19 Feb 2014 14:47:00 +0000 (07:47 -0700)
2014-02-19  Tom Tromey  <tromey@redhat.com>

* target-delegates.c: Rebuild.
* target.c (target_detach): Unconditionally delegate.
(init_dummy_target): Don't initialize to_detach.
* target.h (struct target_ops) <to_detach>: Use
TARGET_DEFAULT_IGNORE.

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

index 5842158..62c429d 100644 (file)
@@ -1,5 +1,13 @@
 2014-02-19  Tom Tromey  <tromey@redhat.com>
 
+       * target-delegates.c: Rebuild.
+       * target.c (target_detach): Unconditionally delegate.
+       (init_dummy_target): Don't initialize to_detach.
+       * target.h (struct target_ops) <to_detach>: Use
+       TARGET_DEFAULT_IGNORE.
+
+2014-02-19  Tom Tromey  <tromey@redhat.com>
+
        * target.h (struct target_ops) <to_augmented_libraries_svr4_read>:
        Add argument.
        (target_augmented_libraries_svr4_read): Add argument.
index 0685729..f3b8b4d 100644 (file)
@@ -4,6 +4,18 @@
 /* To regenerate this file, run:*/
 /*      make-target-delegates target.h > target-delegates.c */
 static void
+delegate_detach (struct target_ops *self, const char *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_detach (self, arg1, arg2);
+}
+
+static void
+tdefault_detach (struct target_ops *self, const char *arg1, int arg2)
+{
+}
+
+static void
 delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
 {
   self = self->beneath;
@@ -138,6 +150,8 @@ tdefault_supports_btrace (struct target_ops *self)
 static void
 install_delegators (struct target_ops *ops)
 {
+  if (ops->to_detach == NULL)
+    ops->to_detach = delegate_detach;
   if (ops->to_resume == NULL)
     ops->to_resume = delegate_resume;
   if (ops->to_wait == NULL)
@@ -167,6 +181,7 @@ install_delegators (struct target_ops *ops)
 static void
 install_dummy_methods (struct target_ops *ops)
 {
+  ops->to_detach = tdefault_detach;
   ops->to_resume = tdefault_resume;
   ops->to_wait = tdefault_wait;
   ops->to_store_registers = tdefault_store_registers;
index 44ffe47..5bab9cf 100644 (file)
@@ -2690,19 +2690,10 @@ target_detach (const char *args, int from_tty)
 
   prepare_for_detach ();
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_detach != NULL)
-       {
-         t->to_detach (t, args, from_tty);
-         if (targetdebug)
-           fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n",
-                               args, from_tty);
-         return;
-       }
-    }
-
-  internal_error (__FILE__, __LINE__, _("could not find a target to detach"));
+  current_target.to_detach (&current_target, args, from_tty);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n",
+                       args, from_tty);
 }
 
 void
@@ -3816,8 +3807,6 @@ 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 *, const char *, int))target_ignore;
   dummy_target.to_create_inferior = find_default_create_inferior;
   dummy_target.to_supports_non_stop = find_default_supports_non_stop;
   dummy_target.to_supports_disable_randomization
index 40e7688..4af0c88 100644 (file)
@@ -405,7 +405,8 @@ struct target_ops
     void (*to_close) (struct target_ops *);
     void (*to_attach) (struct target_ops *ops, char *, int);
     void (*to_post_attach) (struct target_ops *, int);
-    void (*to_detach) (struct target_ops *ops, const char *, int);
+    void (*to_detach) (struct target_ops *ops, const char *, int)
+      TARGET_DEFAULT_IGNORE ();
     void (*to_disconnect) (struct target_ops *, char *, int);
     void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
       TARGET_DEFAULT_NORETURN (noprocess ());