From 60fb7e9efa12266437d28d19191e49e7f1e0013d Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 20 Feb 2015 19:50:36 +0000 Subject: [PATCH] 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 * gdb.trace/no-attach-trace.exp: Don't run to main. Do clean_restart before gdb_target_supports_trace. --- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.trace/no-attach-trace.exp | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d9a752b3943..050f98cb69a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-20 Pedro Alves + + * gdb.trace/no-attach-trace.exp: Don't run to main. Do + clean_restart before gdb_target_supports_trace. + 2015-02-20 Pedro Alves PR threads/18006 diff --git a/gdb/testsuite/gdb.trace/no-attach-trace.exp b/gdb/testsuite/gdb.trace/no-attach-trace.exp index 96135cbf355..2be19bd34f6 100644 --- a/gdb/testsuite/gdb.trace/no-attach-trace.exp +++ b/gdb/testsuite/gdb.trace/no-attach-trace.exp @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# 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" -- 2.30.2