* Makefile.in (symfile.o): Update.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / foll-fork.exp
index 7ce72e16c10ad337be5e0cede52ad2ab72e373e8..b3aae8c4191615ad727105e7c184e79414788fb2 100644 (file)
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
-
-if $tracelevel then {
-       strace $tracelevel
-       }
-
-if { ![isnative] } then {
+if { [is_remote target] || ![isnative] } then {
     continue
 }
 
 set prms_id 0
 set bug_id 0
 
+global srcfile
 set testfile "foll-fork"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
@@ -41,10 +35,32 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 # Until "set follow-fork-mode" and "catch fork" are implemented on
 # other targets...
 #
-if ![istarget "hppa*-hp-hpux*"] then {
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
     continue
 }
 
+proc check_fork_catchpoints {} {
+  global gdb_prompt
+
+  # Verify that the system supports "catch fork".
+  gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "insert first fork catchpoint"
+  set has_fork_catchpoints 0
+  gdb_test_multiple "continue" "continue to first fork catchpoint" {
+    -re ".*Your system does not support fork catchpoints.*$gdb_prompt $" {
+      unsupported "continue to first fork catchpoint"
+    }
+    -re ".*Catchpoint.*$gdb_prompt $" {
+      set has_fork_catchpoints 1
+      pass "continue to first fork catchpoint"
+    }
+  }
+
+  if {$has_fork_catchpoints == 0} {
+    unsupported "fork catchpoints"
+    return -code return
+  }
+}
+
 proc default_fork_parent_follow {} {
    global gdb_prompt
 
@@ -115,7 +131,7 @@ proc explicit_fork_child_follow {} {
    }
    send_gdb "next 2\n"
    gdb_expect {
-      -re "Detaching from program:.*Attaching after fork to.*$gdb_prompt $"\
+      -re "Attaching after fork to.*$gdb_prompt $"\
                       {pass "explicit child follow, no catchpoints"}
       -re "$gdb_prompt $" {fail "explicit child follow, no catchpoints"}
       timeout         {fail "(timeout) explicit child follow, no catchpoints"}
@@ -129,6 +145,7 @@ proc explicit_fork_child_follow {} {
 
 proc catch_fork_child_follow {} {
    global gdb_prompt
+   global srcfile
 
    send_gdb "catch fork\n"
    gdb_expect {
@@ -153,7 +170,7 @@ proc catch_fork_child_follow {} {
 
    send_gdb "continue\n"
    gdb_expect {
-      -re "Catchpoint.*(forked process.*),.*in _fork_sys.*$gdb_prompt $"\
+      -re "Catchpoint.*(forked process.*),.*in .*fork.*$gdb_prompt $"\
                       {pass "explicit child follow, catch fork"}
       -re "$gdb_prompt $" {fail "explicit child follow, catch fork"}
       timeout         {fail "(timeout) explicit child follow, catch fork"}
@@ -175,7 +192,7 @@ proc catch_fork_child_follow {} {
       -re "$gdb_prompt $" {pass "set follow child"}
       timeout         {fail "(timeout) set follow child"}
    }
-   send_gdb "tbreak 24\n"
+   send_gdb "tbreak ${srcfile}:24\n"
    gdb_expect {
       -re "Breakpoint.*, line 24.*$gdb_prompt $"\
                       {pass "set follow child, tbreak"}
@@ -184,7 +201,7 @@ proc catch_fork_child_follow {} {
    }
    send_gdb "continue\n"
    gdb_expect {
-      -re ".*Detaching from program:.*Attaching after fork to.* at .*24.*$gdb_prompt $"\
+      -re "Attaching after fork to.* at .*24.*$gdb_prompt $"\
                       {pass "set follow child, hit tbreak"}
       -re "$gdb_prompt $" {fail "set follow child, hit tbreak"}
       timeout         {fail "(timeout) set follow child, hit tbreak"}
@@ -211,6 +228,7 @@ proc catch_fork_child_follow {} {
 
 proc tcatch_fork_parent_follow {} {
    global gdb_prompt
+   global srcfile
 
    send_gdb "catch fork\n"
    gdb_expect {
@@ -225,7 +243,7 @@ proc tcatch_fork_parent_follow {} {
 
    send_gdb "continue\n"
    gdb_expect {
-      -re ".*in _fork_sys.*$gdb_prompt $"\
+      -re ".*in .*fork.*$gdb_prompt $"\
                       {pass "explicit parent follow, tcatch fork"}
       -re "$gdb_prompt $" {fail "explicit parent follow, tcatch fork"}
       timeout         {fail "(timeout) explicit parent follow, tcatch fork"}
@@ -235,7 +253,7 @@ proc tcatch_fork_parent_follow {} {
       -re "$gdb_prompt $" {pass "set follow parent"}
       timeout         {fail "(timeout) set follow parent"}
    }
-   send_gdb "tbreak 24\n"
+   send_gdb "tbreak ${srcfile}:24\n"
    gdb_expect {
       -re "Breakpoint.*, line 24.*$gdb_prompt $"\
                       {pass "set follow parent, tbreak"}
@@ -313,6 +331,10 @@ By default, the debugger will follow the parent process..*$gdb_prompt $"\
      timeout         {fail "set follow to nonsense is prohibited (reset parent)"}
    }
 
+   # Check that fork catchpoints are supported, as an indicator for whether
+   # fork-following is supported.
+   if [runto_main] then { check_fork_catchpoints }
+
    # Test the default behaviour, which is to follow the parent of a
    # fork, and detach from the child.  Do this without catchpoints.
    #
@@ -357,6 +379,9 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
+# The "Detaching..." and "Attaching..." messages may be hidden by
+# default.
+gdb_test "set verbose" ""
 
 # This is a test of gdb's ability to follow the parent, child or both
 # parent and child of a Unix fork() system call.
This page took 0.026331 seconds and 4 git commands to generate.