## return 0
##}
-global srcfile
-set testfile "foll-vfork"
-set testfile2 "vforked-prog"
-set srcfile ${testfile}.c
-set srcfile2 ${testfile2}.c
-set binfile ${objdir}/${subdir}/${testfile}
-set binfile2 ${objdir}/${subdir}/${testfile2}
+standard_testfile
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested foll-vfork.exp
- return -1
+if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
+ untested "failed to compile $testfile"
+ return -1
}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
- untested foll-vfork.exp
- return -1
+set testfile2 "vforked-prog"
+set srcfile2 ${testfile2}.c
+
+if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
+ untested "failed to compile $testfile2"
+ return -1
}
# A few of these tests require a little more time than the standard
proc vfork_parent_follow_through_step {} {
global gdb_prompt
- send_gdb "set follow-fork parent\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "set follow-fork parent, vfork through step"}
- timeout {fail "set follow-fork parent, vfork through step"}
- }
- send_gdb "next\n"
- gdb_expect {
- -re "Detaching after fork from.*13.*$gdb_prompt "\
- {pass "vfork parent follow, through step"}
- -re "$gdb_prompt $" {fail "vfork parent follow, through step"}
- timeout {fail "(timeout) vfork parent follow, through step" }
+ gdb_test_no_output "set follow-fork parent" \
+ "set follow-fork parent, vfork through step"
+
+ set test "vfork parent follow, through step"
+ gdb_test_multiple "next" $test {
+ -re "Detaching after fork from.*13.*$gdb_prompt " {
+ pass "vfork parent follow, through step"
+ }
}
# The child has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
global gdb_prompt
global srcfile
- send_gdb "set follow-fork parent\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "set follow-fork parent, vfork to bp"}
- timeout {fail "set follow-fork parent, vfork to bp"}
- }
- send_gdb "break ${srcfile}:18\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "break, vfork to bp"}
- timeout {fail "break, vfork to bp"}
- }
- send_gdb "continue\n"
- gdb_expect {
- -re ".*Detaching after fork from child process.*Breakpoint.*18.*$gdb_prompt "\
- {pass "vfork parent follow, to bp"}
- -re "$gdb_prompt $" {fail "vfork parent follow, to bp"}
- timeout {fail "(timeout) vfork parent follow, to bp" }
+ gdb_test_no_output "set follow-fork parent" \
+ "set follow-fork parent, vfork to bp"
+
+ gdb_test "break ${srcfile}:18" ".*" "break, vfork to bp"
+
+ set test "vfork parent follow, to bp"
+ gdb_test_multiple "continue" $test {
+ -re ".*Detaching after fork from child process.*Breakpoint.*18.*$gdb_prompt " {
+ pass $test
+ }
}
# The child has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
exec sleep 1
}
+# Kill child and reload symbols.
+proc kill_child {} {
+ global binfile
+ global gdb_prompt
+
+ set test "killing inferior"
+ gdb_test_multiple "kill" $test {
+ -re ".*Kill the program being debugged.*y or n. $" {
+ gdb_test_no_output "y" ""
+ set test2 "file $binfile"
+ gdb_test_multiple "file $binfile" $test2 {
+ -re ".*Load new symbol table from.*y or n. $" {
+ send_gdb "y\n"
+ gdb_test_multiple "" "loading symbols" {
+ -re "Reading symbols from.*$gdb_prompt $" {
+ }
+ }
+ }
+ -re ".*gdb_prompt $" {
+ }
+ }
+ }
+ -re ".*$gdb_prompt $" {
+ }
+ }
+}
+
proc vfork_and_exec_child_follow_to_main_bp {} {
global gdb_prompt
- global binfile
- send_gdb "set follow-fork child\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "set follow-fork child, vfork and exec to main bp"}
- timeout {fail "set follow-fork child, vfork and exec to main bp"}
- }
- send_gdb "continue\n"
- gdb_expect {
- -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt "\
- {pass "vfork and exec child follow, to main bp"}
- -re "$gdb_prompt $" {fail "vfork and exec child follow, to main bp"}
- timeout {fail "(timeout) vfork and exec child follow, to main bp" }
+ gdb_test_no_output \
+ "set follow-fork child" \
+ "set follow-fork child, vfork and exec to main bp"
+
+ set test "vfork and exec child follow, to main bp"
+ gdb_test_multiple "continue" $test {
+ -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt " {
+ pass $test
+ }
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# Explicitly kill this child, or a subsequent rerun actually runs
# the exec'd child, not the original program...
- send_gdb "kill\n"
- gdb_expect {
- -re ".*Kill the program being debugged.*y or n. $" {
- gdb_test_no_output "y" ""
- send_gdb "file $binfile\n"
- gdb_expect {
- -re ".*Load new symbol table from.*y or n. $" {
- send_gdb "y\n"
- gdb_expect {
- -re "Reading symbols from.*$gdb_prompt $" {}
- timeout { fail "loading symbols (timeout)"; return }
- }
- }
- -re ".*gdb_prompt $" {}
- timeout { fail "loading symbols (timeout)"; return }
- }
- }
- -re ".*$gdb_prompt $" {}
- timeout { fail "killing inferior (timeout)" ; return }
- }
+ kill_child
}
proc vfork_and_exec_child_follow_through_step {} {
global gdb_prompt
- global binfile
# 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
return 0
}
- send_gdb "set follow-fork child\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "set follow-fork child, vfork and exec through step"}
- timeout {fail "set follow-fork child, vfork and exec through step"}
- }
- send_gdb "next\n"
- gdb_expect {
- -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt "\
- {pass "vfork and exec child follow, through step"}
- -re "$gdb_prompt $" {fail "vfork and exec child follow, through step"}
- timeout {fail "(timeout) vfork and exec child follow, through step" }
+ gdb_test_no_output \
+ "set follow-fork child" \
+ "set follow-fork child, vfork and exec through step"
+
+ set test "vfork and exec child follow, through step"
+ gdb_test_multiple "next" $test {
+ -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt " {
+ pass "$test"
+ }
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# Explicitly kill this child, or a subsequent rerun actually runs
# the exec'd child, not the original program...
- send_gdb "kill\n"
- gdb_expect {
- -re ".*Kill the program being debugged.*y or n. $" {
- gdb_test_no_output "y" ""
- send_gdb "file $binfile\n"
- gdb_expect {
- -re ".*Load new symbol table from.*y or n. $" {
- send_gdb "y\n"
- gdb_expect {
- -re "Reading symbols from.*$gdb_prompt $" {}
- timeout { fail "loading symbols (timeout)"; return }
- }
- }
- -re ".*gdb_prompt $" {}
- timeout { fail "loading symbols (timeout)"; return }
- }
- }
- -re ".*$gdb_prompt $" {}
- timeout { fail "killing inferior (timeout)" ; return }
- }
+ kill_child
}
proc tcatch_vfork_then_parent_follow {} {
global gdb_prompt
global srcfile
- send_gdb "set follow-fork parent\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "set follow-fork parent, tcatch vfork"}
- timeout {fail "set follow-fork parent, tcatch vfork"}
- }
- send_gdb "tcatch vfork\n"
- gdb_expect {
- -re "Catchpoint .*(vfork).*$gdb_prompt $"\
- {pass "vfork parent follow, set tcatch vfork"}
- -re "$gdb_prompt $" {fail "vfork parent follow, set tcatch vfork"}
- timeout {fail "(timeout) vfork parent follow, set tcatch vfork"}
- }
- send_gdb "continue\n"
-# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
-# stop you in "_vfork".
- gdb_expect {
- -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt "\
- {pass "vfork parent follow, tcatch vfork"}
- -re "vfork \\(\\) at.*$gdb_prompt "\
- {pass "vfork parent follow, tcatch vfork"}
- -re "$gdb_prompt $" {fail "vfork parent follow, tcatch vfork"}
- timeout {fail "(timeout) vfork parent follow, tcatch vfork"}
+ gdb_test_no_output \
+ "set follow-fork parent" \
+ "set follow-fork parent, tcatch vfork"
+
+ gdb_test "tcatch vfork" \
+ "Catchpoint .*(vfork).*" \
+ "vfork parent follow, set tcatch vfork"
+
+ # HP-UX 10.20 seems to stop you in "vfork", while more recent
+ # HP-UXs stop you in "_vfork".
+ set test "vfork parent follow, tcatch 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
+ }
}
- send_gdb "finish\n"
- gdb_expect {
- -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:12.*$gdb_prompt "\
- {pass "vfork parent follow, finish after tcatch vfork"}
+
+ set test "vfork parent follow, finish after tcatch vfork"
+ gdb_test_multiple "finish" $test {
+ -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:12.*$gdb_prompt " {
+ pass $test
+ }
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
send_gdb "finish\n"
exp_continue
}
- -re "$gdb_prompt $" {fail "vfork parent follow, finish after tcatch vfork"}
- timeout {fail "(timeout) vfork parent follow, finish after tcatch vfork" }
}
# The child has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
global srcfile
global srcfile2
- send_gdb "set follow-fork child\n"
- gdb_expect {
- -re "$gdb_prompt $" {pass "set follow-fork child, tcatch vfork"}
- timeout {fail "set follow-fork child, tcatch vfork"}
- }
- send_gdb "tcatch vfork\n"
- gdb_expect {
- -re "Catchpoint .*(vfork).*$gdb_prompt $"\
- {pass "vfork child follow, set tcatch vfork"}
- -re "$gdb_prompt $" {fail "vfork child follow, set tcatch vfork"}
- timeout {fail "(timeout) vfork child follow, set tcatch vfork"}
- }
- send_gdb "continue\n"
-# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
-# stop you in "_vfork".
- gdb_expect {
- -re "vfork \\(\\) at .*$gdb_prompt $"\
- {pass "vfork child follow, tcatch vfork"}
- -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt "\
- {pass "vfork child follow, tcatch vfork"}
- -re "$gdb_prompt $" {fail "vfork child follow, tcatch vfork"}
- timeout {fail "(timeout) vfork child follow, tcatch vfork"}
+ gdb_test_no_output \
+ "set follow-fork child" \
+ "set follow-fork child, tcatch vfork"
+
+ gdb_test "tcatch vfork" \
+ "Catchpoint .*(vfork).*" \
+ "vfork child follow, set tcatch vfork"
+
+ # HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
+ # stop you in "_vfork".
+ set test "vfork child follow, tcatch 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
+ }
}
- send_gdb "finish\n"
- gdb_expect {
- -re "Run till exit from.*vfork.*${srcfile}:12.*$gdb_prompt "\
- {pass "vfork child follow, finish after tcatch vfork"}
+
+ set test "vfork child follow, finish after tcatch vfork"
+ gdb_test_multiple "finish" $test {
+ -re "Run till exit from.*vfork.*${srcfile}:12.*$gdb_prompt " {
+ pass $test
+ }
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
send_gdb "finish\n"
exp_continue
}
- -re "Run till exit from.*vfork.*${srcfile2}:9.*$gdb_prompt "\
- {pass "vfork child follow, finish after tcatch vfork (followed exec)"}
- -re "$gdb_prompt $" {fail "vfork child follow, finish after tcatch vfork"}
- timeout {fail "(timeout) vfork child follow, finish after tcatch vfork" }
+ -re "Run till exit from.*vfork.*${srcfile2}:9.*$gdb_prompt " {
+ pass "$test (followed exec)"
+ }
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
}
# Start with a fresh gdb
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $testfile
# The "Detaching..." and "Attaching..." messages may be hidden by
# default.