This commit was manufactured by cvs2svn to create branch 'gdb_7_0-branch'.
[external/binutils.git] / gdb / testsuite / gdb.trace / actions.exp
1 #   Copyright 1998, 2007, 2008, 2009 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 if $tracelevel then {
21     strace $tracelevel
22 }
23
24 set prms_id 0
25 set bug_id 0
26
27 gdb_exit
28 gdb_start
29
30 if [istarget "m68k-*-elf"] then {
31     set binfile [board_info target d490_binfile];
32     set srcfile gdb_c_test.c
33 } else {
34     set testfile "actions"
35     set srcfile ${testfile}.c
36     set binfile $objdir/$subdir/actions
37     if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
38             executable {debug nowarnings}] != "" } {
39         untested actions.exp
40         return -1
41     }
42 }
43 gdb_reinitialize_dir $srcdir/$subdir
44
45 # If testing on a remote host, download the source file.
46 # remote_download host $srcdir/$subdir/$srcfile
47
48 gdb_file_cmd $binfile
49
50 # define relative source line numbers:
51 # all subsequent line numbers are relative to this first one (baseline)
52
53 set baseline  [gdb_find_recursion_test_baseline $srcfile];
54 if { $baseline == -1 } then {
55     fail "Could not find gdb_recursion_test function"
56     return;
57 }
58
59 set testline1 [expr $baseline + 7]
60
61 #
62 # test actions command
63 #
64
65 gdb_delete_tracepoints
66 set trcpt1 [gdb_gettpnum gdb_c_test];
67 set trcpt2 [gdb_gettpnum gdb_asm_test];
68 set trcpt3 [gdb_gettpnum $testline1];
69 if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
70     fail "setting tracepoints"
71     return;
72 }
73
74 # 5.1 actions of specified tracepoint
75
76 send_gdb "info tracepoints\n"
77 gdb_expect {
78     -re "Actions for tracepoint \[0-9\]+:.*$gdb_prompt $" {
79         fail "5.1a: testsuite failure (tracepoint already has action)!"
80     }
81     -re "No tracepoints.*$gdb_prompt $" {
82         fail "5.1a: set three tracepoints, no actions (No tracepoints!)"
83     }
84     -re "$gdb_prompt $" {
85         pass "5.1a: set three tracepoints, no actions"
86     }
87 }
88
89 gdb_trace_setactions "5.1b: set actions for first tracepoint" \
90         "$trcpt1" \
91         "collect gdb_char_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 \]+A\[\t \]+collect gdb_char_test.
97 \[\t \]+A\[\t \]+end.
98 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
99 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
100                 "5.1c: verify actions set for first tracepoint"
101
102 gdb_trace_setactions "5.1d: set actions for second tracepoint" \
103         "$trcpt2" \
104         "collect gdb_short_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 \]+A\[\t \]+collect gdb_char_test.
110 \[\t \]+A\[\t \]+end.
111 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
112 \[\t \]+A\[\t \]+collect gdb_short_test.
113 \[\t \]+A\[\t \]+end.
114 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+" \
115                 "5.1e: verify actions set for second tracepoint"
116
117 gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
118         "" \
119         "collect gdb_long_test" "^$"
120
121 gdb_test "info tracepoints" \
122     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
123 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
124 \[\t \]+A\[\t \]+collect gdb_char_test.
125 \[\t \]+A\[\t \]+end.
126 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
127 \[\t \]+A\[\t \]+collect gdb_short_test.
128 \[\t \]+A\[\t \]+end.
129 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
130 \[\t \]+A\[\t \]+collect gdb_long_test.
131 \[\t \]+A\[\t \]+end." \
132                 "5.1e: verify actions set for second tracepoint"
133
134 # 5.3 replace actions set earlier
135
136 gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
137         "$trcpt1" \
138         "collect gdb_struct1_test" "^$"
139
140 gdb_test "info tracepoints" \
141     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
142 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
143 \[\t \]+A\[\t \]+collect gdb_struct1_test.
144 \[\t \]+A\[\t \]+end.
145 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
146 \[\t \]+A\[\t \]+collect gdb_short_test.
147 \[\t \]+A\[\t \]+end.
148 \[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
149 \[\t \]+A\[\t \]+collect gdb_long_test.
150 \[\t \]+A\[\t \]+end." \
151                 "5.3b: verify actions set for first tracepoint"
152
153 #
154 # test end command (all by itself)
155 #
156
157 # 5.4 end outside of context
158
159 gdb_test "end" "This command cannot be used at the top level." \
160                         "5.4: 'end' command out of context"
161
162 # 5.5 empty actions (just an end with no other actions)
163
164 gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
165         "$trcpt1"
166
167 send_gdb "info tracepoints\n"
168 gdb_expect {
169     -re "No tracepoints.*$gdb_prompt $" {
170         fail "5.5c: verify NO actions for first tracepoint"
171     }
172     -re "Actions for.* $trcpt1:.*$gdb_prompt $" {
173         fail "5.5c: verify NO actions for first tracepoint"
174     }
175     -re "$gdb_prompt $" {
176         pass "5.5c: verify NO actions for first tracepoint"
177     }
178 }
179
180 # 5.6 actions for invalid tracepoint number
181
182 gdb_test "actions [expr $trcpt2 + $trcpt3]" \
183     "No tracepoint number [expr $trcpt2 + $trcpt3]." \
184                         "5.6: actions for invalid tracepoint number"
185
186 # 5.7 invalid action (other than 'collect', 'while-stepping' or 'end')
187 #           "warning: .print gdb_c_test. is not a supported trace.*> $" \
188
189 gdb_trace_setactions "5.7: invalid action" \
190         "$trcpt1" \
191         "print gdb_c_test" \
192         "warning: .print gdb_c_test. is not a supported trace"
193
194 # 5.8 help actions (collect, while-stepping, end)
195
196 gdb_test "help actions" \
197     "Specify the actions to be taken at a tracepoint.*" \
198                         "5.8a: help actions"
199
200 gdb_test "help collect" \
201     "Specify one or more data items to be collected at a tracepoint.*" \
202                         "5.8b: help collect"
203
204 gdb_test "help while-stepping" \
205     "Specify single-stepping behavior at a tracepoint.*" \
206                         "5.8c: help while-stepping"
207
208 gdb_test "help end" "Ends a list of commands or actions.*" \
209                         "5.8d: help end"
210