]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/tracecmd.exp
* gdb.arch/altivec-abi.exp: Replace gdb_suppress_entire_file with
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tracecmd.exp
1 # Copyright 1998 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Michael Snyder (msnyder@cygnus.com)
21
22 load_lib "trace-support.exp";
23
24 if $tracelevel then {
25 strace $tracelevel
26 }
27
28 set prms_id 0
29 set bug_id 0
30
31 gdb_exit
32 gdb_start
33 if [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 \
41 executable {debug nowarnings}] != "" } {
42 untested tracecmd.exp
43 return -1
44 }
45 }
46 gdb_reinitialize_dir $srcdir/$subdir
47
48 # If testing on a remote host, download the source file.
49 # remote_download host $srcdir/$subdir/$srcfile
50
51 gdb_file_cmd $binfile
52
53 # define relative source line numbers:
54 # all subsequent line numbers are relative to this first one (baseline)
55 set baseline [gdb_find_recursion_test_baseline $srcfile];
56 if { $baseline == -1 } then {
57 fail "Could not find gdb_recursion_test function"
58 return;
59 }
60
61 set testline1 [expr $baseline + 1]
62 set testline2 [expr $baseline + 3]
63
64 #
65 # test "help tracepoints"
66 #
67
68 set helpcnt 0;
69 send_gdb "help tracepoints\n"
70 gdb_expect {
71 -re "Tracing of program execution without stopping the program." {
72 incr helpcnt;
73 exp_continue
74 }
75 -re "actions -- Specify the actions to be taken at a tracepoint" {
76 incr helpcnt;
77 exp_continue
78 }
79 -re "collect -- Specify one or more data items to be collected" {
80 incr helpcnt;
81 exp_continue
82 }
83 -re "delete tracepoints -- Delete specified tracepoints" {
84 incr helpcnt;
85 exp_continue
86 }
87 -re "end -- Ends a list of.*actions" {
88 incr helpcnt;
89 exp_continue
90 }
91 -re "info tracepoints -- Status of tracepoints" {
92 incr helpcnt;
93 exp_continue
94 }
95 -re "passcount -- Set the passcount for a tracepoint" {
96 incr helpcnt;
97 exp_continue
98 }
99 -re "save-tracepoints -- Save current tracepoint definitions" {
100 incr helpcnt;
101 exp_continue
102 }
103 -re "tdump -- Print everything collected at the current tracepoint" {
104 incr helpcnt;
105 exp_continue
106 }
107 -re "tfind -- Select a trace frame" {
108 incr helpcnt;
109 exp_continue
110 }
111 -re "tfind end -- Synonym for 'none'" {
112 incr helpcnt;
113 exp_continue
114 }
115 -re "tfind line -- Select a trace frame by line number" {
116 incr helpcnt;
117 exp_continue
118 }
119 -re "tfind none -- De-select any trace frame and resume 'live' debugging" {
120 incr helpcnt;
121 exp_continue
122 }
123 -re "tfind outside -- Select a trace frame whose PC is outside" {
124 incr helpcnt;
125 exp_continue
126 }
127 -re "tfind pc -- Select a trace frame by PC" {
128 incr helpcnt;
129 exp_continue
130 }
131 -re "tfind range -- Select a trace frame whose PC is in the given" {
132 incr helpcnt;
133 exp_continue
134 }
135 -re "tfind start -- Select the first trace frame in the trace buffer" {
136 incr helpcnt;
137 exp_continue
138 }
139 -re "tfind tracepoint -- Select a trace frame by tracepoint number" {
140 incr helpcnt;
141 exp_continue
142 }
143 -re "trace -- Set a tracepoint at a specified line or function or addr" {
144 incr helpcnt;
145 exp_continue
146 }
147 -re "tstart -- Start trace data collection" {
148 incr helpcnt;
149 exp_continue
150 }
151 -re "tstatus -- Display the status of the current trace data collection" {
152 incr helpcnt;
153 exp_continue
154 }
155 -re "tstop -- Stop trace data collection" {
156 incr helpcnt;
157 exp_continue
158 }
159 -re "while-stepping -- Specify single-stepping behavior at a tracepoint" {
160 incr helpcnt;
161 exp_continue
162 }
163 -re ".*$gdb_prompt $" {
164 if { $helpcnt == 21 } {
165 pass "1.0: help tracepoints"
166 } else {
167 warning "$helpcnt";
168 fail "1.0: help tracepoints"
169 }
170 }
171 }
172
173 #
174 # test trace command:
175 #
176
177 # 1.1 trace source line
178 gdb_delete_tracepoints
179 gdb_test "trace $srcfile:$testline2" \
180 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
181 "1.1a: set tracepoint at sourceline"
182 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2" \
183 "1.1b: trace sourcefile:line"
184
185 # 1.2 trace invalid source line
186 gdb_delete_tracepoints
187 gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \
188 "1.2a: trace invalid line in sourcefile"
189 gdb_test "info trace" "No tracepoints.*" \
190 "1.2b: reject invalid line in srcfile"
191
192 # 1.3 trace line in invalid source file
193 gdb_delete_tracepoints
194 gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \
195 "1.3a: trace invalid source file"
196 gdb_test "info trace" "No tracepoints.*" \
197 "1.3b: reject invalid srcfile"
198
199 # 1.4 trace function by name
200 gdb_delete_tracepoints
201 gdb_test "trace gdb_recursion_test" \
202 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
203 "1.4a: trace function by name"
204 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1" \
205 "1.4b: trace function by name"
206
207 # 1.5 trace non-existant function
208 gdb_delete_tracepoints
209 gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \
210 "1.5a: trace invalid function"
211 gdb_test "info trace" "No tracepoints.*" \
212 "1.5b: reject invalid srcfile"
213
214 # 1.6 trace at a specific address
215 # Collect the address of "gdb_asm_test", and use that.
216 send_gdb "print gdb_asm_test\n"
217 gdb_expect {
218 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
219 set asm_test_addr $expect_out(1,string)
220 }
221 timeout { }
222 }
223
224 gdb_delete_tracepoints
225 gdb_test "trace \*0x$asm_test_addr" \
226 "Tracepoint $decimal at .*$asm_test_addr.*" \
227 "1.6a: trace at specific address"
228 gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \
229 "1.6b: verify trace at specific address"
230
231 # 1.7 trace at function's exact address
232 # Collect the address of the function for comparison
233 send_gdb "print gdb_recursion_test\n"
234 gdb_expect {
235 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
236 set c_test_addr $expect_out(1,string)
237 }
238 timeout { }
239 }
240
241 gdb_delete_tracepoints
242 gdb_test "trace \*gdb_recursion_test" \
243 "Tracepoint $decimal at .*$c_test_addr.*" \
244 "1.7a: trace at function label (before prologue)"
245 gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline" \
246 "1.7b: verify trace at specific address"
247
248 # 1.8 trace at invalid address
249 # no address is invalid
250
251 # 1.9 trace no arguments
252 gdb_test "trace" "trace command requires an argument" \
253 "1.9: trace <no arguments>"
254
255 # 1.10 set large number of tracepoints
256 # deferred to limits test module
257
258 # 1.11 tracepoint conditions
259 # conditions on tracepoints not implemented
260
261 # 1.12 set tracepoint in prologue
262 # [see tfind.exp]
263
264 # 1.13 trace on recursion
265 # interesting only in "live" session: see backtrace.exp for live test.
266
267 # 1.14 help trace
268 gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace"
269
270