-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2016 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
standard_testfile
-# We need to use TCL's exec to get the pid.
-if [is_remote target] then {
- return 0
-}
-
load_lib gdb-python.exp
load_lib prompt.exp
"prompt_hook argument is default prompt. 2"
gdb_exit
-# 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; }" ]
+if {![can_spawn_for_attach]} {
+ set GDBFLAGS $saved_gdbflags
+ return 0
}
-set GDBFLAGS [concat $tmp_gdbflags " -ex \"set target-async on\""]
-set GDBFLAGS [concat $GDBFLAGS " -ex \"set pagination off\""]
+set test_spawn_id [spawn_wait_for_attach $binfile]
+set testpid [spawn_id_get_pid $test_spawn_id]
+
+set GDBFLAGS [concat $tmp_gdbflags " -ex \"set pagination off\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"set editing on\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"attach $testpid\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"continue&\""]
"prompt_hook argument is default prompt. 3"
gdb_exit
-set GDBFLAGS [concat $tmp_gdbflags " -ex \"set target-async on\""]
-set GDBFLAGS [concat $GDBFLAGS " -ex \"set pagination off\""]
+set GDBFLAGS [concat $tmp_gdbflags " -ex \"set pagination off\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"set editing on\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"attach $testpid\""]
set GDBFLAGS [concat $GDBFLAGS " -ex \"interrupt\""]
gdb_exit
set GDBFLAGS $saved_gdbflags
+kill_wait_spawned_process $test_spawn_id
return 0