Native targets: Add inf-child.c:inf_child_mourn_inferior and use it.
authorPedro Alves <palves@redhat.com>
Wed, 21 May 2014 21:28:23 +0000 (22:28 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 21 May 2014 21:28:23 +0000 (22:28 +0100)
Most ports do the same thing in the tail of their mourn routine - call
generic_mourn_inferior+inf_child_maybe_unpush_target.

This factors that out to a convenience function.  More could be done,
but this converts only the really obvious ones.

Tested by building GDB on x86_64 Fedora 20, mingw32 and djgpp.  The
rest is untested, but I think a patch can't get more obvious.

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

* inf-child.c (inf_child_mourn_inferior): New function.
* inf-child.h (inf_child_mourn_inferior): New declaration.
* darwin-nat.c (darwin_mourn_inferior): Use
inf_child_mourn_inferior.
* gnu-nat.c (gnu_mourn_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_mourn_inferior): Likewise.
* inf-ttrace.c (inf_ttrace_mourn_inferior): Likewise.
* nto-procfs.c (procfs_mourn_inferior): Likewise.
* windows-nat.c (windows_mourn_inferior): Likewise.

gdb/ChangeLog
gdb/darwin-nat.c
gdb/gnu-nat.c
gdb/inf-child.c
gdb/inf-child.h
gdb/inf-ptrace.c
gdb/inf-ttrace.c
gdb/nto-procfs.c
gdb/windows-nat.c

index 24de5fadbd77b2e7f57b5fd5308b48402d289003..d9c9c132df6d99421910450046deb61b3528817d 100644 (file)
@@ -1,3 +1,15 @@
+2014-05-21  Pedro Alves  <palves@redhat.com>
+
+       * inf-child.c (inf_child_mourn_inferior): New function.
+       * inf-child.h (inf_child_mourn_inferior): New declaration.
+       * darwin-nat.c (darwin_mourn_inferior): Use
+       inf_child_mourn_inferior.
+       * gnu-nat.c (gnu_mourn_inferior): Likewise.
+       * inf-ptrace.c (inf_ptrace_mourn_inferior): Likewise.
+       * inf-ttrace.c (inf_ttrace_mourn_inferior): Likewise.
+       * nto-procfs.c (procfs_mourn_inferior): Likewise.
+       * windows-nat.c (windows_mourn_inferior): Likewise.
+
 2014-05-21  Doug Evans  <xdje42@gmail.com>
 
        * scm-breakpoint.c (breakpoint_functions): Fix typo.
index f3d510dec09c50077da073a7bf1459d99e51e9b1..160329b89ea09f1bbf1eb49a25ba12111d93ebaf 100644 (file)
@@ -1268,8 +1268,7 @@ darwin_mourn_inferior (struct target_ops *ops)
   xfree (inf->private);
   inf->private = NULL;
 
-  generic_mourn_inferior ();
-  inf_child_maybe_unpush_target (ops);
+  inf_child_mourn_inferior (ops);
 }
 
 static void
index 3317215b17eda28990773d11ccde66f19630c6e8..516e83d96a71db189cfcc9a5c64fe2d914dd57fe 100644 (file)
@@ -2080,8 +2080,7 @@ gnu_mourn_inferior (struct target_ops *ops)
 {
   inf_debug (gnu_current_inf, "rip");
   inf_detach (gnu_current_inf);
-  generic_mourn_inferior ();
-  inf_child_maybe_unpush_target (ops);
+  inf_child_mourn_inferior (ops);
 }
 
 \f
index a3c4fe4c445f98c678415a10586bb4d3d8b6c7af..dbadde845d8527cb66433858e3c80f5b8a63cbf3 100644 (file)
@@ -159,6 +159,13 @@ inf_child_close (struct target_ops *target)
   inf_child_explicitly_opened = 0;
 }
 
+void
+inf_child_mourn_inferior (struct target_ops *ops)
+{
+  generic_mourn_inferior ();
+  inf_child_maybe_unpush_target (ops);
+}
+
 /* See inf-child.h.  */
 
 void
index 3f00ab638916ea96c5842cc95390bbe46c1f97d6..b2692cabe529588659697d6e65163e4e04658806 100644 (file)
@@ -36,6 +36,10 @@ extern void store_waitstatus (struct target_waitstatus *, int);
 extern void inf_child_open_target (struct target_ops *target,
                                   char *arg, int from_tty);
 
+/* To be called by the native target's to_mourn_inferior routine.  */
+
+extern void inf_child_mourn_inferior (struct target_ops *ops);
+
 /* Unpush the target if it wasn't explicitly open with "target native"
    and there are no live inferiors left.  Note: if calling this as a
    result of a mourn or detach, the current inferior shall already
index cc4921bda4ec37716b049556cf874a0b9fa26038..4736fbd816969f81792cb5790564b3b083f143ce 100644 (file)
@@ -174,9 +174,7 @@ inf_ptrace_mourn_inferior (struct target_ops *ops)
      only report its exit status to its original parent.  */
   waitpid (ptid_get_pid (inferior_ptid), &status, 0);
 
-  generic_mourn_inferior ();
-
-  inf_child_maybe_unpush_target (ops);
+  inf_child_mourn_inferior (ops);
 }
 
 /* Attach to the process specified by ARGS.  If FROM_TTY is non-zero,
index 96105dcbd0af5b7bc72ac86a48ab4568aa33bf2d..ee555159bf3c5d7ec56626ba2d50835b76c8a7ed 100644 (file)
@@ -696,8 +696,7 @@ inf_ttrace_mourn_inferior (struct target_ops *ops)
     }
   inf_ttrace_page_dict.count = 0;
 
-  generic_mourn_inferior ();
-  inf_child_maybe_unpush_target (ops);
+  inf_child_mourn_inferior (ops);
 }
 
 /* Assuming we just attached the debugger to a new inferior, create
index 8a241a8a5d2faa3ece9ff8a4e7cf7c878622953a..2ce956385dcb5e5ec74f0d285ab90a34e4d75c80 100644 (file)
@@ -1027,8 +1027,7 @@ procfs_mourn_inferior (struct target_ops *ops)
     }
   inferior_ptid = null_ptid;
   init_thread_list ();
-  generic_mourn_inferior ();
-  inf_child_maybe_unpush_target (ops);
+  inf_child_mourn_inferior (ops);
 }
 
 /* This function breaks up an argument string into an argument
index fe43c2469c709407f5dcd2f7ba98a9d4079876fe..88844fe11cdeb165da4e93b003b808e2065d9d7c 100644 (file)
@@ -2368,8 +2368,7 @@ windows_mourn_inferior (struct target_ops *ops)
       CHECK (CloseHandle (current_process_handle));
       open_process_used = 0;
     }
-  generic_mourn_inferior ();
-  inf_child_maybe_unpush_target (ops);
+  inf_child_mourn_inferior (ops);
 }
 
 /* Send a SIGINT to the process group.  This acts just like the user typed a