OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gdb/] [gdb-6.8/] [gdb-6.8.openrisc-2.1/] [gdb/] [testsuite/] [gdb.base/] [multi-forks.exp] - Diff between revs 24 and 33

Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 33
#   Copyright 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#   Copyright 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# 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
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
# along with this program.  If not, see .
if $tracelevel then {
if $tracelevel then {
        strace $tracelevel
        strace $tracelevel
        }
        }
if { [is_remote target] || ![isnative] } then {
if { [is_remote target] || ![isnative] } then {
    continue
    continue
}
}
# Until "set follow-fork-mode" and "catch fork" are implemented on
# Until "set follow-fork-mode" and "catch fork" are implemented on
# other targets...
# other targets...
#
#
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]} then {
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]} then {
    continue
    continue
}
}
set prms_id 0
set prms_id 0
set bug_id 0
set bug_id 0
set testfile "multi-forks"
set testfile "multi-forks"
set srcfile ${testfile}.c
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
set binfile ${objdir}/${subdir}/${testfile}
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested multi-forks.exp
     untested multi-forks.exp
     return -1
     return -1
}
}
# Start with a fresh gdb
# Start with a fresh gdb
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_load ${binfile}
global gdb_prompt
global gdb_prompt
# This is a test of gdb's ability to follow the parent, child or both
# This is a test of gdb's ability to follow the parent, child or both
# parent and child of multiple Unix fork() system calls.
# parent and child of multiple Unix fork() system calls.
#
#
# The inferior program builds a tree of processes by executing a loop
# The inferior program builds a tree of processes by executing a loop
# four times, calling fork at each iteration.  Thus, at each
# four times, calling fork at each iteration.  Thus, at each
# iteration, the total number of processes doubles; after four
# iteration, the total number of processes doubles; after four
# iterations, we have 16 processes.  Each process saves the results
# iterations, we have 16 processes.  Each process saves the results
# from its 'fork' calls, so we can tell which leaf a given process is
# from its 'fork' calls, so we can tell which leaf a given process is
# by looking at which forks returned zero and which returned a pid: a
# by looking at which forks returned zero and which returned a pid: a
# zero means to take the child's branch; a pid means to take the
# zero means to take the child's branch; a pid means to take the
# parent's branch.
# parent's branch.
# First set gdb to follow the child.
# First set gdb to follow the child.
# The result should be that each of the 4 forks returns zero.
# The result should be that each of the 4 forks returns zero.
runto_main
runto_main
set exit_bp_loc [gdb_get_line_number "Set exit breakpoint here."]
set exit_bp_loc [gdb_get_line_number "Set exit breakpoint here."]
gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
gdb_test "set follow child" "" ""
gdb_test "set follow child" "" ""
send_gdb "continue\n"
send_gdb "continue\n"
gdb_expect {
gdb_expect {
    -re ".*Break.* main .*$gdb_prompt.*$" {}
    -re ".*Break.* main .*$gdb_prompt.*$" {}
    -re ".*$gdb_prompt $" {fail "run to exit 1"}
    -re ".*$gdb_prompt $" {fail "run to exit 1"}
    default {fail "run to exit 1 (timeout)"}
    default {fail "run to exit 1 (timeout)"}
}
}
gdb_test "print pids" "\\$.* = \\{0, 0, 0, 0\\}.*" "follow child, print pids"
gdb_test "print pids" "\\$.* = \\{0, 0, 0, 0\\}.*" "follow child, print pids"
# Now set gdb to follow the parent.
# Now set gdb to follow the parent.
# Result should be that none of the 4 forks returns zero.
# Result should be that none of the 4 forks returns zero.
delete_breakpoints
delete_breakpoints
runto_main
runto_main
gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
gdb_test "set follow parent" "" ""
gdb_test "set follow parent" "" ""
send_gdb "continue\n"
send_gdb "continue\n"
# The output from the child processes can be interleaved arbitrarily
# The output from the child processes can be interleaved arbitrarily
# with the output from GDB and the parent process.  If we don't
# with the output from GDB and the parent process.  If we don't
# consume it all now, it can confuse later interactions.
# consume it all now, it can confuse later interactions.
set seen_done 0
set seen_done 0
set seen_break 0
set seen_break 0
set seen_prompt 0
set seen_prompt 0
set seen_timeout 0
set seen_timeout 0
while { ($seen_done < 16 || ! $seen_prompt) && ! $seen_timeout } {
while { ($seen_done < 16 || ! $seen_prompt) && ! $seen_timeout } {
    # We don't know what order the interesting things will arrive in.
    # We don't know what order the interesting things will arrive in.
    # Using a pattern of the form 'x|y|z' instead of -re x ... -re y
    # Using a pattern of the form 'x|y|z' instead of -re x ... -re y
    # ... -re z ensures that expect always chooses the match that
    # ... -re z ensures that expect always chooses the match that
    # occurs leftmost in the input, and not the pattern appearing
    # occurs leftmost in the input, and not the pattern appearing
    # first in the script that occurs anywhere in the input, so that
    # first in the script that occurs anywhere in the input, so that
    # we don't skip anything.
    # we don't skip anything.
    gdb_expect {
    gdb_expect {
        -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
        -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
            if {[info exists expect_out(1,string)]} {
            if {[info exists expect_out(1,string)]} {
                incr seen_done
                incr seen_done
            } elseif {[info exists expect_out(2,string)]} {
            } elseif {[info exists expect_out(2,string)]} {
                set seen_break 1
                set seen_break 1
            } elseif {[info exists expect_out(3,string)]} {
            } elseif {[info exists expect_out(3,string)]} {
                set seen_prompt 1
                set seen_prompt 1
            }
            }
            array unset expect_out
            array unset expect_out
        }
        }
        timeout { set seen_timeout 1 }
        timeout { set seen_timeout 1 }
    }
    }
}
}
if { $seen_timeout } {
if { $seen_timeout } {
    fail "run to exit 2 (timeout)"
    fail "run to exit 2 (timeout)"
} elseif { ! $seen_prompt } {
} elseif { ! $seen_prompt } {
    fail "run to exit 2 (no prompt)"
    fail "run to exit 2 (no prompt)"
} elseif { ! $seen_break } {
} elseif { ! $seen_break } {
    fail "run to exit 2 (no breakpoint hit)"
    fail "run to exit 2 (no breakpoint hit)"
} elseif { $seen_done != 16 } {
} elseif { $seen_done != 16 } {
    fail "run to exit 2 (missing done messages)"
    fail "run to exit 2 (missing done messages)"
} else {
} else {
    pass "run to exit 2"
    pass "run to exit 2"
}
}
gdb_test "print pids\[0\]==0 || pids\[1\]==0 || pids\[2\]==0 || pids\[3\]==0" \
gdb_test "print pids\[0\]==0 || pids\[1\]==0 || pids\[2\]==0 || pids\[3\]==0" \
    " = 0" "follow parent, print pids"
    " = 0" "follow parent, print pids"
