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