1 # Copyright 2011 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 load_lib "trace-support.exp";
17 set testfile "trace-break"
18 set executable $testfile
19 set srcfile $testfile.c
20 set binfile $objdir/$subdir/$testfile
21 set expfile $testfile.exp
23 # Some targets have leading underscores on assembly symbols.
24 set additional_flags [gdb_target_symbol_prefix_flags]
26 if [prepare_for_testing $expfile $executable $srcfile \
27 [list debug $additional_flags]] {
28 untested "failed to prepare for trace tests"
33 fail "Can't run to main to check for trace support"
37 if ![gdb_target_supports_trace] {
38 unsupported "target does not support trace"
42 # Set breakpoint and tracepoint at the same address.
44 proc break_trace_same_addr_1 { trace_type option } {
49 set old_pf_prefix $pf_prefix
50 set pf_prefix "$pf_prefix 1 $trace_type $option:"
52 # Start with a fresh gdb.
53 clean_restart ${executable}
55 fail "Can't run to main"
56 set pf_prefix $old_pf_prefix
60 gdb_test_no_output "set breakpoint always-inserted ${option}"
62 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
64 gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
65 gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
67 gdb_test_no_output "tstart"
69 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to set_point"
71 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
72 gdb_test_no_output "tstop"
74 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
75 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
77 set pf_prefix $old_pf_prefix
80 # Set multiple tracepoints at the same address.
82 proc break_trace_same_addr_2 { trace_type1 trace_type2 option } {
87 set old_pf_prefix $pf_prefix
88 set pf_prefix "$pf_prefix 2 $trace_type1 $trace_type2 $option:"
90 # Start with a fresh gdb.
91 clean_restart ${executable}
93 fail "Can't run to main"
94 set pf_prefix $old_pf_prefix
98 gdb_test_no_output "set breakpoint always-inserted ${option}"
100 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
102 gdb_test "${trace_type1} set_point" \
103 "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
104 "${trace_type1} set_point (1)"
106 gdb_test "${trace_type2} set_point" \
107 "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
108 "${trace_type2} set_point (2)"
110 gdb_test_no_output "tstart"
111 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
113 gdb_test_no_output "tstop"
115 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
116 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
117 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
119 set pf_prefix $old_pf_prefix
122 # Set breakpoint and tracepoint at the same address. Delete breakpoint, and verify
123 # that tracepoint still works.
125 proc break_trace_same_addr_3 { trace_type option } {
130 set old_pf_prefix $pf_prefix
131 set pf_prefix "$pf_prefix 3 $trace_type $option:"
133 # Start with a fresh gdb.
134 clean_restart ${executable}
136 fail "Can't run to main"
137 set pf_prefix $old_pf_prefix
141 gdb_test_no_output "set breakpoint always-inserted ${option}"
142 gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
143 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
145 gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
146 gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
148 gdb_test_no_output "tstart"
150 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to marker"
151 gdb_test "delete break 4"
153 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
154 gdb_test_no_output "tstop"
156 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
157 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
159 set pf_prefix $old_pf_prefix
162 # Set breakpoint and tracepoint at the same address. Delete tracepoint, and verify
163 # that breakpoint still works.
165 proc break_trace_same_addr_4 { trace_type option } {
170 set old_pf_prefix $pf_prefix
171 set pf_prefix "$pf_prefix 4 $trace_type $option:"
173 # Start with a fresh gdb.
174 clean_restart ${executable}
176 fail "Can't run to main"
177 set pf_prefix $old_pf_prefix
181 gdb_test_no_output "set breakpoint always-inserted ${option}"
182 gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
183 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
185 gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
186 gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
188 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to marker"
189 # Delete tracepoint set on set_point.
190 gdb_test "delete trace 5"
192 gdb_test "tstart" "No tracepoints defined, not starting trace.*"
194 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to set_point"
195 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
196 gdb_test "tstop" "Trace is not running.*"
198 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
200 set pf_prefix $old_pf_prefix
203 foreach break_always_inserted { "on" "off" } {
204 break_trace_same_addr_1 "trace" ${break_always_inserted}
205 break_trace_same_addr_2 "trace" "trace" ${break_always_inserted}
206 break_trace_same_addr_3 "trace" ${break_always_inserted}
207 break_trace_same_addr_4 "trace" ${break_always_inserted}
210 set libipa $objdir/../gdbserver/libinproctrace.so
211 gdb_load_shlibs $libipa
213 # Can't use prepare_for_testing, because that splits compiling into
214 # building objects and then linking, and we'd fail with "linker input
215 # file unused because linking not done" when building the object.
217 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
218 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
219 untested "failed to compile ftrace tests"
222 clean_restart ${executable}
225 fail "Can't run to main for ftrace tests"
229 gdb_reinitialize_dir $srcdir/$subdir
230 if { [gdb_test "info sharedlibrary" ".*libinproctrace\.so.*" "IPA loaded"] != 0 } {
231 untested "Could not find IPA lib loaded"
233 foreach break_always_inserted { "on" "off" } {
234 break_trace_same_addr_1 "ftrace" ${break_always_inserted}
235 break_trace_same_addr_2 "trace" "ftrace" ${break_always_inserted}
236 break_trace_same_addr_2 "ftrace" "trace" ${break_always_inserted}
237 break_trace_same_addr_3 "ftrace" ${break_always_inserted}
238 break_trace_same_addr_4 "ftrace" ${break_always_inserted}