skip "attach" tests when testing against stub-like targets
authorPedro Alves <palves@redhat.com>
Fri, 9 Jan 2015 11:04:19 +0000 (11:04 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 9 Jan 2015 11:04:19 +0000 (11:04 +0000)
We already skip "attach" tests if the target board is remote, in
dejagnu's sense, as we use TCL's exec to spawn the program on the
build machine.  We should also skip these tests if testing with
"target remote" or other stub-like targets where "attach" doesn't make
sense.

Add a helper procedure that centralizes the checks a test that needs
to spawn a program for testing "attach" and make all test files that
use spawn_wait_for_attach check it.

gdb/testsuite/
2015-01-09  Pedro Alves  <palves@redhat.com>

* lib/gdb.exp (can_spawn_for_attach): New procedure.
(spawn_wait_for_attach): Error out if can_spawn_for_attach returns
false.
* gdb.base/attach.exp: Use can_spawn_for_attach instead of
checking whether the target board is remote.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Use can_spawn_for_attach before the
tests that need to attach, instead of checking whether the target
board is remote at the top of the file.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/attach.exp
gdb/testsuite/gdb.base/solib-overlap.exp
gdb/testsuite/gdb.multi/multi-attach.exp
gdb/testsuite/gdb.python/py-prompt.exp
gdb/testsuite/gdb.python/py-sync-interp.exp
gdb/testsuite/gdb.server/ext-attach.exp
gdb/testsuite/lib/gdb.exp

index 2154036071badb966d21cf28520bd8810108bcee..1a676409e45a88504f3f5f753167db70c234dce5 100644 (file)
@@ -1,3 +1,17 @@
+2015-01-09  Pedro Alves  <palves@redhat.com>
+
+       * lib/gdb.exp (can_spawn_for_attach): New procedure.
+       (spawn_wait_for_attach): Error out if can_spawn_for_attach returns
+       false.
+       * gdb.base/attach.exp: Use can_spawn_for_attach instead of
+       checking whether the target board is remote.
+       * gdb.multi/multi-attach.exp: Likewise.
+       * gdb.python/py-sync-interp.exp: Likewise.
+       * gdb.server/ext-attach.exp: Likewise.
+       * gdb.python/py-prompt.exp: Use can_spawn_for_attach before the
+       tests that need to attach, instead of checking whether the target
+       board is remote at the top of the file.
+
 2015-01-08  Yao Qi  <yao@codesourcery.com>
 
        * gdb.trace/entry-values.exp: Set call_insn for MIPS target.
index 7253bad3bccbb208956c5f310f01ec7422363f7a..38b19b5624e75766a42ab97dd4a81554ebd16847 100644 (file)
@@ -25,8 +25,7 @@ if { [istarget "hppa*-*-hpux*"] } {
     return 0
 }
 
-# are we on a target board
-if [is_remote target] then {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
index fbe4b85df21b07646190cb465f0bb49f59451a7d..ad96d02b82e28e93a443659dd4d7c38fe0a9f9f9 100644 (file)
@@ -31,8 +31,7 @@ if [skip_shlib_tests] {
     return 0
 }
 
-# Are we on a target board?  It is required for attaching to a process.
-if [is_remote target] {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
index 28b7fbef7df50a49841eb70e1841ec04fce49b8c..8a7bb089fbcb2dcec4cdbfac6904f12352599932 100644 (file)
@@ -19,8 +19,7 @@
 
 standard_testfile
 
-# We need to use TCL's exec to get the pid.
-if [is_remote target] then {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
index 28f5e9aa1043cf565698a213c1cedb6a429ecd5c..55f0f5966ebd5f86dc9781ff05b42f94bb233638 100644 (file)
 
 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
 
@@ -80,6 +75,10 @@ gdb_test "python print (\"'\" + str(p\[0\]) + \"'\")" "'$gdb_prompt_fail '" \
         "prompt_hook argument is default prompt. 2"
 gdb_exit
 
+if {![can_spawn_for_attach]} {
+    return 0
+}
+
 set testpid [spawn_wait_for_attach $binfile]
 
 set GDBFLAGS [concat $tmp_gdbflags " -ex \"set pagination off\""]
index 595db3d950a1bf4d6eaad7a917e7cc27a7b65440..0ea31104be9f171047bca8b26d2b02e873b76a5a 100644 (file)
@@ -20,8 +20,7 @@
 
 standard_testfile
 
-# We need to use TCL's exec to get the pid.
-if [is_remote target] then {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
index a1beb6c1756a2934571802159b574b06aa27fbcf..f3cbcf65e76adca64a7cf914b89cda947ff42422 100644 (file)
@@ -26,8 +26,7 @@ if { [skip_gdbserver_tests] } {
     return 0
 }
 
-# We need to use TCL's exec to get the pid.
-if [is_remote target] then {
+if {![can_spawn_for_attach]} {
     return 0
 }
 
index dcc2f942975c1d91ad5fe50b1acb8aef0c6fe319..fc6bc83363b31f9bbc7b82f4258a1592791a8522 100644 (file)
@@ -3413,12 +3413,39 @@ proc gdb_exit { } {
     catch default_gdb_exit
 }
 
+# Return true if we can spawn a program on the target and attach to
+# it.
+
+proc can_spawn_for_attach { } {
+    # We use TCL's exec to get the inferior's pid.
+    if [is_remote target] then {
+       return 0
+    }
+
+    # The "attach" command doesn't make sense when the target is
+    # stub-like, where GDB finds the program already started on
+    # initial connection.
+    if {[target_info exists use_gdb_stub]} {
+       return 0
+    }
+
+    # Assume yes.
+    return 1
+}
+
 # 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.
+# It's a test error to call this when [can_spawn_for_attach] is false.
 
 proc spawn_wait_for_attach { executable_list } {
     set pid_list {}
 
+    if ![can_spawn_for_attach] {
+       # The caller should have checked can_spawn_for_attach itself
+       # before getting here.
+       error "can't spawn for attach with this target/board"
+    }
+
     foreach {executable} $executable_list {
        lappend pid_list [eval exec $executable &]
     }
This page took 0.037241 seconds and 4 git commands to generate.