This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ob/pushed] Native targets: Add inf-child.c:inf_child_mourn_inferior and use it.


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     | 12 ++++++++++++
 gdb/darwin-nat.c  |  3 +--
 gdb/gnu-nat.c     |  3 +--
 gdb/inf-child.c   |  7 +++++++
 gdb/inf-child.h   |  4 ++++
 gdb/inf-ptrace.c  |  4 +---
 gdb/inf-ttrace.c  |  3 +--
 gdb/nto-procfs.c  |  3 +--
 gdb/windows-nat.c |  3 +--
 9 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 24de5fa..d9c9c13 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index f3d510d..160329b 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -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
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 3317215..516e83d 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -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);
 }
 
 
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index a3c4fe4..dbadde8 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -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
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 3f00ab6..b2692ca 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -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
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index cc4921b..4736fbd 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -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,
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index 96105dc..ee55515 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -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
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 8a241a8..2ce9563 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -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
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index fe43c24..88844fe 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -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
-- 
1.9.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]