1 # Copyright 1998, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
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.
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.
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/>.
17 # This file was written by Michael Snyder (msnyder@cygnus.com)
19 load_lib "trace-support.exp";
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}] != "" } {
37 gdb_reinitialize_dir $srcdir/$subdir
39 # If testing on a remote host, download the source file.
40 # remote_download host $srcdir/$subdir/$srcfile
44 # define relative source line numbers:
45 # all subsequent line numbers are relative to this first one (baseline)
47 set baseline [gdb_find_recursion_test_baseline $srcfile];
48 if { $baseline == -1 } then {
49 fail "Could not find gdb_recursion_test function"
53 set testline1 [expr $baseline + 7]
56 # test actions command
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"
68 # 5.1 actions of specified tracepoint
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)!"
74 -re "No tracepoints.*$gdb_prompt $" {
75 fail "5.1a: set three tracepoints, no actions (No tracepoints!)"
78 pass "5.1a: set three tracepoints, no actions"
82 gdb_trace_setactions "5.1b: set actions for first tracepoint" \
84 "collect gdb_char_test" "^$"
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"
94 gdb_trace_setactions "5.1d: set actions for second tracepoint" \
96 "collect gdb_short_test" "^$"
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"
107 gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
109 "collect gdb_long_test" "^$"
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"
121 # 5.3 replace actions set earlier
123 gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
125 "collect gdb_struct1_test" "^$"
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"
138 # test end command (all by itself)
141 # 5.4 end outside of context
143 gdb_test "end" "This command cannot be used at the top level." \
144 "5.4: 'end' command out of context"
146 # 5.5 empty actions (just an end with no other actions)
148 gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
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"
155 -re "Actions for.* $trcpt1:.*$gdb_prompt $" {
156 fail "5.5c: verify NO actions for first tracepoint"
158 -re "$gdb_prompt $" {
159 pass "5.5c: verify NO actions for first tracepoint"
163 # 5.6 actions for invalid tracepoint number
165 gdb_test "actions [expr $trcpt2 + $trcpt3]" \
166 "No tracepoint number [expr $trcpt2 + $trcpt3]." \
167 "5.6: actions for invalid tracepoint number"
169 # 5.7 invalid action (other than 'collect', 'while-stepping' or 'end')
170 # "warning: .print gdb_c_test. is not a supported trace.*> $" \
172 gdb_trace_setactions "5.7: invalid action" \
175 "`print gdb_c_test' is not a supported tracepoint action"
177 # 5.8 help actions (collect, while-stepping, end)
179 gdb_test "help actions" \
180 "Specify the actions to be taken at a tracepoint.*" \
183 gdb_test "help collect" \
184 "Specify one or more data items to be collected at a tracepoint.*" \
187 gdb_test "help while-stepping" \
188 "Specify single-stepping behavior at a tracepoint.*" \
189 "5.8c: help while-stepping"
191 gdb_test "help end" "Ends a list of commands or actions.*" \
194 # 5.9 default-collect
196 gdb_test_no_output "set default-collect gdb_char_test, gdb_long_test - 100" \
197 "5.9a: set default-collect"
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"
203 gdb_test_no_output "set default-collect" \
204 "5.9c: set default-collect"
208 gdb_test "tvariable \$tsv" \
209 "Trace state variable \\\$tsv created, with initial value 0." \
210 "Create a trace state variable"
212 gdb_trace_setactions "5.10a: set teval action for first tracepoint" \
214 "teval gdb_char_test" "^$"
216 gdb_trace_setactions "5.10a: set teval action for second tracepoint" \
218 "teval \$tsv += 1" "^$"
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"