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