Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / save-trace.exp
CommitLineData
6aba47ca 1# Copyright 1998, 2007 Free Software Foundation, Inc.
c906108c
SS
2#
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
15
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19# This file was written by Michael Snyder (msnyder@cygnus.com)
20
21load_lib "trace-support.exp";
22
23if $tracelevel then {
24 strace $tracelevel
25}
26
27set prms_id 0
28set bug_id 0
29
30gdb_exit
31gdb_start
32
33if [istarget "m68k-*-elf"] then {
34 set srcfile gdb_c_test.c
35 set binfile [board_info target d490_binfile];
36} else {
37 set testfile "actions"
38 set srcfile ${testfile}.c
39 set binfile $objdir/$subdir/$testfile
40 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
fc91c6c2 41 executable {debug nowarnings}] != "" } {
b60f0898
JB
42 untested save-trace.exp
43 return -1
c906108c
SS
44 }
45}
46gdb_reinitialize_dir $srcdir/$subdir
47
48# If testing on a remote host, download the source file.
49# remote_download host $srcdir/$subdir/$srcfile
50
51gdb_file_cmd $binfile
52
53# define relative source line numbers:
54# all subsequent line numbers are relative to this first one (baseline)
55set baseline [gdb_find_recursion_test_baseline $srcfile];
56if { $baseline == -1 } then {
57 fail "Could not find gdb_recursion_test function"
58 return;
59}
60
61set testline1 [expr $baseline + 4]
62set testline2 [expr $baseline + 5]
63set testline3 [expr $baseline + 6]
64set testline4 [expr $baseline + 7]
65set testline5 [expr $baseline + 8]
66set testline6 [expr $baseline + 9]
67
68#
69# test save-trace command
70#
71
72# setup a set of tracepoints to save
73
74gdb_delete_tracepoints
75
76foreach x { 1 2 3 4 5 6 } {
77 set testline [expr \$testline$x];
78 set trcpt [gdb_gettpnum $testline];
79 set trcpt$x $trcpt;
80 gdb_test "passcount $x" \
81 "Setting tracepoint $trcpt.* to $x" \
82 "10.x: set passcount for tracepoint $trcpt"
83
84 gdb_trace_setactions "10.x: set actions for tracepoint $x" \
85 "" \
86 "collect q$x" "^$" \
87 "while-stepping $x" "^$" \
88 "collect q$x" "^$" \
89 "end" "^$"
90}
91
92
93proc gdb_verify_tracepoints { testname } {
94 global gdb_prompt;
95
96 set ws "\[\t \]+"
97 set nl "\[\r\n\]+"
98 set ourstate 1;
99 set result "pass";
100 send_gdb "info tracepoints\n";
101 gdb_expect 10 {
102 -re "y\[\t \]+0x\[0-9a-fA-F\]+\[\t \]+(\[0-9\]+)\[\t \]+(\[0-9\]+)\[\t \]+in gdb_recursion_test\[^\r\n\]+" {
103 if { $expect_out(1,string) != $expect_out(2,string) } {
104 #set result "fail";
105 }
106 if { $expect_out(1,string) != $ourstate } {
107 set result "fail";
108 }
109 incr ourstate;
110 exp_continue;
111 }
112 -re "$gdb_prompt $" {
113 if { $ourstate >= 6 } {
114 set result "pass";
115 } else {
116 set result "fail";
117 }
118 }
119 default {
120 set result "fail";
121 }
122 }
123 $result $testname;
124 return $result;
125}
126
127gdb_verify_tracepoints "10.x: verify trace setup";
128
129# 10.1 Save current tracepoint definitions to a file
130
131remote_file host delete savetrace.tr
132gdb_test "save-tracepoints savetrace.tr" \
133 "Tracepoints saved to file 'savetrace.tr'." \
134 "10.1: save tracepoint definitions"
135
136# 10.2 Read back tracepoint definitions
137
138gdb_delete_tracepoints
139gdb_test "info tracepoints" "No tracepoints." "10.2: delete tracepoints"
140gdb_test "source savetrace.tr" \
141 "Tracepoint \[0-9\]+ at .*" \
142 "10.2: read back saved tracepoints"
143gdb_verify_tracepoints "10.2: verify recovered tracepoints";
144remote_file host delete savetrace.tr
145
146# 10.3 repeat with a path to the file
147
e0f353ce 148set escapedfilename [string_to_regexp $objdir/savetrace.tr]
c906108c
SS
149remote_file host delete $objdir/savetrace.tr
150gdb_test "save-tracepoints $objdir/savetrace.tr" \
e0f353ce 151 "Tracepoints saved to file '${escapedfilename}'." \
c906108c
SS
152 "10.3: save tracepoint definitions, full path"
153
154gdb_delete_tracepoints
155gdb_test "info tracepoints" "No tracepoints." "10.3: delete tracepoints"
156gdb_test "source $objdir/savetrace.tr" \
157 "Tracepoint \[0-9\]+ at .*" \
158 "10.4: read saved tracepoints, full path"
159gdb_verify_tracepoints "10.3: verify recovered tracepoints, full path";
160remote_file host delete $objdir/savetrace.tr
161
162# 10.5 invalid filename
163# [deferred -- not sure what a good invalid filename would be]
164
165# 10.6 save-trace (file already exists)
166# [expect it to clobber the old one]
167
168# 10.7 help save-tracepoints
169
170gdb_test "help save-tracepoints" \
171 "Save current tracepoint definitions as a script.*" \
172 "10.7: help save-tracepoints"
This page took 0.707574 seconds and 4 git commands to generate.