* [PATCH 2/8] foll-vfork.exp: Don't hard code line numbers.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure Pedro Alves
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
The test hard codes line numbers, which makes it fragile wrt to
changes to the test's sources. This replaces all the hard-coded
numbers with something else.
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
Don't hard code line numbers.
* gdb.base/foll-vfork.exp (vfork_parent_follow_through_step):
Expect text from the sources instead of a line number.
(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):
Use gdb_get_line_number.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 73be334..67d077d 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -91,7 +91,7 @@ proc vfork_parent_follow_through_step {} {
set test "vfork parent follow, through step"
gdb_test_multiple "next" $test {
- -re "Detaching after fork from.*13.*$gdb_prompt " {
+ -re "Detaching after fork from.*if \\(pid == 0\\).*$gdb_prompt " {
pass "vfork parent follow, through step"
}
}
@@ -109,11 +109,12 @@ proc 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 bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
+ gdb_test "break ${srcfile}:${bp_location}" ".*" "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 " {
+ -re ".*Detaching after fork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
pass $test
}
}
@@ -153,14 +154,17 @@ proc kill_child {} {
proc vfork_and_exec_child_follow_to_main_bp {} {
global gdb_prompt
+ global srcfile2
gdb_test_no_output \
"set follow-fork child" \
"set follow-fork child, vfork and exec to main bp"
+ set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
+
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 " {
+ -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
pass $test
}
}
@@ -177,6 +181,7 @@ proc vfork_and_exec_child_follow_to_main_bp {} {
proc vfork_and_exec_child_follow_through_step {} {
global gdb_prompt
+ global srcfile2
# 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
@@ -195,8 +200,9 @@ proc vfork_and_exec_child_follow_through_step {} {
"set follow-fork child, vfork and exec through step"
set test "vfork and exec child follow, through step"
+ 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:9.*$gdb_prompt " {
+ -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
pass "$test"
}
}
@@ -235,9 +241,10 @@ proc tcatch_vfork_then_parent_follow {} {
}
}
+ set linenum [gdb_get_line_number "pid = 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 " {
+ -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:${linenum}.*$gdb_prompt " {
pass $test
}
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
@@ -277,16 +284,19 @@ proc tcatch_vfork_then_child_follow {} {
}
}
+ set linenum1 [gdb_get_line_number "pid = vfork ();"]
+ set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
+
set test "vfork child follow, finish after tcatch vfork"
gdb_test_multiple "finish" $test {
- -re "Run till exit from.*vfork.*${srcfile}:12.*$gdb_prompt " {
+ -re "Run till exit from.*vfork.*${srcfile}:${linenum1}.*$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 " {
+ -re "Run till exit from.*vfork.*${srcfile2}:${linenum2}.*$gdb_prompt " {
pass "$test (followed exec)"
}
}
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
2012-10-25 17:42 ` [PATCH 2/8] foll-vfork.exp: Don't hard code line numbers Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-11-02 18:18 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 7/8] foll-vfork.exp: Also test following vfork when the child exits Pedro Alves
` (6 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
All the individual tests in foll-vfork.exp currently run under the
same GDB, and each test relies on the previous test cleaning up things
correctly. E.g., killing the fork child, and switching back to the
main executable (after the child having execed another executable).
This isn't very robust. It's also annoying if a test wants to do
"info inferiors", as after a few of these procedures are run we end up
with more than a few inferiors in the list. Always restarting GDB
makes sure things are always nice and tidy between the individual
tests. There are more than a few sleep 1's in the file which dominate
over any slowdown this could introduce.
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.exp (setup_gdb): New procedure.
(check_vfork_catchpoints, vfork_parent_follow_through_step)
(vfork_parent_follow_to_bp): Call it.
(kill_child): Delete.
(vfork_and_exec_child_follow_to_main_bp)
(vfork_and_exec_child_follow_through_step): Call setup_gdb. No
longer call kill_child.
(tcatch_vfork_then_parent_follow): Call setup_gdb.
(do_vfork_and_exec_tests): Don't runto_main before calling each
test procedure.
(top level): Don't clean restart and set verbose before running
each test procedure.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 85 ++++++++++++++-------------------
1 file changed, 36 insertions(+), 49 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index f978f8c..31477ef 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -60,10 +60,27 @@ if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
set oldtimeout $timeout
set timeout [expr "$timeout + 10"]
+# Start with a fresh GDB, with verbosity enabled, and run to main. On
+# error, behave as "return", so we don't try to continue testing with
+# a borked session.
+proc setup_gdb {} {
+ global testfile
+
+ clean_restart $testfile
+
+ gdb_test_no_output "set verbose"
+
+ if ![runto_main] {
+ return -code return
+ }
+}
+
proc check_vfork_catchpoints {} {
global gdb_prompt
global has_vfork_catchpoints
+ setup_gdb
+
# Verify that the system supports "catch vfork".
gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
set has_vfork_catchpoints 0
@@ -87,6 +104,8 @@ proc vfork_parent_follow_through_step {} {
with_test_prefix "vfork parent follow, through step" {
global gdb_prompt
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
set test "step"
@@ -107,6 +126,8 @@ proc vfork_parent_follow_to_bp {} {
global gdb_prompt
global srcfile
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
@@ -125,38 +146,13 @@ 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 {} {
with_test_prefix "vfork and exec child follow, to main bp" {
global gdb_prompt
global srcfile2
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
@@ -172,10 +168,6 @@ proc vfork_and_exec_child_follow_to_main_bp {} {
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
-
- # Explicitly kill this child, or a subsequent rerun actually runs
- # the exec'd child, not the original program...
- kill_child
}}
proc vfork_and_exec_child_follow_through_step {} {
@@ -197,6 +189,8 @@ proc vfork_and_exec_child_follow_through_step {} {
return 0
}
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
set test "step over vfork"
@@ -228,10 +222,6 @@ proc vfork_and_exec_child_follow_through_step {} {
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
-
- # Explicitly kill this child, or a subsequent rerun actually runs
- # the exec'd child, not the original program...
- kill_child
}}
proc tcatch_vfork_then_parent_follow {} {
@@ -239,6 +229,8 @@ proc tcatch_vfork_then_parent_follow {} {
global gdb_prompt
global srcfile
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
@@ -279,6 +271,8 @@ proc tcatch_vfork_then_child_follow {} {
global srcfile
global srcfile2
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
@@ -323,22 +317,22 @@ proc do_vfork_and_exec_tests {} {
# Check that vfork catchpoints are supported, as an indicator for whether
# vfork-following is supported.
- if [runto_main] then { check_vfork_catchpoints }
+ check_vfork_catchpoints
# Try following the parent process by stepping through a call to
# vfork. Do this without catchpoints.
- if [runto_main] then { vfork_parent_follow_through_step }
+ vfork_parent_follow_through_step
# Try following the parent process by setting a breakpoint on the
# other side of a vfork, and running to that point. Do this
# without catchpoints.
- if [runto_main] then { vfork_parent_follow_to_bp }
+ vfork_parent_follow_to_bp
# Try following the child process by just continuing through the
# vfork, and letting the parent's breakpoint on "main" be auto-
# magically reset in the child.
#
- if [runto_main] then { vfork_and_exec_child_follow_to_main_bp }
+ vfork_and_exec_child_follow_to_main_bp
# Try following the child process by stepping through a call to
# vfork. The child also executes an exec. Since the child cannot
@@ -347,15 +341,15 @@ proc do_vfork_and_exec_tests {} {
# recomputed in the exec'd child, the step through a vfork should
# land us in the "main" for the exec'd child, too.
#
- if [runto_main] then { vfork_and_exec_child_follow_through_step }
+ vfork_and_exec_child_follow_through_step
# Try catching a vfork, and stepping out to the parent.
#
- if [runto_main] then { tcatch_vfork_then_parent_follow }
+ tcatch_vfork_then_parent_follow
# Try catching a vfork, and stepping out to the child.
#
- if [runto_main] then { tcatch_vfork_then_child_follow }
+ tcatch_vfork_then_child_follow
# Test the ability to follow both child and parent of a vfork. Do
# this without catchpoints.
@@ -369,13 +363,6 @@ proc do_vfork_and_exec_tests {} {
#
}
-# Start with a fresh gdb
-clean_restart $testfile
-
-# The "Detaching..." and "Attaching..." messages may be hidden by
-# default.
-gdb_test_no_output "set verbose"
-
# This is a test of gdb's ability to follow the parent or child
# of a Unix vfork() system call. (The child will subsequently
# call a variant of a Unix exec() system call.)
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure.
2012-10-25 17:42 ` [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure Pedro Alves
@ 2012-11-02 18:18 ` Pedro Alves
0 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-11-02 18:18 UTC (permalink / raw)
To: gdb-patches
On 10/25/2012 06:42 PM, Pedro Alves wrote:
> +# Start with a fresh GDB, with verbosity enabled, and run to main. On
> +# error, behave as "return", so we don't try to continue testing with
> +# a borked session.
> +proc setup_gdb {} {
> + global testfile
> +
> + clean_restart $testfile
> +
> + gdb_test_no_output "set verbose"
> +
> + if ![runto_main] {
> + return -code return
> + }
> +}
...
> -# The "Detaching..." and "Attaching..." messages may be hidden by
> -# default.
> -gdb_test_no_output "set verbose"
I noticed I lost this comment just before committing. This is the
patch that I ended up applying. It moves that comment to setup_gdb.
Nothing else changed.
gdb/testsuite/
2012-11-02 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.exp (setup_gdb): New procedure.
(check_vfork_catchpoints, vfork_parent_follow_through_step)
(vfork_parent_follow_to_bp): Call it.
(kill_child): Delete.
(vfork_and_exec_child_follow_to_main_bp)
(vfork_and_exec_child_follow_through_step): Call setup_gdb. No
longer call kill_child.
(tcatch_vfork_then_parent_follow): Call setup_gdb.
(do_vfork_and_exec_tests): Don't runto_main before calling each
test procedure.
(top level): Don't clean restart and set verbose before running
each test procedure.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 85 ++++++++++++++-------------------
1 file changed, 36 insertions(+), 49 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index f978f8c..31477ef 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -60,10 +60,27 @@ if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
set oldtimeout $timeout
set timeout [expr "$timeout + 10"]
+# Start with a fresh GDB, with verbosity enabled, and run to main. On
+# error, behave as "return", so we don't try to continue testing with
+# a borked session.
+proc setup_gdb {} {
+ global testfile
+
+ clean_restart $testfile
+
+ gdb_test_no_output "set verbose"
+
+ if ![runto_main] {
+ return -code return
+ }
+}
+
proc check_vfork_catchpoints {} {
global gdb_prompt
global has_vfork_catchpoints
+ setup_gdb
+
# Verify that the system supports "catch vfork".
gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
set has_vfork_catchpoints 0
@@ -87,6 +104,8 @@ proc vfork_parent_follow_through_step {} {
with_test_prefix "vfork parent follow, through step" {
global gdb_prompt
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
set test "step"
@@ -107,6 +126,8 @@ proc vfork_parent_follow_to_bp {} {
global gdb_prompt
global srcfile
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
@@ -125,38 +146,13 @@ 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 {} {
with_test_prefix "vfork and exec child follow, to main bp" {
global gdb_prompt
global srcfile2
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
@@ -172,10 +168,6 @@ proc vfork_and_exec_child_follow_to_main_bp {} {
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
-
- # Explicitly kill this child, or a subsequent rerun actually runs
- # the exec'd child, not the original program...
- kill_child
}}
proc vfork_and_exec_child_follow_through_step {} {
@@ -197,6 +189,8 @@ proc vfork_and_exec_child_follow_through_step {} {
return 0
}
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
set test "step over vfork"
@@ -228,10 +222,6 @@ proc vfork_and_exec_child_follow_through_step {} {
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
-
- # Explicitly kill this child, or a subsequent rerun actually runs
- # the exec'd child, not the original program...
- kill_child
}}
proc tcatch_vfork_then_parent_follow {} {
@@ -239,6 +229,8 @@ proc tcatch_vfork_then_parent_follow {} {
global gdb_prompt
global srcfile
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
@@ -279,6 +271,8 @@ proc tcatch_vfork_then_child_follow {} {
global srcfile
global srcfile2
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
@@ -323,22 +317,22 @@ proc do_vfork_and_exec_tests {} {
# Check that vfork catchpoints are supported, as an indicator for whether
# vfork-following is supported.
- if [runto_main] then { check_vfork_catchpoints }
+ check_vfork_catchpoints
# Try following the parent process by stepping through a call to
# vfork. Do this without catchpoints.
- if [runto_main] then { vfork_parent_follow_through_step }
+ vfork_parent_follow_through_step
# Try following the parent process by setting a breakpoint on the
# other side of a vfork, and running to that point. Do this
# without catchpoints.
- if [runto_main] then { vfork_parent_follow_to_bp }
+ vfork_parent_follow_to_bp
# Try following the child process by just continuing through the
# vfork, and letting the parent's breakpoint on "main" be auto-
# magically reset in the child.
#
- if [runto_main] then { vfork_and_exec_child_follow_to_main_bp }
+ vfork_and_exec_child_follow_to_main_bp
# Try following the child process by stepping through a call to
# vfork. The child also executes an exec. Since the child cannot
@@ -347,15 +341,15 @@ proc do_vfork_and_exec_tests {} {
# recomputed in the exec'd child, the step through a vfork should
# land us in the "main" for the exec'd child, too.
#
- if [runto_main] then { vfork_and_exec_child_follow_through_step }
+ vfork_and_exec_child_follow_through_step
# Try catching a vfork, and stepping out to the parent.
#
- if [runto_main] then { tcatch_vfork_then_parent_follow }
+ tcatch_vfork_then_parent_follow
# Try catching a vfork, and stepping out to the child.
#
- if [runto_main] then { tcatch_vfork_then_child_follow }
+ tcatch_vfork_then_child_follow
# Test the ability to follow both child and parent of a vfork. Do
# this without catchpoints.
@@ -369,13 +363,6 @@ proc do_vfork_and_exec_tests {} {
#
}
-# Start with a fresh gdb
-clean_restart $testfile
-
-# The "Detaching..." and "Attaching..." messages may be hidden by
-# default.
-gdb_test_no_output "set verbose"
-
# This is a test of gdb's ability to follow the parent or child
# of a Unix vfork() system call. (The child will subsequently
# call a variant of a Unix exec() system call.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 7/8] foll-vfork.exp: Also test following vfork when the child exits.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
2012-10-25 17:42 ` [PATCH 2/8] foll-vfork.exp: Don't hard code line numbers Pedro Alves
2012-10-25 17:42 ` [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 8/8] Fix PR gdb/14766 - vfork child exit with "set follow-fork-mode child" broken Pedro Alves
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
foll-vfork.exp currently has tests for both following the vfork
parent, and the vfork child. However, the vfork shared region is done
with when either the child execs, or exits, and the tests only test
the exec variant. These events are handled with similar yet
not-quite-the-same code paths in GDB, so it's useful to add that
vector to the test matrix as well. (gdb/14766 is a case of a bug on
the exit path only. gdb/14762 is exposed by making the tests cover
the whole testing matrix.) The patch implements that by adding a new
test source based on foll-vfork.c that has been adjusted to have the
child _exit instead of exec. The follow-parent tests can all run with
either the exit or exec variant, using the same tcl procedure even
(with_test_prefix is used to distinguish the variants in gdb.sum).
Some of the follow-child tests can too, while others cannot -- the
one's that can't get special tcl procedures for each exec/exit
variant.
(I had originally developed this as a separate new .exp test file,
based on foll-vfork.exp, until I decided that it was better to merge
them.)
(This kfails both gdb/14762 and gdb/14766. The gdb/14762 kfail is
actually masked by gdb/14766. The next patch fixes gdb/14766, thus
exposing the gdb/14762 kfail...)
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork-exit.c: New file.
* gdb.base/foll-vfork.exp (top level): New file-describing
comment.
(vfork_child_follow_to_exit): New procedure.
(tcatch_vfork_then_child_follow): Rename as ...
(tcatch_vfork_then_child_follow_exec): ... this.
(tcatch_vfork_then_child_follow_exit): New procedure.
(do_vfork_and_follow_parent_tests): New procedure, factored out
from do_vfork_and_exec_tests.
(do_vfork_and_follow_child_tests_exec): Ditto.
(do_vfork_and_exec_tests): Delete.
(do_vfork_and_follow_child_tests_exit): New procedure.
(top level): Run tests with both the program that has the vfork
child execing, and the program has the vfork child exiting.
---
gdb/testsuite/gdb.base/foll-vfork-exit.c | 38 +++++++
gdb/testsuite/gdb.base/foll-vfork.exp | 155 +++++++++++++++++++++++++++---
2 files changed, 178 insertions(+), 15 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/foll-vfork-exit.c
diff --git a/gdb/testsuite/gdb.base/foll-vfork-exit.c b/gdb/testsuite/gdb.base/foll-vfork-exit.c
new file mode 100644
index 0000000..6aa8a5c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/foll-vfork-exit.c
@@ -0,0 +1,38 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1997, 1999, 2007-2012 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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/>. */
+
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main ()
+{
+ int pid;
+
+ pid = vfork ();
+ if (pid == 0)
+ {
+ printf ("I'm the child!\n");
+ _exit (0);
+ }
+ else
+ {
+ printf ("I'm the proud parent of child #%d!\n", pid);
+ }
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 31477ef..ca04cdc 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -13,6 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Various tests of gdb's ability to follow the parent or child of a
+# Unix vfork system call. A vfork parent is blocked until the child
+# 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
}
@@ -146,6 +151,31 @@ proc vfork_parent_follow_to_bp {} {
exec sleep 1
}}
+proc vfork_child_follow_to_exit {} {
+ with_test_prefix "vfork child follow, to exit" {
+ global gdb_prompt
+
+ setup_gdb
+
+ gdb_test_no_output "set follow-fork child"
+
+ set test "continue to child exit"
+ gdb_test_multiple "continue" $test {
+ -re "Couldn't get registers.*$gdb_prompt " {
+ setup_kfail "gdb/14766" *-*-*
+ fail "$test"
+ }
+ -re "Attaching after.* vfork to.*Detaching vfork parent .* after child exit.*$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
+ # any gdb_expected debugger output from a subsequent testpoint.
+ #
+ exec sleep 1
+}}
+
proc vfork_and_exec_child_follow_to_main_bp {} {
with_test_prefix "vfork and exec child follow, to main bp" {
global gdb_prompt
@@ -265,7 +295,7 @@ proc tcatch_vfork_then_parent_follow {} {
exec sleep 1
}}
-proc tcatch_vfork_then_child_follow {} {
+proc tcatch_vfork_then_child_follow_exec {} {
with_test_prefix "vfork child follow, finish after tcatch vfork" {
global gdb_prompt
global srcfile
@@ -312,12 +342,56 @@ proc tcatch_vfork_then_child_follow {} {
exec sleep 1
}}
-proc do_vfork_and_exec_tests {} {
+proc tcatch_vfork_then_child_follow_exit {} {
+ with_test_prefix "vfork child follow, finish after tcatch vfork" {
global gdb_prompt
+ global srcfile
+
+ setup_gdb
+
+ gdb_test_no_output "set follow-fork child"
+
+ 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
+ }
+ }
+
+ set test "finish"
+ gdb_test_multiple "finish" $test {
+ -re "Couldn't get registers.*$gdb_prompt " {
+ setup_kfail "gdb/14766" *-*-*
+ fail "$test "
+ }
+ -re "Run till exit from.*vfork.*exited normally.*$gdb_prompt " {
+ setup_kfail "gdb/14762" *-*-*
+ fail $test
+ }
+ -re "Run till exit from.*vfork.*pid = vfork \\(\\).*$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
+ }
+ }
+ # The parent has been detached; allow time for any output it might
+ # generate to arrive, so that output doesn't get confused with
+ # any expected debugger output from a subsequent testpoint.
+ #
+ exec sleep 1
+}}
- # Check that vfork catchpoints are supported, as an indicator for whether
- # vfork-following is supported.
- check_vfork_catchpoints
+proc do_vfork_and_follow_parent_tests {} {
+ global gdb_prompt
# Try following the parent process by stepping through a call to
# vfork. Do this without catchpoints.
@@ -328,6 +402,12 @@ proc do_vfork_and_exec_tests {} {
# without catchpoints.
vfork_parent_follow_to_bp
+ # Try catching a vfork, and stepping out to the parent.
+ #
+ tcatch_vfork_then_parent_follow
+}
+
+proc do_vfork_and_follow_child_tests_exec {} {
# Try following the child process by just continuing through the
# vfork, and letting the parent's breakpoint on "main" be auto-
# magically reset in the child.
@@ -343,13 +423,9 @@ proc do_vfork_and_exec_tests {} {
#
vfork_and_exec_child_follow_through_step
- # Try catching a vfork, and stepping out to the parent.
- #
- tcatch_vfork_then_parent_follow
-
# Try catching a vfork, and stepping out to the child.
#
- tcatch_vfork_then_child_follow
+ tcatch_vfork_then_child_follow_exec
# Test the ability to follow both child and parent of a vfork. Do
# this without catchpoints.
@@ -363,11 +439,60 @@ proc do_vfork_and_exec_tests {} {
#
}
-# This is a test of gdb's ability to follow the parent or child
-# of a Unix vfork() system call. (The child will subsequently
-# call a variant of a Unix exec() system call.)
-#
-do_vfork_and_exec_tests
+proc do_vfork_and_follow_child_tests_exit {} {
+ # Try following the child process by just continuing through the
+ # vfork, and letting the child exit.
+ #
+ vfork_child_follow_to_exit
+
+ # Try catching a vfork, and stepping out to the child.
+ #
+ tcatch_vfork_then_child_follow_exit
+}
+
+with_test_prefix "check vfork support" {
+ # Check that vfork catchpoints are supported, as an indicator for
+ # whether vfork-following is supported.
+ check_vfork_catchpoints
+}
+
+# Follow parent and follow child vfork tests with a child that execs.
+with_test_prefix "exec" {
+ # These are tests of gdb's ability to follow the parent of a Unix
+ # vfork system call. The child will subsequently call a variant
+ # of the Unix exec system call.
+ do_vfork_and_follow_parent_tests
+
+ # These are tests of gdb's ability to follow the child of a Unix
+ # vfork system call. The child will subsequently call a variant
+ # of a Unix exec system call.
+ #
+ do_vfork_and_follow_child_tests_exec
+}
+
+# Switch to test the case of the child exiting. We can't use
+# standard_testfile here because we don't want to overwrite the binary
+# of the previous tests.
+set testfile "foll-vfork-exit"
+set srcfile ${testfile}.c
+set binfile [standard_output_file ${testfile}]
+
+if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
+ untested "failed to build $testfile"
+ return
+}
+
+# Follow parent and follow child vfork tests with a child that exits.
+with_test_prefix "exit" {
+ # These are tests of gdb's ability to follow the parent of a Unix
+ # vfork system call. The child will subsequently exit.
+ do_vfork_and_follow_parent_tests
+
+ # These are tests of gdb's ability to follow the child of a Unix
+ # vfork system call. The child will subsequently exit.
+ #
+ do_vfork_and_follow_child_tests_exit
+}
set timeout $oldtimeout
return 0
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 8/8] Fix PR gdb/14766 - vfork child exit with "set follow-fork-mode child" broken.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
` (2 preceding siblings ...)
2012-10-25 17:42 ` [PATCH 7/8] foll-vfork.exp: Also test following vfork when the child exits Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-25 17:49 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 5/8] foll-vfork.exp: Use with_test_prefix Pedro Alves
` (4 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
If "set detach-on-fork" is off (which it is by default), and we follow
the vfork child, we don't actually detach from the parent at vfork
time, but instead hold on to it until the child is done with the
shared memory region. IOW, until the child execs or exits. There's a
single function that handles all that work for both child execs and
exits, handle_vfork_child_exec_or_exit. When that function goes about
detaching the parent, it tries to preserve the selected inferior (the
child), but while doing so, it is also trying to restore the selected
thread (as pointed at by inferior_ptid). That makes sense for execs,
but not so for exits. For exits, inferior_ptid, which has been
switched to the event ptid, does not point at a valid thread anymore.
Instead it just points at the process's pid. The result is:
(gdb) r
Starting program:
/home/pedro/gdb/mygit/build/gdb/testsuite/gdb.base/foll-vfork-exit
[New process 4673]
I'm the child!
I'm the proud parent of child #4673!
Couldn't get registers: No such process.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Couldn't get registers: No such process.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Couldn't get registers: No such process.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(gdb)
The fix is not try to restore the thread, but just the inferior.
The bit in tcatch_vfork_then_child_follow_exit that kfails this PR is
just removed, as there's a specific test for this bug in the file. It
was put there originally as this bug masked the gdb/14762 bug, and
thus the related gdb/14762 kfail in
tcatch_vfork_then_child_follow_exit was not reached.
gdb/
2012-10-25 Pedro Alves <palves@redhat.com>
PR gdb/14766
* infrun.c (handle_inferior_event)
<TARGET_WAITKIND_EXITED/TARGET_WAITKIND_SIGNALLED>: Switch to
null_ptid before handling a vfork child exec or exit. Switch to
the event ptid afterwards.
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
PR gdb/14766
* gdb.base/foll-vfork.exp (vfork_child_follow_to_exit): Remove
setup_kfail.
(tcatch_vfork_then_child_follow_exit): No longer expect "Couldn't
get registers".
---
gdb/testsuite/gdb.base/foll-vfork.exp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 0caa1ac..de9b137 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -663,7 +663,16 @@ handle_vfork_child_exec_or_exit (int exec)
/* follow-fork child, detach-on-fork on. */
- old_chain = make_cleanup_restore_current_thread ();
+ if (!exec)
+ {
+ /* If we're handling a child exit, then inferior_ptid
+ points at the inferior's pid, not to a thread. */
+ old_chain = save_inferior_ptid ();
+ save_current_program_space ();
+ save_current_inferior ();
+ }
+ else
+ old_chain = save_current_space_and_thread ();
/* We're letting loose of the parent. */
tp = any_live_thread_of_process (inf->vfork_parent->pid);
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index ca04cdc..12f7ec7 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -162,7 +162,7 @@ proc vfork_child_follow_to_exit {} {
set test "continue to child exit"
gdb_test_multiple "continue" $test {
-re "Couldn't get registers.*$gdb_prompt " {
- setup_kfail "gdb/14766" *-*-*
+ # PR gdb/14766
fail "$test"
}
-re "Attaching after.* vfork to.*Detaching vfork parent .* after child exit.*$gdb_prompt " {
@@ -367,10 +367,6 @@ proc tcatch_vfork_then_child_follow_exit {} {
set test "finish"
gdb_test_multiple "finish" $test {
- -re "Couldn't get registers.*$gdb_prompt " {
- setup_kfail "gdb/14766" *-*-*
- fail "$test "
- }
-re "Run till exit from.*vfork.*exited normally.*$gdb_prompt " {
setup_kfail "gdb/14762" *-*-*
fail $test
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 5/8] foll-vfork.exp: Use with_test_prefix.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
` (3 preceding siblings ...)
2012-10-25 17:42 ` [PATCH 8/8] Fix PR gdb/14766 - vfork child exit with "set follow-fork-mode child" broken Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 3/8] foll-vfork.exp: Expose more testing on non-HP/UX targets Pedro Alves
` (3 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
Looking at a FAIL in this test (caused by some other changes I was
working on), I had some trouble matching the gdb.sum output with the
test's code. The gdb.sum output currently looks like:
PASS: gdb.base/foll-vfork.exp: set verbose
PASS: gdb.base/foll-vfork.exp: insert first vfork catchpoint
PASS: gdb.base/foll-vfork.exp: continue to first vfork catchpoint
PASS: gdb.base/foll-vfork.exp: set follow-fork parent, vfork through step
PASS: gdb.base/foll-vfork.exp: vfork parent follow, through step
PASS: gdb.base/foll-vfork.exp: set follow-fork parent, vfork to bp
PASS: gdb.base/foll-vfork.exp: break, vfork to bp
PASS: gdb.base/foll-vfork.exp: vfork parent follow, to bp
PASS: gdb.base/foll-vfork.exp: set follow-fork child, vfork and exec to main bp
PASS: gdb.base/foll-vfork.exp: vfork and exec child follow, to main bp
PASS: gdb.base/foll-vfork.exp: set follow-fork child, vfork and exec through step
PASS: gdb.base/foll-vfork.exp: vfork and exec child follow, through step
PASS: gdb.base/foll-vfork.exp: set follow-fork parent, tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork parent follow, set tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork parent follow, tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork parent follow, finish after tcatch vfork
PASS: gdb.base/foll-vfork.exp: set follow-fork child, tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork child follow, set tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork child follow, tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork child follow, finish after tcatch vfork (followed exec)
This patch changes the tests to use with_test_prefix instead of
hardcoding a prefix in gdb_test/gdb_test_multiple (and being
inconsistent). We now get:
PASS: gdb.base/foll-vfork.exp: set verbose
PASS: gdb.base/foll-vfork.exp: insert first vfork catchpoint
PASS: gdb.base/foll-vfork.exp: continue to first vfork catchpoint
PASS: gdb.base/foll-vfork.exp: vfork parent follow, through step: set follow-fork parent
PASS: gdb.base/foll-vfork.exp: vfork parent follow, through step: step
PASS: gdb.base/foll-vfork.exp: vfork parent follow, to bp: set follow-fork parent
PASS: gdb.base/foll-vfork.exp: vfork parent follow, to bp: break, vfork to bp
PASS: gdb.base/foll-vfork.exp: vfork parent follow, to bp: continue to bp
PASS: gdb.base/foll-vfork.exp: vfork and exec child follow, to main bp: set follow-fork child
PASS: gdb.base/foll-vfork.exp: vfork and exec child follow, to main bp: continue to bp
PASS: gdb.base/foll-vfork.exp: vfork and exec child follow, through step: set follow-fork child
PASS: gdb.base/foll-vfork.exp: vfork and exec child follow, through step: step over vfork
PASS: gdb.base/foll-vfork.exp: vfork parent follow, finish after tcatch vfork: set follow-fork parent
PASS: gdb.base/foll-vfork.exp: vfork parent follow, finish after tcatch vfork: tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork parent follow, finish after tcatch vfork: continue to vfork
PASS: gdb.base/foll-vfork.exp: vfork parent follow, finish after tcatch vfork: finish
PASS: gdb.base/foll-vfork.exp: vfork child follow, finish after tcatch vfork: set follow-fork child
PASS: gdb.base/foll-vfork.exp: vfork child follow, finish after tcatch vfork: tcatch vfork
PASS: gdb.base/foll-vfork.exp: vfork child follow, finish after tcatch vfork: continue to vfork
PASS: gdb.base/foll-vfork.exp: vfork child follow, finish after tcatch vfork: finish (followed exec)
Split off to a separate patch because this is the first change in the
series that actually changes gdb.sum output.
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.exp (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_parent_follow, tcatch_vfork_then_child_follow):
Use with_test_prefix.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 66 +++++++++++++++------------------
1 file changed, 29 insertions(+), 37 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 54f5971..f978f8c 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -84,15 +84,15 @@ proc check_vfork_catchpoints {} {
}
proc vfork_parent_follow_through_step {} {
+ with_test_prefix "vfork parent follow, through step" {
global gdb_prompt
- gdb_test_no_output "set follow-fork parent" \
- "set follow-fork parent, vfork through step"
+ gdb_test_no_output "set follow-fork parent"
- set test "vfork parent follow, through step"
+ set test "step"
gdb_test_multiple "next" $test {
-re "Detaching after fork from.*if \\(pid == 0\\).*$gdb_prompt " {
- pass "vfork parent follow, through step"
+ pass $test
}
}
# The child has been detached; allow time for any output it might
@@ -100,19 +100,19 @@ proc vfork_parent_follow_through_step {} {
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
-}
+}}
proc vfork_parent_follow_to_bp {} {
+ with_test_prefix "vfork parent follow, to bp" {
global gdb_prompt
global srcfile
- gdb_test_no_output "set follow-fork parent" \
- "set follow-fork parent, vfork to bp"
+ gdb_test_no_output "set follow-fork parent"
set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
gdb_test "break ${srcfile}:${bp_location}" ".*" "break, vfork to bp"
- set test "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 " {
pass $test
@@ -123,7 +123,7 @@ proc vfork_parent_follow_to_bp {} {
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
-}
+}}
# Kill child and reload symbols.
proc kill_child {} {
@@ -153,16 +153,15 @@ proc kill_child {} {
}
proc vfork_and_exec_child_follow_to_main_bp {} {
+ with_test_prefix "vfork and exec child follow, to main bp" {
global gdb_prompt
global srcfile2
- gdb_test_no_output \
- "set follow-fork child" \
- "set follow-fork child, vfork and exec to main bp"
+ gdb_test_no_output "set follow-fork child"
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
- set test "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 " {
pass $test
@@ -177,9 +176,10 @@ 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...
kill_child
-}
+}}
proc vfork_and_exec_child_follow_through_step {} {
+ with_test_prefix "vfork and exec child follow, through step" {
global gdb_prompt
global srcfile2
@@ -197,11 +197,9 @@ proc vfork_and_exec_child_follow_through_step {} {
return 0
}
- gdb_test_no_output \
- "set follow-fork child" \
- "set follow-fork child, vfork and exec through step"
+ gdb_test_no_output "set follow-fork child"
- set test "vfork and exec child follow, through step"
+ 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
@@ -234,23 +232,20 @@ 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...
kill_child
-}
+}}
proc tcatch_vfork_then_parent_follow {} {
+ with_test_prefix "vfork parent follow, finish after tcatch vfork" {
global gdb_prompt
global srcfile
- gdb_test_no_output \
- "set follow-fork parent" \
- "set follow-fork parent, tcatch vfork"
+ gdb_test_no_output "set follow-fork parent"
- gdb_test "tcatch vfork" \
- "Catchpoint .*(vfork).*" \
- "vfork parent follow, set tcatch vfork"
+ 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 "vfork parent follow, tcatch 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
@@ -261,7 +256,7 @@ proc tcatch_vfork_then_parent_follow {} {
}
set linenum [gdb_get_line_number "pid = vfork ();"]
- set test "vfork parent follow, finish after tcatch vfork"
+ set test "finish"
gdb_test_multiple "finish" $test {
-re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:${linenum}.*$gdb_prompt " {
pass $test
@@ -276,24 +271,21 @@ proc tcatch_vfork_then_parent_follow {} {
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
-}
+}}
proc tcatch_vfork_then_child_follow {} {
+ with_test_prefix "vfork child follow, finish after tcatch vfork" {
global gdb_prompt
global srcfile
global srcfile2
- gdb_test_no_output \
- "set follow-fork child" \
- "set follow-fork child, tcatch vfork"
+ gdb_test_no_output "set follow-fork child"
- gdb_test "tcatch vfork" \
- "Catchpoint .*(vfork).*" \
- "vfork child follow, set tcatch vfork"
+ 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 "vfork child follow, tcatch vfork"
+ set test "continue to vfork"
gdb_test_multiple "continue" $test {
-re "vfork \\(\\) at .*$gdb_prompt $" {
pass $test
@@ -306,7 +298,7 @@ proc tcatch_vfork_then_child_follow {} {
set linenum1 [gdb_get_line_number "pid = vfork ();"]
set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
- set test "vfork child follow, finish after tcatch vfork"
+ set test "finish"
gdb_test_multiple "finish" $test {
-re "Run till exit from.*vfork.*${srcfile}:${linenum1}.*$gdb_prompt " {
pass $test
@@ -324,7 +316,7 @@ proc tcatch_vfork_then_child_follow {} {
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
-}
+}}
proc do_vfork_and_exec_tests {} {
global gdb_prompt
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 3/8] foll-vfork.exp: Expose more testing on non-HP/UX targets
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
` (4 preceding siblings ...)
2012-10-25 17:42 ` [PATCH 5/8] foll-vfork.exp: Use with_test_prefix Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 4/8] foll-vfork.c/vforked-prog.c: Add copyright headers Pedro Alves
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
Well, exposes more to Linux, since we have at the top:
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
continue
}
The vfork_and_exec_child_follow_through_step procedure is about
following the child over a "next". This is currently disabled on non
HP/UX targets, but it's a useful test to run. AFAICS from the test,
HP/UX can't debug the vfork child until it execs or exits. The Linux
kernel can, so the test is adjusted to expect the ideal behavior out
of non HP/UX targets (and we get that right on Linux).
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.exp
(vfork_and_exec_child_follow_through_step): Don't skip on
non-HP/UX targets. Expect the next to only step one line on
non-HP/UX targets, rather than stopping only after the exec.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 47 +++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 67d077d..54f5971 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -183,15 +183,17 @@ proc vfork_and_exec_child_follow_through_step {} {
global gdb_prompt
global srcfile2
-# 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.
-#
- if { ![istarget "hppa*-*-hpux11.*"] } {
- verbose "vfork child-following next test ignored for non-hppa or pre-HP/UX-10.30 targets."
+ 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
}
@@ -200,11 +202,28 @@ proc vfork_and_exec_child_follow_through_step {} {
"set follow-fork child, vfork and exec through step"
set test "vfork and exec child follow, through step"
- 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"
- }
+ 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 parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 4/8] foll-vfork.c/vforked-prog.c: Add copyright headers.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
` (5 preceding siblings ...)
2012-10-25 17:42 ` [PATCH 3/8] foll-vfork.exp: Expose more testing on non-HP/UX targets Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 1/8] foll-vfork.exp: Modernize Pedro Alves
2012-10-30 20:50 ` [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Tom Tromey
8 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
I wanted to copy and adjust foll-vfork.c for a new test, and noticed
that those files miss copyright headers. This patch adds them. To
know which years to use, I went back in history and saw that these
files were added at the same time as foll-vfork.exp (gdb 4.8). I then
just copied the years from that file.
gdb/testuite/
2012-10-25 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.c: Add copyright header.
* gdb.base/vforked-prog.c: Add copyright header.
---
gdb/testsuite/gdb.base/foll-vfork.c | 17 +++++++++++++++++
gdb/testsuite/gdb.base/vforked-prog.c | 17 +++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c
index 3c7fab5..3bb37ad 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.c
+++ b/gdb/testsuite/gdb.base/foll-vfork.c
@@ -1,3 +1,20 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1997, 1999, 2007-2012 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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/>. */
+
#include <stdio.h>
#include <unistd.h>
diff --git a/gdb/testsuite/gdb.base/vforked-prog.c b/gdb/testsuite/gdb.base/vforked-prog.c
index 27504db..6fffe5f 100644
--- a/gdb/testsuite/gdb.base/vforked-prog.c
+++ b/gdb/testsuite/gdb.base/vforked-prog.c
@@ -1,3 +1,20 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1997, 1999, 2007-2012 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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/>. */
+
#include <stdio.h>
#ifdef PROTOTYPES
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 1/8] foll-vfork.exp: Modernize.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
` (6 preceding siblings ...)
2012-10-25 17:42 ` [PATCH 4/8] foll-vfork.c/vforked-prog.c: Add copyright headers Pedro Alves
@ 2012-10-25 17:42 ` Pedro Alves
2012-10-30 20:50 ` [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Tom Tromey
8 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2012-10-25 17:42 UTC (permalink / raw)
To: gdb-patches
I wanted to extend this file, but it is a bit crufty... Clean it up
first.
gdb/testsuite/
2012-10-25 Pedro Alves <palves@redhat.com>
Modernise.
* 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.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 294 ++++++++++++++-------------------
1 file 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.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it.
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
` (7 preceding siblings ...)
2012-10-25 17:42 ` [PATCH 1/8] foll-vfork.exp: Modernize Pedro Alves
@ 2012-10-30 20:50 ` Tom Tromey
2012-11-02 18:15 ` Pedro Alves
8 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2012-10-30 20:50 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> It starts by modernizing foll-vfork.exp, and then extending it to
Pedro> cover more cases, exposing the bug on hardware step targets (like
Pedro> amd64 GNU/Linux).
FWIW, I skimmed this series and it seemed fine to me.
Tom
^ permalink raw reply [flat|nested] 13+ messages in thread