[gdb/testsuite] Stabilize gdb-caching-proc.exp test order
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / foll-vfork.exp
index fe3663cba20fbc71be4abf24d9906bbe03a5858e..7bfebb2a91f06dc954469b64da8b1c36f642eb34 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright 1997-2014 Free Software Foundation, Inc.
+#   Copyright 1997-2019 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # either execs or exits --- since those events take somewhat different
 # code paths in GDB, both variants are exercised.
 
-if { [is_remote target] || ![isnative] } then {
-    continue
-}
-
 # Until "set follow-fork-mode" and "catch vfork" are implemented on
 # other targets...
 #
-if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
+if {![istarget "*-linux*"]} then {
     continue
 }
 
-# Test to see if we are on an HP-UX 10.20 and if so,
-# do not run these tests as catching vfork is disabled for
-# 10.20.
-
-if [istarget "hppa*-hp-hpux10.20"] then {
+# Test relies on checking follow-fork output. Do not run if gdb debug is
+# enabled as it will be redirected to the log.
+if [gdb_debug_enabled] {
+    untested "debug is enabled"
     return 0
 }
 
-# NOTE drow/2002-12-06: I don't know what the referenced kernel problem
-# is, but it appears to be fixed in recent HP/UX versions.
-
-##if [istarget "hppa2.0w-hp-hpux*"] {
-##  warning "Don't run gdb.base/foll-vfork.exp until JAGaa43495 kernel problem is fixed."
-##  return 0
-##}
-
 standard_testfile
 
 set compile_options debug
-set dirname [relative_filename [pwd] [file dirname $binfile]]
-lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
 
 if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
-    untested "failed to compile $testfile"
+    untested "failed to compile main testcase"
     return -1
 }
 
@@ -60,7 +45,7 @@ set testfile2 "vforked-prog"
 set srcfile2 ${testfile2}.c
 
 if {[build_executable $testfile.exp $testfile2 $srcfile2 $compile_options] == -1} {
-    untested "failed to compile $testfile2"
+    untested "failed to compile secondary testcase"
     return -1
 }
 
