OSDN Git Service

60a374cd486c1add8a41fe0064c54c0914fe0ac3
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.trace / actions.exp
1 #   Copyright 1998, 2007, 2008, 2009, 2010, 2011
2 #   Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # This file was written by Michael Snyder (msnyder@cygnus.com)
18
19 load_lib "trace-support.exp";
20
21 if $tracelevel then {
22     strace $tracelevel
23 }
24
25
26 gdb_exit
27 gdb_start
28
29 set testfile "actions"
30 set srcfile ${testfile}.c
31 set binfile $objdir/$subdir/actions
32 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
33           executable {debug nowarnings}] != "" } {
34     untested actions.exp
35     return -1
36 }
37 gdb_reinitialize_dir $srcdir/$subdir
38
39 # If testing on a remote host, download the source file.
40 # remote_download host $srcdir/$subdir/$srcfile
41
42 gdb_file_cmd $binfile
43
44 # define relative source line numbers:
45 # all subsequent line numbers are relative to this first one (baseline)
46
47 set baseline  [gdb_find_recursion_test_baseline $srcfile];
48 if { $baseline == -1 } then {
49     fail "Could not find gdb_recursion_test function"
50     return;
51 }
52
53 set testline1 [expr $baseline + 7]
54
55 #
56 # test actions command
57 #
58
59 gdb_delete_tracepoints
60 set trcpt1 [gdb_gettpnum gdb_c_test];
61 set trcpt2 [gdb_gettpnum gdb_asm_test];
62 set trcpt3 [gdb_gettpnum $testline1];
63 if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
64     fail "setting tracepoints"
65     return;
66 }
67
68 # 5.1 actions of specified tracepoint
69
70 gdb_test_multiple "info tracepoints" "5.1a: set three tracepoints, no actions" {
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
82 gdb_trace_setactions "5.1b: set actions for first tracepoint" \
83         "$trcpt1" \
84         "collect gdb_char_test" "^$"
85
86 gdb_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\]+.
89 \[\t \]+collect gdb_char_test.
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"
93
94 gdb_trace_setactions "5.1d: set actions for second tracepoint" \
95         "$trcpt2" \
96         "collect gdb_short_test" "^$"
97
98 gdb_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\]+.
101 \[\t \]+collect gdb_char_test.
102 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
103 \[\t \]+collect gdb_short_test.
104 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
105                 "5.1e: verify actions set for second tracepoint"
106
107 gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
108         "" \
109         "collect gdb_long_test" "^$"
110
111 gdb_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\]+.
114 \[\t \]+collect gdb_char_test.
115 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
116 \[\t \]+collect gdb_short_test.
117 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
118 \[\t \]+collect gdb_long_test." \
119                 "5.1e: verify actions set for second tracepoint"
120
121 # 5.3 replace actions set earlier
122
123 gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
124         "$trcpt1" \
125         "collect gdb_struct1_test" "^$"
126
127 gdb_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\]+.
130 \[\t \]+collect gdb_struct1_test.
131 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
132 \[\t \]+collect gdb_short_test.
133 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
134 \[\t \]+collect gdb_long_test." \
135                 "5.3b: verify actions set for first tracepoint"
136
137 #
138 # test end command (all by itself)
139 #
140
141 # 5.4 end outside of context
142
143 gdb_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
148 gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
149         "$trcpt1"
150
151 gdb_test_multiple "info tracepoints" "5.5c: verify NO actions for first tracepoint" {
152     -re "No tracepoints.*$gdb_prompt $" {
153         fail "5.5c: verify NO actions for first tracepoint"
154     }
155     -re "Actions for.* $trcpt1:.*$gdb_prompt $" {
156         fail "5.5c: verify NO actions for first tracepoint"
157     }
158     -re "$gdb_prompt $" {
159         pass "5.5c: verify NO actions for first tracepoint"
160     }
161 }
162
163 # 5.6 actions for invalid tracepoint number
164
165 gdb_test "actions [expr $trcpt2 + $trcpt3]" \
166     "No tracepoint number [expr $trcpt2 + $trcpt3]." \
167                         "5.6: actions for invalid tracepoint number"
168
169 # 5.7 invalid action (other than 'collect', 'while-stepping' or 'end')
170 #           "warning: .print gdb_c_test. is not a supported trace.*> $" \
171
172 gdb_trace_setactions "5.7: invalid action" \
173         "$trcpt1" \
174         "print gdb_c_test" \
175         "`print gdb_c_test' is not a supported tracepoint action"
176
177 # 5.8 help actions (collect, while-stepping, end)
178
179 gdb_test "help actions" \
180     "Specify the actions to be taken at a tracepoint.*" \
181                         "5.8a: help actions"
182
183 gdb_test "help collect" \
184     "Specify one or more data items to be collected at a tracepoint.*" \
185                         "5.8b: help collect"
186
187 gdb_test "help while-stepping" \
188     "Specify single-stepping behavior at a tracepoint.*" \
189                         "5.8c: help while-stepping"
190
191 gdb_test "help end" "Ends a list of commands or actions.*" \
192                         "5.8d: help end"
193
194 # 5.9 default-collect
195
196 gdb_test_no_output "set default-collect gdb_char_test, gdb_long_test - 100" \
197     "5.9a: set default-collect"
198
199 gdb_test "show default-collect" \
200     "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \
201     "5.9b: show default-collect"
202
203 gdb_test_no_output "set default-collect" \
204     "5.9c: set default-collect"
205
206 # 5.10 teval
207
208 gdb_test "tvariable \$tsv" \
209   "Trace state variable \\\$tsv created, with initial value 0." \
210   "Create a trace state variable"
211
212 gdb_trace_setactions "5.10a: set teval action for first tracepoint" \
213         "$trcpt1" \
214         "teval gdb_char_test" "^$"
215
216 gdb_trace_setactions "5.10a: set teval action for second tracepoint" \
217         "$trcpt2" \
218         "teval \$tsv += 1" "^$"
219
220 gdb_test "info tracepoints" \
221     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
222 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
223 \[\t \]+teval gdb_char_test.
224 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
225 \[\t \]+teval \\\$tsv \\\+= 1.
226 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
227 \[\t \]+collect gdb_long_test." \
228                 "5.10a: verify teval actions set for two tracepoints"
229