This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2] GDB test suite: Add helper for locating core files
- From: Pedro Alves <palves at redhat dot com>
- To: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>, Kevin Buettner <kevinb at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 12 Oct 2017 17:47:55 +0100
- Subject: Re: [PATCH 1/2] GDB test suite: Add helper for locating core files
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11C5615565
- References: <1505760152-28775-1-git-send-email-arnez@linux.vnet.ibm.com> <1505760152-28775-2-git-send-email-arnez@linux.vnet.ibm.com> <20171007094545.1bba5c51@pinnacle.lan> <m31smcp3b6.fsf@oc1027705133.ibm.com> <a02b8961-d8c3-a0a9-9887-23a24e63962d@redhat.com>
On 10/12/2017 02:47 PM, Pedro Alves wrote:
> On 10/09/2017 07:46 PM, Andreas Arnez wrote:
>
>> @@ -5883,7 +5883,7 @@ proc run_and_get_core {binfile {arg ""}} {
>> # specified. Return that path name, or "" if no core file was found.
>>
>> proc find_core {binfile coredir {destcore ""}} {
>> - if {[is_remote target]} {
>> + if {![isnative]} {
>> warning "Can not access remote core file."
>> return ""
>> }
>
> This seems incorrect to me. "isnative" only checks
> if the build and target _triplets_ are the same. So
> foo-linux-gnu gdb x foo-linux-gnu gdbserver on separate
> machine still returns isnative==true.
>
> I think the real problem is that the native-gdbserver board
> returns true to is_remote, when I think it shouldn't.
>
> Doing that alone results in fallout in the testsuite, of
> course. I'm seeing if fixing it is doable.
It's doable. Below's what I have. This exposed a number of
tests that were skipped for stale reasons.
The new "set cwd" command helps with this, which is nice
in the "I love it when a plan comes together" sense. :-)
I should probably split this up and submit in pieces.
>From 111e58e1310450539f1b1840666b3c2200e2364f Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 12 Oct 2017 14:45:57 +0100
Subject: [PATCH] native-gdbserver no longer is_remote and fix fallout
---
gdb/testsuite/boards/gdbserver-base.exp | 8 +
gdb/testsuite/boards/native-extended-gdbserver.exp | 8 -
gdb/testsuite/gdb.base/annota1.exp | 8 +-
gdb/testsuite/gdb.base/annota3.exp | 8 +-
gdb/testsuite/gdb.base/argv0-symlink.exp | 5 +-
gdb/testsuite/gdb.base/auxv.exp | 11 +-
gdb/testsuite/gdb.base/catch-fork-static.exp | 4 -
gdb/testsuite/gdb.base/checkpoint.exp | 10 +-
gdb/testsuite/gdb.base/corefile.exp | 16 +-
gdb/testsuite/gdb.base/dprintf-non-stop.exp | 6 -
gdb/testsuite/gdb.base/find-unmapped.exp | 3 +-
gdb/testsuite/gdb.base/inferior-died.exp | 13 +-
gdb/testsuite/gdb.base/label.exp | 6 -
gdb/testsuite/gdb.base/remote.exp | 7 +-
gdb/testsuite/gdb.base/reread.exp | 68 +++----
gdb/testsuite/gdb.base/scope.exp | 15 +-
gdb/testsuite/gdb.base/shlib-call.exp | 26 +--
gdb/testsuite/gdb.base/solib-nodir.exp | 13 +-
gdb/testsuite/gdb.base/solib-search.exp | 12 +-
gdb/testsuite/gdb.base/term.exp | 4 +-
gdb/testsuite/gdb.base/testenv.c | 6 +
gdb/testsuite/gdb.base/testenv.exp | 206 ++++++++++++++-------
gdb/testsuite/gdb.base/valgrind-db-attach.exp | 4 +-
gdb/testsuite/gdb.base/valgrind-disp-step.exp | 5 -
gdb/testsuite/gdb.base/valgrind-infcall.exp | 5 -
gdb/testsuite/gdb.cp/annota2.exp | 8 +-
gdb/testsuite/gdb.cp/annota3.exp | 8 +-
gdb/testsuite/gdb.multi/bkpt-multi-exec.exp | 2 +-
gdb/testsuite/gdb.python/py-evsignal.exp | 3 +-
gdb/testsuite/gdb.python/py-evthreads.exp | 6 -
gdb/testsuite/gdb.threads/non-ldr-exc-1.exp | 5 -
gdb/testsuite/gdb.threads/non-ldr-exc-2.exp | 5 -
gdb/testsuite/gdb.threads/non-ldr-exc-3.exp | 5 -
gdb/testsuite/gdb.threads/non-ldr-exc-4.exp | 5 -
gdb/testsuite/gdb.threads/thread_events.exp | 8 +-
gdb/testsuite/lib/gdb.exp | 12 +-
gdb/testsuite/lib/selftest-support.exp | 14 +-
37 files changed, 304 insertions(+), 254 deletions(-)
diff --git a/gdb/testsuite/boards/gdbserver-base.exp b/gdb/testsuite/boards/gdbserver-base.exp
index 13321d6..04bdfa6 100644
--- a/gdb/testsuite/boards/gdbserver-base.exp
+++ b/gdb/testsuite/boards/gdbserver-base.exp
@@ -33,6 +33,14 @@ set_board_info gdb,predefined_tsv "\\\$trace_timestamp"
set GDBFLAGS "${GDBFLAGS} -ex \"set auto-connect-native-target off\""
+# By default, dejagnu makes the board remote unless the board name
+# matches localhost. Force it to be NOT remote.
+global board
+global board_info
+# Remove any target variant specifications from the name.
+set baseboard [lindex [split $board "/"] 0]
+set board_info($baseboard,isremote) 0
+
proc ${board}_file { dest op args } {
if { $op == "delete" } {
return 0
diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp
index 4ea210f..9c35b12 100644
--- a/gdb/testsuite/boards/native-extended-gdbserver.exp
+++ b/gdb/testsuite/boards/native-extended-gdbserver.exp
@@ -23,14 +23,6 @@
load_generic_config "extended-gdbserver"
load_board_description "gdbserver-base"
-# By default, dejagnu makes the board remote unless the board name
-# matches localhost. Force it to be NOT remote.
-global board
-global board_info
-# Remove any target variant specifications from the name.
-set baseboard [lindex [split $board "/"] 0]
-set board_info($baseboard,isremote) 0
-
set_board_info sockethost "localhost:"
# We will be using the extended GDB remote protocol.
diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
index dd02bb4..bb3dc2f 100644
--- a/gdb/testsuite/gdb.base/annota1.exp
+++ b/gdb/testsuite/gdb.base/annota1.exp
@@ -16,12 +16,10 @@
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
-# are we on a target board? If so, don't run these tests.
-# note: this is necessary because we cannot use runto_main (which would
-# work for remote targets too) because of the different prompt we get
-# when using annotation level 2.
+# This testcase cannot use runto_main because of the different prompt
+# we get when using annotation level 2.
#
-if [is_remote target] then {
+if ![target_can_use_run_cmd] {
return 0
}
diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp
index ceb1682..5a971f0 100644
--- a/gdb/testsuite/gdb.base/annota3.exp
+++ b/gdb/testsuite/gdb.base/annota3.exp
@@ -16,12 +16,10 @@
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
-# are we on a target board? If so, don't run these tests.
-# note: this is necessary because we cannot use runto_main (which would
-# work for remote targets too) because of the different prompt we get
-# when using annotation level 2.
+# This testcase cannot use runto_main because of the different prompt
+# we get when using annotation level 2.
#
-if [is_remote target] then {
+if ![target_can_use_run_cmd] {
return 0
}
diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp
index a1248ed..1a4b0a6 100644
--- a/gdb/testsuite/gdb.base/argv0-symlink.exp
+++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
@@ -80,8 +80,9 @@ gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
if { $has_argv0 } {
- # gdbserver does not have this issue.
- if ![is_remote target] {
+ # gdbserver in extended-remote mode does not have this issue.
+ # Plain remote does, however.
+ if {[target_info gdb_protocol] != "extended-remote"} {
setup_kfail "*-*-*" gdb/15934
}
gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp
index 833a1fd..06236b4 100644
--- a/gdb/testsuite/gdb.base/auxv.exp
+++ b/gdb/testsuite/gdb.base/auxv.exp
@@ -38,10 +38,12 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
}
# Use a fresh directory to confine the native core dumps.
-# Make it the working directory for gdb and its child.
+# Make it the working directory for the inferior.
set coredir [standard_output_file coredir.[getpid]]
file mkdir $coredir
-set core_works [expr [isnative] && ! [is_remote target]]
+set core_works [expr [isnative] \
+ && ! [is_remote target] \
+ && ! [target_info exists use_gdb_stub]]
# Run GDB on the test program up to where it will dump core.
@@ -50,8 +52,9 @@ gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set width 0"
if {$core_works} {
- if {[gdb_test "cd $coredir" ".*Working directory .*" \
- "cd to temporary directory for core dumps"]} {
+ verbose -log "coredir = $coredir"
+ if {[gdb_test_no_output "set cwd $coredir" \
+ "set cwd to temporary directory for core dumps"]} {
set core_works 0
}
}
diff --git a/gdb/testsuite/gdb.base/catch-fork-static.exp b/gdb/testsuite/gdb.base/catch-fork-static.exp
index 2a96004..0a4bc63 100644
--- a/gdb/testsuite/gdb.base/catch-fork-static.exp
+++ b/gdb/testsuite/gdb.base/catch-fork-static.exp
@@ -21,10 +21,6 @@
# ld.so probes before reaching main, and ptrace flags were set then. But a
# static executable would just keep running and never catch the fork.
-if { [is_remote target] || ![isnative] } then {
- continue
-}
-
# Until "catch fork" is implemented on other targets...
#
if { ![istarget "*-*-linux*"] && ![istarget "*-*-openbsd*"] } then {
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 677c389..b93c5f4 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -13,10 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
-if { [is_remote target] || ![isnative] } then {
- continue
-}
-
# Until "set follow-fork-mode" and "catch fork" are implemented on
# other targets...
#
@@ -24,6 +20,12 @@ if {![istarget "*-*-linux*"]} then {
continue
}
+# Checkpoint support is currently implemented in the Linux native
+# target, so only works with "target native".
+if { [target_info gdb_protocol] != "" } {
+ continue
+}
+
# Must name the source file explicitly, otherwise when driven by
# checkpoints-ns.exp, we'd try compiling checkpoints-ns.c, which
# doesn't exist.
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index 21b974f..63127a2 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -188,6 +188,13 @@ gdb_test "core" "No core file now."
proc corefile_test_run {} {
global corefile gdb_prompt
+ # This test assumes that GDB finds the default run target when
+ # already debugging a core, so it can't work if the board already
+ # wants to connect to something.
+ if { [target_info gdb_protocol] != "" } {
+ return
+ }
+
gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"
@@ -244,7 +251,14 @@ gdb_exit
proc corefile_test_attach {} {
global binfile corefile gdb_prompt
- if ![is_remote target] {
+ # This test assumes that GDB finds the default run target when
+ # already debugging a core, so it can't work if the board already
+ # wants to connect to something.
+ if { [target_info gdb_protocol] != "" } {
+ return
+ }
+
+ if [can_spawn_for_attach] {
set test "attach: spawn sleep"
set res [remote_spawn host "$binfile sleep"]
if { $res < 0 || $res == "" } {
diff --git a/gdb/testsuite/gdb.base/dprintf-non-stop.exp b/gdb/testsuite/gdb.base/dprintf-non-stop.exp
index fed51ef..1df933b 100644
--- a/gdb/testsuite/gdb.base/dprintf-non-stop.exp
+++ b/gdb/testsuite/gdb.base/dprintf-non-stop.exp
@@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if [is_remote target] then {
- # Testing with remote/non-stop is racy at the moment.
- unsupported "testing dprintf with remote/non-stop is not supported."
- return 0
-}
-
standard_testfile
set executable ${testfile}
diff --git a/gdb/testsuite/gdb.base/find-unmapped.exp b/gdb/testsuite/gdb.base/find-unmapped.exp
index 9982d0c..05feda4 100644
--- a/gdb/testsuite/gdb.base/find-unmapped.exp
+++ b/gdb/testsuite/gdb.base/find-unmapped.exp
@@ -13,7 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if {[is_remote target]} {
+if {[target_info gdb_protocol] == "remote"
+ || [target_info gdb_protocol] == "extended-remote"} {
# gdbserver prints the warning message but expect is parsing only the
# GDB output, not the gdbserver output.
return 0
diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp
index f2005fa..6f8b6d7 100644
--- a/gdb/testsuite/gdb.base/inferior-died.exp
+++ b/gdb/testsuite/gdb.base/inferior-died.exp
@@ -13,11 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if { [is_remote target] || ![isnative] } then {
- unsupported "inferior-died.exp"
- continue
-}
-
# Until "set follow-fork-mode" and "catch fork" are implemented on
# other targets...
#
@@ -33,12 +28,16 @@ if { ![support_displaced_stepping] } {
standard_testfile .c
-if { [prepare_for_testing "failed to prepare" ${testfile} ${testfile}.c] } {
+if { [build_executable "failed to build" ${testfile} ${testfile}.c] } {
return -1
}
+save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set non-stop 1\""
+ clean_restart ${binfile}
+}
+
gdb_test_no_output "set detach-on-fork off"
-gdb_test_no_output "set non-stop on"
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.base/label.exp b/gdb/testsuite/gdb.base/label.exp
index d3939b6..3560167 100644
--- a/gdb/testsuite/gdb.base/label.exp
+++ b/gdb/testsuite/gdb.base/label.exp
@@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-if [is_remote target] then {
- return 0
-}
-
-
#
# test running programs
#
diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp
index 7f89b28..b8912b9 100644
--- a/gdb/testsuite/gdb.base/remote.exp
+++ b/gdb/testsuite/gdb.base/remote.exp
@@ -13,10 +13,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-# test only on a remote target board
-if {! [is_remote target]} {
+# Test only on a "target remote" board.
+if {[target_info gdb_protocol] != "remote"
+ && [target_info gdb_protocol] != "extended-remote"} {
return
}
diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp
index 4e611ce..5a992b1 100644
--- a/gdb/testsuite/gdb.base/reread.exp
+++ b/gdb/testsuite/gdb.base/reread.exp
@@ -94,51 +94,39 @@ foreach_with_prefix opts {
# and reset the breakpoints correctly.
# Should see "Breakpoint 1, foo () at reread2.c:9"
- set test "run to foo() second time"
- if [is_remote target] {
- unsupported $test
- } else {
- gdb_run_cmd
- gdb_test "" "Breakpoint.* foo .* at .*:9.*" $test
- }
-
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*:9.*" "run to foo() second time"
### Second pass: verify that GDB checks the executable file's
### timestamp when the program is *restarted*, not just when it exits.
- if [is_remote target] {
- unsupported "second pass: GDB should check for changes before running"
- } else {
-
- # Put the older executable back in place.
- gdb_rename_execfile ${binfile} ${binfile2}
- gdb_rename_execfile ${binfile1} ${binfile}
-
- # Restart GDB entirely.
- clean_restart ${binfile}
-
- # Set a breakpoint on foo and run to it.
- gdb_test "break foo" \
- "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
- "second pass: breakpoint foo in first file"
- gdb_run_cmd
- gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" \
- "second pass: run to foo()"
-
- # This time, let the program run to completion. If GDB checks the
- # executable file's timestamp now, it won't notice any change.
- gdb_continue_to_end "second pass"
-
- # Now move the newer executable into place, and re-run. GDB
- # should still notice that the executable file has changed,
- # and still re-set the breakpoint appropriately.
- gdb_rename_execfile ${binfile} ${binfile1}
- gdb_rename_execfile ${binfile2} ${binfile}
- gdb_run_cmd
- gdb_test "" "Breakpoint.* foo .* at .*:9.*" \
- "second pass: run to foo() second time"
- }
+ # Put the older executable back in place.
+ gdb_rename_execfile ${binfile} ${binfile2}
+ gdb_rename_execfile ${binfile1} ${binfile}
+
+ # Restart GDB entirely.
+ clean_restart ${binfile}
+
+ # Set a breakpoint on foo and run to it.
+ gdb_test "break foo" \
+ "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
+ "second pass: breakpoint foo in first file"
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" \
+ "second pass: run to foo()"
+
+ # This time, let the program run to completion. If GDB checks the
+ # executable file's timestamp now, it won't notice any change.
+ gdb_continue_to_end "second pass"
+ # Now move the newer executable into place, and re-run. GDB
+ # should still notice that the executable file has changed,
+ # and still re-set the breakpoint appropriately.
+ gdb_rename_execfile ${binfile} ${binfile1}
+ gdb_rename_execfile ${binfile2} ${binfile}
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*:9.*" \
+ "second pass: run to foo() second time"
}
# End of tests.
diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp
index 48d8245..a0ef6b6 100644
--- a/gdb/testsuite/gdb.base/scope.exp
+++ b/gdb/testsuite/gdb.base/scope.exp
@@ -505,16 +505,13 @@ setup_xfail "rs6000-*-*"
gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
-# gdb currently cannot access bss memory on some targets if the inferior
-# is not running.
+# Check that gdb can access bss memory if the inferior is not running.
#
-# For PA boards using monitor/remote-pa.c, the bss test is going to
-# randomly fail. We've already put remote-pa on the target stack,
-# so we actually read memory from the board. Problem is crt0.o
-# is responsible for clearing bss and that hasnt' happened yet.
-#
-# This is a problem for all non-native targets. -- manson
-if [is_remote target] {
+# For embedded stub-like boards, this test is going to randomly fail.
+# We've already put target remote on the target stack, so we actually
+# read memory from the board. Problem is crt0.o is responsible for
+# clearing bss and that hasn't happened yet.
+if [target_info exists use_gdb_stub] {
unsupported "print 'scope0.c'::filelocal_bss before run"
} else {
gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \
diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp
index e1664da..2c9b495 100644
--- a/gdb/testsuite/gdb.base/shlib-call.exp
+++ b/gdb/testsuite/gdb.base/shlib-call.exp
@@ -170,18 +170,22 @@ gdb_test_no_output "set width 0"
# test that we can re-set breakpoints in shared libraries
gdb_breakpoint "shr1" "allow-pending"
-# FIXME: should not send "run" explicitly. Non-portable.
-
-if ![is_remote target] {
- gdb_test "run" "Starting program:.*Breakpoint .,.*" \
- "run to bp in shared library"
-
- gdb_continue_to_end "" continue 1
+set test "run to bp in shared library"
+gdb_run_cmd
+gdb_test_multiple "" $test {
+ -re "Breakpoint .,.*${gdb_prompt} " {
+ pass $test
+ }
+}
- gdb_test "run" "Starting program:.*Breakpoint .,.*" \
- "re-run to bp in shared library (PR's 16495, 18213)"
+gdb_continue_to_end "" continue 1
- gdb_continue_to_end "" continue 1
+set test "re-run to bp in shared library (PR's 16495, 18213)"
+gdb_run_cmd
+gdb_test_multiple "" $test {
+ -re "Breakpoint .,.*${gdb_prompt} " {
+ pass $test
+ }
}
-return 0
+gdb_continue_to_end "" continue 1
diff --git a/gdb/testsuite/gdb.base/solib-nodir.exp b/gdb/testsuite/gdb.base/solib-nodir.exp
index 9cb682e..800ca01 100644
--- a/gdb/testsuite/gdb.base/solib-nodir.exp
+++ b/gdb/testsuite/gdb.base/solib-nodir.exp
@@ -13,8 +13,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
-# are we on a target board
-if {[is_remote target] || [skip_shlib_tests]} {
+if {[skip_shlib_tests]} {
+ return
+}
+
+# We need to be able to influence the target's environment and working
+# directory. Can't do that if when we connect the inferior is already
+# running.
+if [target_info exists use_gdb_stub] {
return
}
@@ -44,7 +50,8 @@ clean_restart $executable
gdb_load_shlib ${binlibfile}
gdb_test_no_output "set env LD_LIBRARY_PATH=:"
-gdb_test "cd ${binlibfiledir}" "Working directory [string_to_regexp ${binlibfiledir}]\\." "cd OBJDIR/${subdir}"
+gdb_test_no_output "set cwd ${binlibfiledir}" \
+ "set cwd OBJDIR/${subdir}"
set test "library loaded"
if [runto_main] {
diff --git a/gdb/testsuite/gdb.base/solib-search.exp b/gdb/testsuite/gdb.base/solib-search.exp
index 7272a76..a38f7ba 100644
--- a/gdb/testsuite/gdb.base/solib-search.exp
+++ b/gdb/testsuite/gdb.base/solib-search.exp
@@ -16,11 +16,19 @@
# Test solib-search-path, and in the case of solib-svr4.c whether l_addr_p
# is properly reset when the path is changed.
-if {[is_remote target] || [skip_shlib_tests]} {
- untested "skipping remote target and shared library tests"
+if [skip_shlib_tests] {
+ untested "skipping shared library tests"
return -1
}
+# The testcase invokes commands on the build system, expecting that
+# the effects are visible on the host.
+if [is_remote host] {
+ untested "skipping remote host"
+ return -1
+}
+
+
# This is required by gdb_compile_shlib.
if {[get_compiler_info]} {
warning "Could not get compiler info"
diff --git a/gdb/testsuite/gdb.base/term.exp b/gdb/testsuite/gdb.base/term.exp
index c922deb..7c3f1cb 100644
--- a/gdb/testsuite/gdb.base/term.exp
+++ b/gdb/testsuite/gdb.base/term.exp
@@ -13,8 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Don't try this for remote targets.
-if [is_remote target] then {
+# Don't try this for non-"target native" targets.
+if {[target_info gdb_protocol] != ""} {
continue
}
diff --git a/gdb/testsuite/gdb.base/testenv.c b/gdb/testsuite/gdb.base/testenv.c
index 11e6bd3..bbc851e 100644
--- a/gdb/testsuite/gdb.base/testenv.c
+++ b/gdb/testsuite/gdb.base/testenv.c
@@ -24,6 +24,11 @@
#include <stdio.h>
#include <string.h>
+static void
+vars_counted (void)
+{
+}
+
int main (int argc, char **argv, char **envp)
{
@@ -39,6 +44,7 @@ int main (int argc, char **argv, char **envp)
}
}
printf ("Program found %d variables starting with TEST_GDB\n", j);
+ vars_counted ();
return 0; /* set breakpoint here. */
}
diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp
index 52becfd..6f13de8 100644
--- a/gdb/testsuite/gdb.base/testenv.exp
+++ b/gdb/testsuite/gdb.base/testenv.exp
@@ -18,9 +18,10 @@
# Check if environment variables are correctly passed to inferiors
#
-# There's no support for passing environment variables in the remote protocol.
-if { [is_remote target] } {
- return 0
+# Can't pass environment variables to the inferior if when we connect,
+# the inferior is already running.
+if [target_info exists use_gdb_stub] {
+ return
}
standard_testfile .c
@@ -32,92 +33,155 @@ if { [prepare_for_testing "failed to prepare" ${binfile} ${srcfile}] } {
return -1
}
-# make sure $pc is sane, in case we're talking to a board.
-if { ![runto_main] } {
- gdb_suppress_tests
+# Test that the the inferior sees EXPECTED env vars starting with
+# "TEST_GDB".
+proc test_num_test_vars {expected message} {
+ set num [get_integer_valueof "j" -1 "$message, get num vars"]
+ gdb_assert {$num == $expected} "$message, confirmed"
}
-set bp_line [gdb_get_line_number "set breakpoint here"]
-gdb_breakpoint $bp_line
+# Restart test program, and prepare for another test sequence.
+# Returns true on success.
+proc run_and_count_vars {} {
+ global gdb_prompt
+
+ if ![runto "vars_counted"] {
+ return 0
+ }
+ gdb_test_multiple "up" "up" {
+ -re "#1 .*main.*$gdb_prompt $" {
+ }
+ }
+ return 1
+}
+
+# Find environment variable named VARNAME (peeking inferior variables
+# directly), and return its value. Returns "<not found>" if not
+# found.
+
+proc find_env {varname} {
+ global gdb_prompt
+
+ for {set i 0} {1} {incr i} {
+ set test "printf \"var: %s\\n\", envp\[$i\] ? envp\[$i\] : \"\""
+ set var ""
+ gdb_test_multiple $test $test {
+ -re "var: \r\n$gdb_prompt $" {
+ return "<not found>"
+ }
+ -re "var: \(\[^\r\n\]*\)\r\n$gdb_prompt $" {
+ set var $expect_out(1,string)
+ }
+ }
+
+ if {[string match "$varname=*" $var]} {
+ set from [expr [string first "=" $var] + 1]
+ set to [string length $var]
+ return [string range $var $from $to]
+ }
+ }
+}
#
# Test gdb set/unset environment commands.
-# Executable lists and counts all environment variables
+# The executable lists and counts all environment variables
# starting with TEST_GDB.
+proc_with_prefix test_set_unset_env {} {
+ global binfile
+
+ clean_restart $binfile
+
+ # First test with no TEST_GDB_VAR.
+ with_test_prefix "test1" {
+ if ![run_and_count_vars] {
+ return
+ }
+ test_num_test_vars 0 "no TEST_GDB vars"
+ }
+
+ # Second test with one TEST_GDB_VAR.
+ with_test_prefix "test2" {
+ gdb_test_no_output "set env TEST_GDB_VAR1 test1" \
+ "set TEST_GDB_VAR1"
+
+ if ![run_and_count_vars] {
+ return
+ }
+ test_num_test_vars 1 "one TEST_GDB var"
+ }
+
+ # Third test with two TEST_GDB_VAR.
+ with_test_prefix "test3" {
+ gdb_test_no_output "set env TEST_GDB_VAR2 test2" \
+ "set TEST_GDB_VAR2"
+
+ if ![run_and_count_vars] {
+ return
+ }
+
+ test_num_test_vars 2 "two TEST_GDB var"
+ }
+
+ # Fourth test with one TEST_GDB_VAR left, after one was removed
+ # with unset command.
+ with_test_prefix "test4" {
+ gdb_test_no_output "unset env TEST_GDB_VAR1" \
+ "unset TEST_GDB_VAR1"
+
+ if ![run_and_count_vars] {
+ return
+ }
+
+ test_num_test_vars 1 "one TEST_GDB var, after unset"
+ }
+}
-# First test with no TEST_GDB_VAR
-gdb_test "continue" \
- ".*Program found 0 variables starting with TEST_GDB.*" \
- "test no TEST_GDB var"
-
-gdb_test_no_output "set env TEST_GDB_VAR1 test1" \
- "set TEST_GDB_VAR1"
-
-runto_main
-gdb_breakpoint $bp_line
+proc_with_prefix test_inherit_env_var {} {
+ global binfile
+ global env
-# Second test with one TEST_GDB_VAR
-gdb_test "continue" \
- ".*Program found 1 variables starting with TEST_GDB.*" \
- "test with one TEST_GDB var"
+ # This test assumes that the build's environ (where dejagnu runs)
+ # is the same as the host's (where gdb runs) environ.
+ if [is_remote host] {
+ return
+ }
-gdb_test_no_output "set env TEST_GDB_VAR2 test2" \
- "set TEST_GDB_VAR2"
+ save_vars {env(TEST_GDB_GLOBAL)} {
+ set env(TEST_GDB_GLOBAL) "Global environment value"
-runto_main
-gdb_breakpoint $bp_line
+ clean_restart $binfile
-# Third test with two TEST_GDB_VAR
-gdb_test "continue" \
- ".*Program found 2 variables starting with TEST_GDB.*" \
- "test with two TEST_GDB var"
+ # First test with only inherited TEST_GDB_GLOBAL.
+ with_test_prefix "test1" {
+ if ![run_and_count_vars] {
+ return
+ }
-gdb_test_no_output "unset env TEST_GDB_VAR1" \
- "unset TEST_GDB_VAR1"
+ gdb_test "show env" ".*TEST_GDB_GLOBAL=.*" \
+ "test passing TEST_GDB_GLOBAL to GDB"
-runto_main
-gdb_breakpoint $bp_line
+ test_num_test_vars 1 "TEST_GDB_GLOBAL"
-# Fourth test with one TEST_GDB_VAR left, after one was removed
-# with unset command.
-gdb_test "continue" \
- ".*Program found 1 variables starting with TEST_GDB.*" \
- "test with one TEST_GDB var, after unset"
+ set var [find_env "TEST_GDB_GLOBAL"]
-gdb_exit
+ gdb_assert {[string equal $var "Global environment value"]} \
+ "test with TEST_GDB_GLOBAL"
+ }
-set env(TEST_GDB_GLOBAL) "Global environment value"
+ # Second test with one TEST_GDB_VAR.
+ with_test_prefix "test2" {
+ gdb_test_no_output "unset env TEST_GDB_GLOBAL" \
+ "unset TEST_GDB_GLOBAL"
-clean_restart $binfile
+ if ![run_and_count_vars] {
+ return
+ }
-# make sure $pc is sane, in case we're talking to a board.
-if { ![runto_main] } {
- gdb_suppress_tests
+ test_num_test_vars 0 "test with TEST_GDB_GLOBAL unset"
+ }
+ }
}
-set bp_line [gdb_get_line_number "set breakpoint here"]
-gdb_breakpoint $bp_line
-
-gdb_test "show env" ".*TEST_GDB_GLOBAL=.*" "test passing TEST_GDB_GLOBAL to GDB"
-# First test with only inherited TEST_GDB_GLOBAL
-gdb_test "continue" \
- ".*TEST_GDB_GLOBAL=Global environment value.*Program found 1 variables starting with TEST_GDB.*" \
- "test with TEST_GDB_GLOBAL"
-
-gdb_test_no_output "unset env TEST_GDB_GLOBAL" \
- "unset TEST_GDB_GLOBAL"
-
-runto_main
-gdb_breakpoint $bp_line
-
-# Second test with one TEST_GDB_VAR
-gdb_test "continue" \
- ".*Program found 0 variables starting with TEST_GDB.*" \
- "test with TEST_GDB_GLOBAL unset"
-
-gdb_exit
-
-# Clear environment in case we're doing multiple runs
-unset env(TEST_GDB_GLOBAL)
-
+test_set_unset_env
+test_inherit_env_var
diff --git a/gdb/testsuite/gdb.base/valgrind-db-attach.exp b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
index 306132d..2a2963a 100644
--- a/gdb/testsuite/gdb.base/valgrind-db-attach.exp
+++ b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
@@ -13,8 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if [is_remote target] {
- # The test always runs locally.
+# Skip if already connected to some target.
+if { [target_info gdb_protocol] != "" } {
return 0
}
diff --git a/gdb/testsuite/gdb.base/valgrind-disp-step.exp b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
index b904874..0e9e0d1 100644
--- a/gdb/testsuite/gdb.base/valgrind-disp-step.exp
+++ b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
@@ -18,11 +18,6 @@
# really tests is that GDB falls back to in-line stepping
# automatically instead of getting stuck or crashing.
-if [is_remote target] {
- # The test always runs locally.
- return 0
-}
-
standard_testfile .c
if {[build_executable "failed to build" $testfile $srcfile {debug}] == -1} {
return -1
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.base/valgrind-infcall.exp
index e1222fa..6eefa3d 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp
@@ -13,11 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if [is_remote target] {
- # The test always runs locally.
- return 0
-}
-
standard_testfile .c
if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
return -1
diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp
index a00161d..78e8795 100644
--- a/gdb/testsuite/gdb.cp/annota2.exp
+++ b/gdb/testsuite/gdb.cp/annota2.exp
@@ -29,12 +29,10 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
return -1
}
-# are we on a target board? If so, don't run these tests.
-# note: this is necessary because we cannot use runto_main (which would
-# work for remote targets too) because of the different prompt we get
-# when using annotation level 2.
+# This testcase cannot use runto_main because of the different prompt
+# we get when using annotation level 2.
#
-if [is_remote target] then {
+if ![target_can_use_run_cmd] {
return 0
}
diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp
index 4215e76..3141251 100644
--- a/gdb/testsuite/gdb.cp/annota3.exp
+++ b/gdb/testsuite/gdb.cp/annota3.exp
@@ -29,12 +29,10 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
return -1
}
-# are we on a target board? If so, don't run these tests.
-# note: this is necessary because we cannot use runto_main (which would
-# work for remote targets too) because of the different prompt we get
-# when using annotation level 2.
+# This testcase cannot use runto_main because of the different prompt
+# we get when using annotation level 2.
#
-if [is_remote target] then {
+if ![target_can_use_run_cmd] {
return 0
}
diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
index dba6697..f308aed 100644
--- a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
+++ b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if { [is_remote target] || ![isnative] } then {
+if { ![target_can_use_run_cmd] } then {
continue
}
diff --git a/gdb/testsuite/gdb.python/py-evsignal.exp b/gdb/testsuite/gdb.python/py-evsignal.exp
index 8a39f4e..4138b9c 100644
--- a/gdb/testsuite/gdb.python/py-evsignal.exp
+++ b/gdb/testsuite/gdb.python/py-evsignal.exp
@@ -13,7 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if {[is_remote target]} {
+if {[target_info gdb_protocol] == "remote"
+ || [target_info gdb_protocol] == "extended-remote"} {
# RuntimeError: Could not find event thread
kfail "python/12966" "Signal Thread 3"
return -1
diff --git a/gdb/testsuite/gdb.python/py-evthreads.exp b/gdb/testsuite/gdb.python/py-evthreads.exp
index 64b2af5..a72966f 100644
--- a/gdb/testsuite/gdb.python/py-evthreads.exp
+++ b/gdb/testsuite/gdb.python/py-evthreads.exp
@@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if {[is_remote target]} {
- # RuntimeError: Could not find event thread
- kfail "python/12966" "Run to breakpoint 1"
- return -1
-}
-
if { ![support_displaced_stepping] } {
unsupported "displaced stepping"
return -1
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
index 689246f..558810d 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
@@ -16,11 +16,6 @@
# Test that when a thread other than the main thread execs, we follow
# through to the new incarnation of the main thread.
-# No exec event support in the remote protocol.
-if { [is_remote target] } then {
- continue
-}
-
standard_testfile
set executable ${testfile}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
index 1b7be25..077c192 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
@@ -17,11 +17,6 @@
# through to the new incarnation of the main thread, even if the main
# thread had already exited before the exec.
-# No exec event support in the remote protocol.
-if { [is_remote target] } then {
- continue
-}
-
standard_testfile
set executable ${testfile}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
index 74ee6a7..3c88d1d 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
@@ -19,11 +19,6 @@
# non-ldr-exc-2.exp in that we have more than two threads in the
# program when the exec happens.
-# No exec event support in the remote protocol.
-if { [is_remote target] } then {
- continue
-}
-
standard_testfile
set executable ${testfile}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
index f306b9d..04e81e3 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
@@ -18,11 +18,6 @@
# from non-ldr-exc-1.exp in that we have more than two threads in the
# program when the exec happens.
-# No exec event support in the remote protocol.
-if { [is_remote target] } then {
- continue
-}
-
standard_testfile
set executable ${testfile}
diff --git a/gdb/testsuite/gdb.threads/thread_events.exp b/gdb/testsuite/gdb.threads/thread_events.exp
index d8d19c8..82d81c1 100644
--- a/gdb/testsuite/gdb.threads/thread_events.exp
+++ b/gdb/testsuite/gdb.threads/thread_events.exp
@@ -27,9 +27,11 @@ if ![istarget *-*-linux*] then {
return
}
-# When using gdbserver, even on Linux, we don't get notifications
-# about new threads. This is expected, so don't test for that.
-if [is_remote target] then {
+# When using "target remote", even on Linux with gdbserver, we don't
+# get notifications about new threads. This is expected, so don't
+# test for that.
+if {[target_info gdb_protocol] == "remote"
+ || [target_info gdb_protocol] == "extended-remote"} {
return
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 9d8296a..cf04274 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -226,6 +226,16 @@ proc delete_breakpoints {} {
}
}
+# Returns true iff the target supports using the "run" command.
+
+proc target_can_use_run_cmd {} {
+ if [target_info exists use_gdb_stub] {
+ return 0
+ }
+
+ return 1
+}
+
# Generic run command.
#
# The second pattern below matches up to the first newline *only*.
@@ -4107,7 +4117,7 @@ proc can_spawn_for_attach { } {
# 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]} {
+ if [target_info exists use_gdb_stub] {
return 0
}
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 987b5c8..e889c00 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -87,14 +87,16 @@ proc selftest_setup { executable function } {
set timeout 600
set description "run until breakpoint at $function"
- gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
- -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb_prompt $" {
+ gdb_test_no_output "set args $INTERNAL_GDBFLAGS"
+ gdb_run_cmd
+ gdb_test_multiple "" "$description" {
+ -re "Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb_prompt $" {
pass "$description"
}
- -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).*$gdb_prompt $" {
+ -re "Breakpoint \[0-9\]+,.*$function \\(\\).*$gdb_prompt $" {
xfail "$description (line numbers scrambled?)"
}
- -re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
+ -re "Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" {
# $function may be inlined, so the program stops at the line
# calling $function.
pass "$description"
@@ -124,7 +126,9 @@ proc selftest_setup { executable function } {
proc do_self_tests {function body} {
global GDB tool
- # Are we on a target board.
+ # Are we testing with a remote board (which won't have access to
+ # the GDB binary and its auxilliary data files), or with a cross
+ # debugger?
if { [is_remote target] || ![isnative] } then {
return
}
--
2.5.5