@@ -73,17 +58,17 @@ set timeout [expr "$timeout + 10"]
 # error, behave as "return", so we don't try to continue testing with
 # a borked session.
 proc setup_gdb {} {
-    global testfile
+    global testfile srcfile
 
     clean_restart $testfile
 
-    # The "Detaching..." and "Attaching..." messages may be hidden by
-    # default.
-    gdb_test_no_output "set verbose"
-
     if ![runto_main] {
        return -code return
     }
+
+    set tbreak_line [gdb_get_line_number " VFORK " $srcfile]
+    gdb_test "tbreak ${tbreak_line}"
+    gdb_continue_to_breakpoint ".*"
 }
 
 proc check_vfork_catchpoints {} {
@@ -121,7 +106,7 @@ proc vfork_parent_follow_through_step {} {
 
    set test "step"
    gdb_test_multiple "next" $test {
-       -re "Detaching after fork from.*if \\(pid == 0\\).*$gdb_prompt " {
+       -re "\\\[Detaching after vfork from.*if \\(pid == 0\\).*$gdb_prompt " {
           pass $test
        }
    }
@@ -146,7 +131,7 @@ proc vfork_parent_follow_to_bp {} {
 
    set test "continue to bp"
    gdb_test_multiple "continue" $test {
-       -re ".*Detaching after fork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
+       -re ".*\\\[Detaching after vfork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
           pass $test
        }
    }
@@ -171,7 +156,7 @@ proc vfork_child_follow_to_exit {} {
          # PR gdb/14766
          fail "$test"
       }
-      -re "Attaching after.* vfork to.*Detaching vfork parent .* after child exit.*$gdb_prompt " {
+       -re "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent .* after child exit.*$gdb_prompt " {
          pass $test
       }
    }
@@ -195,7 +180,7 @@ proc vfork_and_exec_child_follow_to_main_bp {} {
 
    set test "continue to bp"
    gdb_test_multiple "continue" $test {
-      -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
+      -re "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
          pass $test
       }
    }
@@ -211,46 +196,18 @@ proc vfork_and_exec_child_follow_through_step {} {
    global gdb_prompt
    global srcfile2
 
-   if { [istarget "hppa*-*-hpux*"] && ![istarget "hppa*-*-hpux11.*"] } {
-      # This test cannot be performed prior to HP-UX 10.30, because
-      # ptrace-based debugging of a vforking program basically doesn't
-      # allow the child to do things like hit a breakpoint between a
-      # vfork and exec.  This means that saying "set follow-fork
-      # child; next" at a vfork() call won't work, because the
-      # implementation of "next" sets a "step resume" breakpoint at
-      # the return from the vfork(), which the child will hit on its
-      # way to exec'ing.
-      #
-      verbose "vfork child-following next test ignored for pre-HP/UX-10.30 targets."
-      return 0
-   }
-
    setup_gdb
 
    gdb_test_no_output "set follow-fork child"
 
    set test "step over vfork"
-   if { [istarget "hppa*-*-hpux*"]} {
-       # Since the child cannot be debugged until after it has exec'd,
-       # and since there's a bp on "main" in the parent, and since the
-       # bp's for the parent are recomputed in the exec'd child, the
-       # step through a vfork should land us in the "main" for the
-       # exec'd child, too.
-       #
-       set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
-       gdb_test_multiple "next" $test {
-          -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
-              pass "$test"
-          }
-       }
-   } else {
-       # The ideal support is to be able to debug the child even
-       # before it execs.  Thus, "next" lands on the next line after
-       # the vfork.
-       gdb_test_multiple "next" $test {
-          -re "Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
-              pass "$test"
-          }
+
+   # The ideal support is to be able to debug the child even
+   # before it execs.  Thus, "next" lands on the next line after
+   # the vfork.
+   gdb_test_multiple "next" $test {
+       -re "\\\[Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
+          pass "$test"
        }
    }
    # The parent has been detached; allow time for any output it might
@@ -260,6 +217,21 @@ proc vfork_and_exec_child_follow_through_step {} {
    exec sleep 1
 }}
 
+proc continue_to_vfork {} {
+   global gdb_prompt
+
+   # A vfork catchpoint may stop in either "vfork" or "_vfork".
+   set test "continue to vfork"
+   gdb_test_multiple "continue" $test {
+      -re "vfork \\(\\) at .*$gdb_prompt $" {
+         pass $test
+      }
+      -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
+         pass $test
+      }
+   }
+}
+
 proc tcatch_vfork_then_parent_follow {} {
   with_test_prefix "vfork parent follow, finish after tcatch vfork" {
    global gdb_prompt
@@ -271,17 +243,7 @@ proc tcatch_vfork_then_parent_follow {} {
 
    gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
 
-   # HP-UX 10.20 seems to stop you in "vfork", while more recent
-   # HP-UXs stop you in "_vfork".
-   set test "continue to vfork"
-   gdb_test_multiple "continue" $test {
-      -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
-         pass $test
-      }
-      -re "vfork \\(\\) at.*$gdb_prompt " {
-         pass $test
-      }
-   }
+   continue_to_vfork
 
    set linenum [gdb_get_line_number "pid = vfork ();"]
    set test "finish"
@@ -313,17 +275,7 @@ proc tcatch_vfork_then_child_follow_exec {} {
 
    gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
 
-   # HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
-   # stop you in "_vfork".
-   set test "continue to vfork"
-   gdb_test_multiple "continue" $test {
-      -re "vfork \\(\\) at .*$gdb_prompt $" {
-         pass $test
-      }
-      -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
-         pass $test
-      }
-   }
+   continue_to_vfork
 
    set linenum1 [gdb_get_line_number "pid = vfork ();"]
    set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
@@ -359,17 +311,7 @@ proc tcatch_vfork_then_child_follow_exit {} {
 
    gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
 
-   # HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
-   # stop you in "_vfork".
-   set test "continue to vfork"
-   gdb_test_multiple "continue" $test {
-      -re "vfork \\(\\) at .*$gdb_prompt $" {
-         pass $test
-      }
-      -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
-         pass $test
-      }
-   }
+   continue_to_vfork
 
    set test "finish"
    gdb_test_multiple "finish" $test {
@@ -402,13 +344,13 @@ proc vfork_relations_in_info_inferiors { variant } {
 
    set test "step over vfork"
    gdb_test_multiple "next" $test {
-       -re "Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
+       -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" \
+       ".*is vfork parent of inferior 2.*is vfork child of inferior 1" \
        "info inferiors shows vfork parent/child relation"
 
    if { $variant == "exec" } {
This page took 0.027128 seconds and 4 git commands to generate.