1 # Copyright 1998, 2007, 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
18 load_lib "trace-support.exp";
30 if [istarget "m68k-*-elf"] then {
31 set binfile [board_info target d490_binfile];
32 set srcfile gdb_c_test.c
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}] != "" } {
43 gdb_reinitialize_dir $srcdir/$subdir
45 # If testing on a remote host, download the source file.
46 # remote_download host $srcdir/$subdir/$srcfile
50 # define relative source line numbers:
51 # all subsequent line numbers are relative to this first one (baseline)
53 set baseline [gdb_find_recursion_test_baseline $srcfile];
54 if { $baseline == -1 } then {
55 fail "Could not find gdb_recursion_test function"
59 set testline1 [expr $baseline + 7]
62 # test actions command
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"
74 # 5.1 actions of specified tracepoint
76 send_gdb "info tracepoints\n"
78 -re "Actions for tracepoint \[0-9\]+:.*$gdb_prompt $" {
79 fail "5.1a: testsuite failure (tracepoint already has action)!"
81 -re "No tracepoints.*$gdb_prompt $" {
82 fail "5.1a: set three tracepoints, no actions (No tracepoints!)"
85 pass "5.1a: set three tracepoints, no actions"
89 gdb_trace_setactions "5.1b: set actions for first tracepoint" \
91 "collect gdb_char_test" "^$"
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.
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"
102 gdb_trace_setactions "5.1d: set actions for second tracepoint" \
104 "collect gdb_short_test" "^$"
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"
117 gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
119 "collect gdb_long_test" "^$"
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"
134 # 5.3 replace actions set earlier
136 gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
138 "collect gdb_struct1_test" "^$"
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"
154 # test end command (all by itself)
157 # 5.4 end outside of context
159 gdb_test "end" "This command cannot be used at the top level." \
160 "5.4: 'end' command out of context"
162 # 5.5 empty actions (just an end with no other actions)
164 gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \
167 send_gdb "info tracepoints\n"
169 -re "No tracepoints.*$gdb_prompt $" {
170 fail "5.5c: verify NO actions for first tracepoint"
172 -re "Actions for.* $trcpt1:.*$gdb_prompt $" {
173 fail "5.5c: verify NO actions for first tracepoint"
175 -re "$gdb_prompt $" {
176 pass "5.5c: verify NO actions for first tracepoint"
180 # 5.6 actions for invalid tracepoint number
182 gdb_test "actions [expr $trcpt2 + $trcpt3]" \
183 "No tracepoint number [expr $trcpt2 + $trcpt3]." \
184 "5.6: actions for invalid tracepoint number"
186 # 5.7 invalid action (other than 'collect', 'while-stepping' or 'end')
187 # "warning: .print gdb_c_test. is not a supported trace.*> $" \
189 gdb_trace_setactions "5.7: invalid action" \
192 "warning: .print gdb_c_test. is not a supported trace"
194 # 5.8 help actions (collect, while-stepping, end)
196 gdb_test "help actions" \
197 "Specify the actions to be taken at a tracepoint.*" \
200 gdb_test "help collect" \
201 "Specify one or more data items to be collected at a tracepoint.*" \
204 gdb_test "help while-stepping" \
205 "Specify single-stepping behavior at a tracepoint.*" \
206 "5.8c: help while-stepping"
208 gdb_test "help end" "Ends a list of commands or actions.*" \