#
#
# Now test with detach-on-fork off.
# Now test with detach-on-fork off.
#
#
runto_main
runto_main
gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" ""
gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" ""
gdb_test "help set detach-on-fork" "whether gdb will detach the child.*" \
gdb_test "help set detach-on-fork" "whether gdb will detach the child.*" \
    "help set detach"
    "help set detach"
gdb_test "show detach-on-fork" "on." "show detach default on"
gdb_test "show detach-on-fork" "on." "show detach default on"
gdb_test "set detach off" "" "set detach off"
gdb_test "set detach off" "" "set detach off"
#
#
# We will now run every fork up to the exit bp,
# We will now run every fork up to the exit bp,
# eventually winding up with 16 forks.
# eventually winding up with 16 forks.
#
#
for {set i 1} {$i <= 15} {incr i} {
for {set i 1} {$i <= 15} {incr i} {
  gdb_test "continue" "Breakpoint .* main .*exit.*" "Run to exit $i"
  gdb_test "continue" "Breakpoint .* main .*exit.*" "Run to exit $i"
  gdb_test "info fork" " 4 .* 3 .* 2 .* 1 .*" "info fork $i"
  gdb_test "info fork" " 4 .* 3 .* 2 .* 1 .*" "info fork $i"
  gdb_test "restart $i" "(_dl_sysinfo_int80|fork|__kernel_(v|)syscall).*" \
  gdb_test "restart $i" "(_dl_sysinfo_int80|fork|__kernel_(v|)syscall).*" \
      "restart $i"
      "restart $i"
}
}
gdb_test "continue" "Breakpoint .* main .*exit.*" "Run to exit 16"
gdb_test "continue" "Breakpoint .* main .*exit.*" "Run to exit 16"
gdb_test "info fork" " 4 .* 3 .* 2 .* 1 .*" "info fork 16"
gdb_test "info fork" " 4 .* 3 .* 2 .* 1 .*" "info fork 16"
gdb_test "restart 0" " main .*" "restart final"
gdb_test "restart 0" " main .*" "restart final"
#
#
# Now we should examine all the pids.
# Now we should examine all the pids.
#
#
#
#
# Test detach fork
# Test detach fork
#
#
# [assumes we're at #0]
# [assumes we're at #0]
gdb_test "detach fork 1" "Detached .*" "Detach 1"
gdb_test "detach fork 1" "Detached .*" "Detach 1"
gdb_test "detach fork 2" "Detached .*" "Detach 2"
gdb_test "detach fork 2" "Detached .*" "Detach 2"
gdb_test "detach fork 3" "Detached .*" "Detach 3"
gdb_test "detach fork 3" "Detached .*" "Detach 3"
gdb_test "detach fork 4" "Detached .*" "Detach 4"
gdb_test "detach fork 4" "Detached .*" "Detach 4"
#
#
# Test delete fork
# Test delete fork
#
#
gdb_test "delete fork 5" "" "Delete 5"
gdb_test "delete fork 5" "" "Delete 5"
gdb_test "info fork 5"   "No fork number 5." "Did delete 5"
gdb_test "info fork 5"   "No fork number 5." "Did delete 5"
gdb_test "delete fork 6" "" "Delete 6"
gdb_test "delete fork 6" "" "Delete 6"
gdb_test "info fork 6"   "No fork number 6." "Did delete 6"
gdb_test "info fork 6"   "No fork number 6." "Did delete 6"
gdb_test "delete fork 7" "" "Delete 7"
gdb_test "delete fork 7" "" "Delete 7"
gdb_test "info fork 7"   "No fork number 7." "Did delete 7"
gdb_test "info fork 7"   "No fork number 7." "Did delete 7"
gdb_test "delete fork 8" "" "Delete 8"
gdb_test "delete fork 8" "" "Delete 8"
gdb_test "info fork 8"   "No fork number 8." "Did delete 8"
gdb_test "info fork 8"   "No fork number 8." "Did delete 8"
gdb_test "delete fork 9" "" "Delete 9"
gdb_test "delete fork 9" "" "Delete 9"
gdb_test "info fork 9"   "No fork number 9." "Did delete 9"
gdb_test "info fork 9"   "No fork number 9." "Did delete 9"
gdb_test "delete fork 10" "" "Delete 10"
gdb_test "delete fork 10" "" "Delete 10"
gdb_test "info fork 10"   "No fork number 10." "Did delete 10"
gdb_test "info fork 10"   "No fork number 10." "Did delete 10"
gdb_test "delete fork 11" "" "Delete 11"
gdb_test "delete fork 11" "" "Delete 11"
gdb_test "info fork 11"   "No fork number 11." "Did delete 11"
gdb_test "info fork 11"   "No fork number 11." "Did delete 11"
gdb_test "delete fork 12" "" "Delete 12"
gdb_test "delete fork 12" "" "Delete 12"
gdb_test "info fork 12"   "No fork number 12." "Did delete 12"
gdb_test "info fork 12"   "No fork number 12." "Did delete 12"
gdb_test "delete fork 13" "" "Delete 13"
gdb_test "delete fork 13" "" "Delete 13"
gdb_test "info fork 13"   "No fork number 13." "Did delete 13"
gdb_test "info fork 13"   "No fork number 13." "Did delete 13"
gdb_test "delete fork 14" "" "Delete 14"
gdb_test "delete fork 14" "" "Delete 14"
gdb_test "info fork 14"   "No fork number 14." "Did delete 14"
gdb_test "info fork 14"   "No fork number 14." "Did delete 14"
gdb_test "delete fork 15" "" "Delete 15"
gdb_test "delete fork 15" "" "Delete 15"
gdb_test "info fork 15"   "No fork number 15." "Did delete 15"
gdb_test "info fork 15"   "No fork number 15." "Did delete 15"
return 0
return 0
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.