gdb/
authorPedro Alves <palves@redhat.com>
Mon, 5 Nov 2012 18:56:45 +0000 (18:56 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 5 Nov 2012 18:56:45 +0000 (18:56 +0000)
2012-11-05  Pedro Alves  <palves@redhat.com>

* inferior.c (exit_inferior_1): Clear 'vfork_parent' in the vfork
child.  Clear 'pending_detach'.
* infrun.c (handle_vfork_child_exec_or_exit): Clear
'pending_detach' in the vfork parent.

gdb/testsuite/
2012-11-05  Pedro Alves  <palves@redhat.com>

* gdb.base/foll-vfork.exp (vfork_relations_in_info_inferiors): New
procedure.
(do_vfork_and_follow_child_tests_exec)
(do_vfork_and_follow_child_tests_exit): Call it.

gdb/ChangeLog
gdb/inferior.c
gdb/infrun.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/foll-vfork.exp

index ecf623946feb3d51f3d6685d109766e4f40e0559..baf3e7152992e68a6e1abd6e3dc90996c3110534 100644 (file)
@@ -1,3 +1,10 @@
+2012-11-05  Pedro Alves  <palves@redhat.com>
+
+       * inferior.c (exit_inferior_1): Clear 'vfork_parent' in the vfork
+       child.  Clear 'pending_detach'.
+       * infrun.c (handle_vfork_child_exec_or_exit): Clear
+       'pending_detach' in the vfork parent.
+
 2012-11-05  Doug Evans  <dje@google.com>
 
        Add support for DWP files.  http://gcc.gnu.org/wiki/DebugFissionDWP
index f45058aa815715281ad66a539334490fb9ea3fdb..f46e1e336cc4a34c42191d55ec44c8411e2d077d 100644 (file)
@@ -266,9 +266,15 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
       inf->vfork_parent->vfork_child = NULL;
       inf->vfork_parent = NULL;
     }
+  if (inf->vfork_child != NULL)
+    {
+      inf->vfork_child->vfork_parent = NULL;
+      inf->vfork_child = NULL;
+    }
 
   inf->has_exit_code = 0;
   inf->exit_code = 0;
+  inf->pending_detach = 0;
 }
 
 void
index ab5aacf584da9fd1da9dc5270b5c157c5b2fea63..3d6eccd830f3473ecc97ad56d88c01ebf2242b05 100644 (file)
@@ -663,6 +663,8 @@ handle_vfork_child_exec_or_exit (int exec)
 
          /* follow-fork child, detach-on-fork on.  */
 
+         inf->vfork_parent->pending_detach = 0;
+
          if (!exec)
            {
              /* If we're handling a child exit, then inferior_ptid
index 227b24fbd7895cb96a3bc6c2cac1525a8d41568e..80aac5bd379d70f5973729b981e97971614c43d8 100644 (file)
@@ -1,3 +1,10 @@
+2012-11-05  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/foll-vfork.exp (vfork_relations_in_info_inferiors): New
+       procedure.
+       (do_vfork_and_follow_child_tests_exec)
+       (do_vfork_and_follow_child_tests_exit): Call it.
+
 2012-11-05  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/foll-vfork.c (main): Call perror and _exit if execlp()
index 0b2eee69e30d2e95e480a241f3b03da4ba391dd6..58e92c433b809877bc8d046c9d0d991ffd41fc79 100644 (file)
@@ -388,6 +388,58 @@ proc tcatch_vfork_then_child_follow_exit {} {
    exec sleep 1
 }}
 
+proc vfork_relations_in_info_inferiors { variant } {
+  with_test_prefix "vfork relations in info inferiors" {
+   global gdb_prompt
+
+   setup_gdb
+
+   gdb_test_no_output "set follow-fork child"
+
+   set test "step over vfork"
+   gdb_test_multiple "next" $test {
+       -re "Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
+          pass "$test"
+       }
+   }
+
+   gdb_test "info inferiors" \
+       ".*is vfork child of inferior 1.*is vfork parent of inferior 2" \
+       "info inferiors shows vfork parent/child relation"
+
+   if { $variant == "exec" } {
+       global srcfile2
+
+       set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
+       set test "continue to bp"
+       gdb_test_multiple "continue" $test {
+          -re ".*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
+              pass $test
+          }
+       }
+   } else {
+       set test "continue to child exit"
+       gdb_test_multiple "continue" $test {
+          -re "exited normally.*$gdb_prompt " {
+              pass $test
+          }
+       }
+   }
+
+   set test "vfork relation no longer appears in info inferiors"
+   gdb_test_multiple "info inferiors" $test {
+       -re "is vfork child of inferior 1.*$gdb_prompt $" {
+          fail $test
+       }
+       -re "is vfork parent of inferior 2.*$gdb_prompt $" {
+          fail $test
+       }
+       -re "$gdb_prompt $" {
+          pass $test
+       }
+   }
+}}
+
 proc do_vfork_and_follow_parent_tests {} {
    global gdb_prompt
 
@@ -435,6 +487,13 @@ proc do_vfork_and_follow_child_tests_exec {} {
    # catchpoints.
    # ??rehrauer: NYI.  Will add testpoints here when implemented.
    #
+
+   # Step over a vfork in the child, do "info inferiors" and check the
+   # parent/child relation is displayed.  Run the child over the exec,
+   # and confirm the relation is no longer displayed in "info
+   # inferiors".
+   #
+   vfork_relations_in_info_inferiors "exec"
 }
 
 proc do_vfork_and_follow_child_tests_exit {} {
@@ -446,6 +505,13 @@ proc do_vfork_and_follow_child_tests_exit {} {
    # Try catching a vfork, and stepping out to the child.
    #
    tcatch_vfork_then_child_follow_exit
+
+   # Step over a vfork in the child, do "info inferiors" and check the
+   # parent/child relation is displayed.  Run the child to completion,
+   # and confirm the relation is no longer displayed in "info
+   # inferiors".
+   #
+   vfork_relations_in_info_inferiors "exit"
 }
 
 with_test_prefix "check vfork support" {
This page took 0.047804 seconds and 4 git commands to generate.