OSDN Git Service

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