aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/attach.exp
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2014-09-11 13:04:14 +0100
committerPedro Alves <palves@redhat.com>2014-09-11 13:04:14 +0100
commit4c92ff2c35392b68ee9172af979483b32aaa3d7b (patch)
treed0e6d784dc0924ee5c6aa2e5b9aa38cd56e2f4a0 /gdb/testsuite/gdb.base/attach.exp
parentbd9269f70c70b1218b0eb73a6f487d6ca481e5ac (diff)
downloadgdb-4c92ff2c35392b68ee9172af979483b32aaa3d7b.zip
gdb-4c92ff2c35392b68ee9172af979483b32aaa3d7b.tar.gz
gdb-4c92ff2c35392b68ee9172af979483b32aaa3d7b.tar.bz2
testsuite: refactor spawn and wait for attach
Several places in the testsuite have a copy of a snippet of code that spawns a test program, waits a bit, and then does some PID munging for Cygwin. This is in order to have GDB attach to the spawned program. This refactors all that to a common procedure. (multi-attach.exp wants to spawn multiple processes, so this makes the new procedure's interface work with lists.) Tested on x86_64 Fedora 20. gdb/testsuite/ChangeLog: 2014-09-11 Pedro Alves <palves@redhat.com> * lib/gdb.exp (spawn_wait_for_attach): New procedure. * gdb.base/attach.exp (do_attach_tests, do_call_attach_tests) (do_command_attach_tests): Use spawn_wait_for_attach. * gdb.base/solib-overlap.exp: Likewise. * gdb.multi/multi-attach.exp: Likewise. * gdb.python/py-prompt.exp: Likewise. * gdb.python/py-sync-interp.exp: Likewise. * gdb.server/ext-attach.exp: Likewise.
Diffstat (limited to 'gdb/testsuite/gdb.base/attach.exp')
-rw-r--r--gdb/testsuite/gdb.base/attach.exp41
1 files changed, 4 insertions, 37 deletions
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index 9714c29..a20c51a 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -70,13 +70,7 @@ proc do_attach_tests {} {
# Start the program running and then wait for a bit, to be sure
# that it can be attached to.
- set testpid [eval exec $binfile &]
- exec sleep 2
- if { [istarget "*-*-cygwin*"] } {
- # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
- # different due to the way fork/exec works.
- set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
- }
+ set testpid [spawn_wait_for_attach $binfile]
# Verify that we cannot attach to nonsense.
@@ -279,16 +273,7 @@ proc do_attach_tests {} {
remote_exec build "kill -9 ${testpid}"
- # Start the program running and then wait for a bit, to be sure
- # that it can be attached to.
-
- set testpid [eval exec $binfile &]
- exec sleep 2
- if { [istarget "*-*-cygwin*"] } {
- # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
- # different due to the way fork/exec works.
- set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
- }
+ set testpid [spawn_wait_for_attach $binfile]
# Verify that we can attach to the process, and find its a.out
# when we're cd'd to some directory that doesn't contain the
@@ -335,16 +320,7 @@ proc do_call_attach_tests {} {
global gdb_prompt
global binfile2
- # Start the program running and then wait for a bit, to be sure
- # that it can be attached to.
-
- set testpid [eval exec $binfile2 &]
- exec sleep 2
- if { [istarget "*-*-cygwin*"] } {
- # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
- # different due to the way fork/exec works.
- set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
- }
+ set testpid [spawn_wait_for_attach $binfile2]
# Attach
@@ -397,16 +373,7 @@ proc do_command_attach_tests {} {
return 0
}
- # Start the program running and then wait for a bit, to be sure
- # that it can be attached to.
-
- set testpid [eval exec $binfile &]
- exec sleep 2
- if { [istarget "*-*-cygwin*"] } {
- # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
- # different due to the way fork/exec works.
- set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
- }
+ set testpid [spawn_wait_for_attach $binfile]
gdb_exit
if $verbose>1 then {