1 # Copyright 1998, 2007, 2008, 2009 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
18 load_lib "trace-support.exp";
30 if [istarget "m68k-*-elf"] then {
31 set srcfile gdb_c_test.c
32 set binfile [board_info target d490_binfile];
34 set testfile "actions"
35 set srcfile ${testfile}.c
36 set binfile $objdir/$subdir/save-trace
37 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
38 executable {debug nowarnings}] != "" } {
39 untested save-trace.exp
43 gdb_reinitialize_dir $srcdir/$subdir
45 # If testing on a remote host, download the source file.
46 # remote_download host $srcdir/$subdir/$srcfile
50 # define relative source line numbers:
51 # all subsequent line numbers are relative to this first one (baseline)
52 set baseline [gdb_find_recursion_test_baseline $srcfile];
53 if { $baseline == -1 } then {
54 fail "Could not find gdb_recursion_test function"
58 set testline1 [expr $baseline + 4]
59 set testline2 [expr $baseline + 5]
60 set testline3 [expr $baseline + 6]
61 set testline4 [expr $baseline + 7]
62 set testline5 [expr $baseline + 8]
63 set testline6 [expr $baseline + 9]
66 # test save-trace command
69 # setup a set of tracepoints to save
71 gdb_delete_tracepoints
73 foreach x { 1 2 3 4 5 6 } {
74 set testline [expr \$testline$x];
75 set trcpt [gdb_gettpnum $testline];
77 gdb_test "passcount $x" \
78 "Setting tracepoint $trcpt.* to $x" \
79 "10.x: set passcount for tracepoint $trcpt"
81 gdb_trace_setactions "10.x: set actions for tracepoint $x" \
84 "while-stepping $x" "^$" \
90 proc gdb_verify_tracepoints { testname } {
97 send_gdb "info tracepoints\n";
99 -re "\[0-9\]+\[\t \]+tracepoint\[\t \]+keep y\[\t \]+0x\[0-9a-fA-F\]+ in gdb_recursion_test\[^\r\n\]+" {
100 # if { $expect_out(1,string) != $ourstate } {
106 -re "$gdb_prompt $" {
107 if { $ourstate >= 6 } {
121 gdb_verify_tracepoints "10.x: verify trace setup";
123 # 10.1 Save current tracepoint definitions to a file
125 remote_file host delete savetrace.tr
126 gdb_test "save-tracepoints savetrace.tr" \
127 "Tracepoints saved to file 'savetrace.tr'." \
128 "10.1: save tracepoint definitions"
130 # 10.2 Read back tracepoint definitions
132 gdb_delete_tracepoints
133 gdb_test "info tracepoints" "No tracepoints." "10.2: delete tracepoints"
134 gdb_test "source savetrace.tr" \
135 "Tracepoint \[0-9\]+ at .*" \
136 "10.2: read back saved tracepoints"
137 gdb_verify_tracepoints "10.2: verify recovered tracepoints";
138 remote_file host delete savetrace.tr
140 # 10.3 repeat with a path to the file
142 set escapedfilename [string_to_regexp $objdir/savetrace.tr]
143 remote_file host delete $objdir/savetrace.tr
144 gdb_test "save-tracepoints $objdir/savetrace.tr" \
145 "Tracepoints saved to file '${escapedfilename}'." \
146 "10.3: save tracepoint definitions, full path"
148 gdb_delete_tracepoints
149 gdb_test "info tracepoints" "No tracepoints." "10.3: delete tracepoints"
150 gdb_test "source $objdir/savetrace.tr" \
151 "Tracepoint \[0-9\]+ at .*" \
152 "10.4: read saved tracepoints, full path"
153 gdb_verify_tracepoints "10.3: verify recovered tracepoints, full path";
154 remote_file host delete $objdir/savetrace.tr
156 # 10.5 invalid filename
157 # [deferred -- not sure what a good invalid filename would be]
159 # 10.6 save-trace (file already exists)
160 # [expect it to clobber the old one]
162 # 10.7 help save-tracepoints
164 gdb_test "help save-tracepoints" \
165 "Save current tracepoint definitions as a script.*" \
166 "10.7: help save-tracepoints"