Fix no-attach-trace.exp with "target remote" / gdbserver

$ make check RUNTESTFLAGS="--target_board=native-gdbserver no-attach-trace.exp"
 ...
 (gdb) trace main
 Tracepoint 1 at 0x400594: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.trace/no-attach-trace.c, line 25.
 (gdb) PASS: gdb.trace/no-attach-trace.exp: set tracepoint on main
 tstart
 You can't do that when your target is `exec'
 (gdb) FAIL: gdb.trace/no-attach-trace.exp: tstart

Even though this target supports tracing, the test restarts GDB and
doesn't do gdb_run_cmd so does not reconnect to the remote target.  So
at that point, GDB only has the "exec" target, which obviously doesn't
do tracing.

The test is about doing "tstart" before running a program, so the fix
is to do gdb_target_supports_trace with whatever target GDB ends up
connected after clean_restart.

Tested on x86_64 Fedora 20, native, native-gdbserver and
native-extended-gdbserver boards.  The test passes with the latter,
and is skipped with the first two.

gdb/testsuite/ChangeLog:
2015-02-20  Pedro Alves  <palves@redhat.com>

	* gdb.trace/no-attach-trace.exp: Don't run to main.  Do
	clean_restart before gdb_target_supports_trace.
This commit is contained in:
Pedro Alves 2015-02-20 19:50:36 +00:00
parent 5c5019c27c
commit 60fb7e9efa
2 changed files with 10 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2015-02-20 Pedro Alves <palves@redhat.com>
* gdb.trace/no-attach-trace.exp: Don't run to main. Do
clean_restart before gdb_target_supports_trace.
2015-02-20 Pedro Alves <palves@redhat.com>
PR threads/18006

View File

@ -15,7 +15,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/>.
# Test that trying to trace without a program attached fails properly.
# Test that trying to trace without a process attached fails properly.
load_lib trace-support.exp
@ -25,20 +25,16 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
return -1
}
if ![runto_main] {
fail "Can't run to main to check for trace support"
return -1
}
# Start GDB, but don't run so that we have no process attached.
# Effectively, this tests targets that can do tracing and where GDB
# can start programs ("run"), such as e.g., extended-remote gdbserver.
clean_restart $testfile
if { ![gdb_target_supports_trace] } then {
unsupported "Current target does not support trace"
return 1
}
# Clean test state so that we have no process attached.
clean_restart $testfile
gdb_test "trace main" \
"Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
"set tracepoint on main"