diff options
author | Pedro Alves <palves@redhat.com> | 2012-11-02 17:57:04 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2012-11-02 17:57:04 +0000 |
commit | 771bc0af444a8ae839e74b0cd2d9ba62fa5ac46b (patch) | |
tree | f8a63320e0379b9e722b15f0f4f72b4b2d142f13 /gdb/testsuite | |
parent | f0559fff600165f5cbdf546737217e1da3f737b8 (diff) | |
download | gdb-771bc0af444a8ae839e74b0cd2d9ba62fa5ac46b.zip gdb-771bc0af444a8ae839e74b0cd2d9ba62fa5ac46b.tar.gz gdb-771bc0af444a8ae839e74b0cd2d9ba62fa5ac46b.tar.bz2 |
2012-11-02 Pedro Alves <palves@redhat.com>
Modernize.
* gdb.base/foll-vfork.exp: Use standard_testfile and
build_executable. Pass descriptive string to untested.
(vfork_parent_follow_through_step, vfork_parent_follow_to_bp)
(vfork_and_exec_child_follow_to_main_bp)
(vfork_and_exec_child_follow_through_step)
(tcatch_vfork_then_parent_follow, tcatch_vfork_then_child_follow)
(do_vfork_and_exec_tests): Use gdb_test/gdb_test_multiple instead
of send_gdb/gdb_expect.
(kill_child): New procedure.
(vfork_and_exec_child_follow_to_main_bp)
(vfork_and_exec_child_follow_through_step): Use it.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.base/foll-vfork.exp | 294 |
1 files changed, 127 insertions, 167 deletions
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index 7a3c04e..73be334 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -40,22 +40,19 @@ if [istarget "hppa*-hp-hpux10.20"] then { ## 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 @@ -89,17 +86,14 @@ proc check_vfork_catchpoints {} { 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 @@ -112,22 +106,16 @@ proc vfork_parent_follow_to_bp {} { 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 @@ -136,21 +124,45 @@ proc vfork_parent_follow_to_bp {} { 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 @@ -160,31 +172,11 @@ proc vfork_and_exec_child_follow_to_main_bp {} { # 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 @@ -198,17 +190,15 @@ proc vfork_and_exec_child_follow_through_step {} { 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 @@ -218,65 +208,42 @@ proc vfork_and_exec_child_follow_through_step {} { # 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 @@ -290,41 +257,38 @@ proc tcatch_vfork_then_child_follow {} { 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 @@ -385,11 +349,7 @@ proc do_vfork_and_exec_tests {} { } # 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. |