summaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/gdb.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/lib/gdb.exp')
-rw-r--r--gdb/testsuite/lib/gdb.exp25
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 82242f4640e..274cad2fe35 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3324,6 +3324,31 @@ proc gdb_exit { } {
catch default_gdb_exit
}
+# Start a set of programs running and then wait for a bit, to be sure
+# that they can be attached to. Return a list of the processes' PIDs.
+
+proc spawn_wait_for_attach { executable_list } {
+ set pid_list {}
+
+ foreach {executable} $executable_list {
+ lappend pid_list [eval exec $executable &]
+ }
+
+ sleep 2
+
+ if { [istarget "*-*-cygwin*"] } {
+ for {set i 0} {$i < [llength $pid_list]} {incr i} {
+ # testpid is the Cygwin PID, GDB uses the Windows PID,
+ # which might be different due to the way fork/exec works.
+ set testpid [lindex $pid_list $i]
+ set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
+ set pid_list [lreplace $pid_list $i $i $testpid]
+ }
+ }
+
+ return $pid_list
+}
+
#
# gdb_load_cmd -- load a file into the debugger.
# ARGS - additional args to load command.