gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / actions.exp
CommitLineData
4c38e0a4 1# Copyright 1998, 2007, 2008, 2009, 2010 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 15
c906108c
SS
16# This file was written by Michael Snyder (msnyder@cygnus.com)
17
18load_lib "trace-support.exp";
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
c906108c
SS
24
25gdb_exit
26gdb_start
27
f8b7eaf3
DJ
28set testfile "actions"
29set srcfile ${testfile}.c
30set binfile $objdir/$subdir/actions
31if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
32 executable {debug nowarnings}] != "" } {
33 untested actions.exp
34 return -1
c906108c
SS
35}
36gdb_reinitialize_dir $srcdir/$subdir
37
38# If testing on a remote host, download the source file.
39# remote_download host $srcdir/$subdir/$srcfile
40
41gdb_file_cmd $binfile
42
43# define relative source line numbers:
44# all subsequent line numbers are relative to this first one (baseline)
45
46set baseline [gdb_find_recursion_test_baseline $srcfile];
47if { $baseline == -1 } then {
48 fail "Could not find gdb_recursion_test function"
49 return;
50}
51
52set testline1 [expr $baseline + 7]
53
54#
55# test actions command
56#
57
58gdb_delete_tracepoints
59set trcpt1 [gdb_gettpnum gdb_c_test];
60set trcpt2 [gdb_gettpnum gdb_asm_test];
61set trcpt3 [gdb_gettpnum $testline1];
62if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
63 fail "setting tracepoints"
64 return;
65}
66
67# 5.1 actions of specified tracepoint
68
69send_gdb "info tracepoints\n"
70gdb_expect {
71 -re "Actions for tracepoint \[0-9\]+:.*$gdb_prompt $" {
72 fail "5.1a: testsuite failure (tracepoint already has action)!"
73 }
74 -re "No tracepoints.*$gdb_prompt $" {
75 fail "5.1a: set three tracepoints, no actions (No tracepoints!)"
76 }
77 -re "$gdb_prompt $" {
78 pass "5.1a: set three tracepoints, no actions"
79 }
80}
81
82gdb_trace_setactions "5.1b: set actions for first tracepoint" \
83 "$trcpt1" \
84 "collect gdb_char_test" "^$"
85
1042e4c0
SS
86gdb_test "info tracepoints" \
87 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
88\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
a7bdde9e 89\[\t \]+collect gdb_char_test.
1042e4c0
SS
90\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
91\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
92 "5.1c: verify actions set for first tracepoint"
c906108c
SS
93
94gdb_trace_setactions "5.1d: set actions for second tracepoint" \
95 "$trcpt2" \
96 "collect gdb_short_test" "^$"
97
1042e4c0
SS
98gdb_test "info tracepoints" \
99 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
100\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
a7bdde9e 101\[\t \]+collect gdb_char_test.
1042e4c0 102\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
a7bdde9e 103\[\t \]+collect gdb_short_test.
1042e4c0
SS
104\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
105 "5.1e: verify actions set for second tracepoint"
c906108c
SS
106
107gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
108 "" \
109 "collect gdb_long_test" "^$"
110
1042e4c0
SS
111gdb_test "info tracepoints" \
112 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
113\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
a7bdde9e 114\[\t \]+collect gdb_char_test.
1042e4c0 115\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
a7bdde9e 116\[\t \]+collect gdb_short_test.
1042e4c0 117\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
a7bdde9e 118\[\t \]+collect gdb_long_test." \
1042e4c0 119 "5.1e: verify actions set for second tracepoint"
c906108c
SS
120
121# 5.3 replace actions set earlier
122
123gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
124 "$trcpt1" \
125 "collect gdb_struct1_test" "^$"
126
1042e4c0
SS
127gdb_test "info tracepoints" \
128 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
129\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
a7bdde9e 130\[\t \]+collect gdb_struct1_test.
1042e4c0 131\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
a7bdde9e 132\[\t \]+collect gdb_short_test.
1042e4c0 133\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
a7bdde9e 134\[\t \]+collect gdb_long_test." \
1042e4c0 135 "5.3b: verify actions set for first tracepoint"
c906108c
SS
136
137#
138# test end command (all by itself)
139#
140
141# 5.4 end outside of context
142
143gdb_test "end" "This command cannot be used at the top level." \
144 "5.4: 'end' command out of context"
145
146# 5.5 empty actions (just an end with no other actions)
147
148gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
149 "$trcpt1"
150
151send_gdb "info tracepoints\n"
152gdb_expect {
153 -re "No tracepoints.*$gdb_prompt $" {
154 fail "5.5c: verify NO actions for first tracepoint"
155 }
156 -re "Actions for.* $trcpt1:.*$gdb_prompt $" {
157 fail "5.5c: verify NO actions for first tracepoint"
158 }
159 -re "$gdb_prompt $" {
160 pass "5.5c: verify NO actions for first tracepoint"
161 }
162}
163
164# 5.6 actions for invalid tracepoint number
165
166gdb_test "actions [expr $trcpt2 + $trcpt3]" \
167 "No tracepoint number [expr $trcpt2 + $trcpt3]." \
168 "5.6: actions for invalid tracepoint number"
169
170# 5.7 invalid action (other than 'collect', 'while-stepping' or 'end')
171# "warning: .print gdb_c_test. is not a supported trace.*> $" \
172
173gdb_trace_setactions "5.7: invalid action" \
174 "$trcpt1" \
175 "print gdb_c_test" \
fff87407 176 "`print gdb_c_test' is not a supported tracepoint action"
c906108c
SS
177
178# 5.8 help actions (collect, while-stepping, end)
179
180gdb_test "help actions" \
181 "Specify the actions to be taken at a tracepoint.*" \
182 "5.8a: help actions"
183
184gdb_test "help collect" \
185 "Specify one or more data items to be collected at a tracepoint.*" \
186 "5.8b: help collect"
187
188gdb_test "help while-stepping" \
189 "Specify single-stepping behavior at a tracepoint.*" \
190 "5.8c: help while-stepping"
191
192gdb_test "help end" "Ends a list of commands or actions.*" \
193 "5.8d: help end"
194
236f1d4d
SS
195# 5.9 default-collect
196
197gdb_test "set default-collect gdb_char_test, gdb_long_test - 100" \
198 "" \
199 "5.9a: set default-collect"
200
201gdb_test "show default-collect" \
202 "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \
203 "5.9b: show default-collect"
6da95a67 204
64e17368
SS
205gdb_test "set default-collect" \
206 "" \
207 "5.9c: set default-collect"
208
6da95a67
SS
209# 5.10 teval
210
211gdb_test "tvariable \$tsv" \
212 "Trace state variable \\\$tsv created, with initial value 0." \
213 "Create a trace state variable"
214
215gdb_trace_setactions "5.10a: set teval action for first tracepoint" \
216 "$trcpt1" \
217 "teval gdb_char_test" "^$"
218
219gdb_trace_setactions "5.10a: set teval action for second tracepoint" \
220 "$trcpt2" \
221 "teval \$tsv += 1" "^$"
222
223gdb_test "info tracepoints" \
224 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
225\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
a7bdde9e 226\[\t \]+teval gdb_char_test.
6da95a67 227\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
a7bdde9e 228\[\t \]+teval \\\$tsv \\\+= 1.
6da95a67 229\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
a7bdde9e 230\[\t \]+collect gdb_long_test." \
6da95a67
SS
231 "5.10a: verify teval actions set for two tracepoints"
232
This page took 0.936123 seconds and 4 git commands to generate.