]>
Commit | Line | Data |
---|---|---|
b9fd1791 PA |
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. | |
6 | # | |
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. | |
11 | # | |
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/>. | |
14 | ||
15 | load_lib "trace-support.exp"; | |
16 | ||
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 | |
22 | ||
23 | # Some targets have leading underscores on assembly symbols. | |
24 | set additional_flags [gdb_target_symbol_prefix_flags] | |
25 | ||
26 | if [prepare_for_testing $expfile $executable $srcfile \ | |
27 | [list debug $additional_flags]] { | |
28 | untested "failed to prepare for trace tests" | |
29 | return -1 | |
30 | } | |
31 | ||
32 | if ![runto_main] { | |
33 | fail "Can't run to main to check for trace support" | |
34 | return -1 | |
35 | } | |
36 | ||
37 | if ![gdb_target_supports_trace] { | |
38 | unsupported "target does not support trace" | |
39 | return -1; | |
40 | } | |
41 | ||
42 | # Set breakpoint and tracepoint at the same address. | |
43 | ||
44 | proc break_trace_same_addr_1 { trace_type option } { | |
45 | global executable | |
46 | global pf_prefix | |
47 | global hex | |
48 | ||
49 | set old_pf_prefix $pf_prefix | |
50 | set pf_prefix "$pf_prefix 1 $trace_type $option:" | |
51 | ||
52 | # Start with a fresh gdb. | |
53 | clean_restart ${executable} | |
54 | if ![runto_main] { | |
55 | fail "Can't run to main" | |
56 | set pf_prefix $old_pf_prefix | |
57 | return -1 | |
58 | } | |
59 | ||
60 | gdb_test_no_output "set breakpoint always-inserted ${option}" | |
61 | ||
62 | gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" | |
63 | ||
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.*" | |
66 | ||
67 | gdb_test_no_output "tstart" | |
68 | ||
69 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to set_point" | |
70 | ||
71 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
72 | gdb_test_no_output "tstop" | |
73 | ||
74 | gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" | |
75 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
76 | ||
77 | set pf_prefix $old_pf_prefix | |
78 | } | |
79 | ||
80 | # Set multiple tracepoints at the same address. | |
81 | ||
82 | proc break_trace_same_addr_2 { trace_type1 trace_type2 option } { | |
83 | global executable | |
84 | global pf_prefix | |
85 | global hex | |
86 | ||
87 | set old_pf_prefix $pf_prefix | |
88 | set pf_prefix "$pf_prefix 2 $trace_type1 $trace_type2 $option:" | |
89 | ||
90 | # Start with a fresh gdb. | |
91 | clean_restart ${executable} | |
92 | if ![runto_main] { | |
93 | fail "Can't run to main" | |
94 | set pf_prefix $old_pf_prefix | |
95 | return -1 | |
96 | } | |
97 | ||
98 | gdb_test_no_output "set breakpoint always-inserted ${option}" | |
99 | ||
100 | gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" | |
101 | ||
102 | gdb_test "${trace_type1} set_point" \ | |
103 | "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \ | |
104 | "${trace_type1} set_point (1)" | |
105 | ||
106 | gdb_test "${trace_type2} set_point" \ | |
107 | "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \ | |
108 | "${trace_type2} set_point (2)" | |
109 | ||
110 | gdb_test_no_output "tstart" | |
111 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
112 | ||
113 | gdb_test_no_output "tstop" | |
114 | ||
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\\..*" | |
118 | ||
119 | set pf_prefix $old_pf_prefix | |
120 | } | |
121 | ||
122 | # Set breakpoint and tracepoint at the same address. Delete breakpoint, and verify | |
123 | # that tracepoint still works. | |
124 | ||
125 | proc break_trace_same_addr_3 { trace_type option } { | |
126 | global executable | |
127 | global pf_prefix | |
128 | global hex | |
129 | ||
130 | set old_pf_prefix $pf_prefix | |
131 | set pf_prefix "$pf_prefix 3 $trace_type $option:" | |
132 | ||
133 | # Start with a fresh gdb. | |
134 | clean_restart ${executable} | |
135 | if ![runto_main] { | |
136 | fail "Can't run to main" | |
137 | set pf_prefix $old_pf_prefix | |
138 | return -1 | |
139 | } | |
140 | ||
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.*" | |
144 | ||
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.*" | |
147 | ||
148 | gdb_test_no_output "tstart" | |
149 | ||
150 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to marker" | |
151 | gdb_test "delete break 4" | |
152 | ||
153 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
154 | gdb_test_no_output "tstop" | |
155 | ||
156 | gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" | |
157 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
158 | ||
159 | set pf_prefix $old_pf_prefix | |
160 | } | |
161 | ||
162 | # Set breakpoint and tracepoint at the same address. Delete tracepoint, and verify | |
163 | # that breakpoint still works. | |
164 | ||
165 | proc break_trace_same_addr_4 { trace_type option } { | |
166 | global executable | |
167 | global pf_prefix | |
168 | global hex | |
169 | ||
170 | set old_pf_prefix $pf_prefix | |
171 | set pf_prefix "$pf_prefix 4 $trace_type $option:" | |
172 | ||
173 | # Start with a fresh gdb. | |
174 | clean_restart ${executable} | |
175 | if ![runto_main] { | |
176 | fail "Can't run to main" | |
177 | set pf_prefix $old_pf_prefix | |
178 | return -1 | |
179 | } | |
180 | ||
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.*" | |
184 | ||
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.*" | |
187 | ||
188 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to marker" | |
189 | # Delete tracepoint set on set_point. | |
190 | gdb_test "delete trace 5" | |
191 | ||
192 | gdb_test "tstart" "No tracepoints defined, not starting trace.*" | |
193 | ||
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.*" | |
197 | ||
198 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
199 | ||
200 | set pf_prefix $old_pf_prefix | |
201 | } | |
202 | ||
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} | |
208 | } | |
209 | ||
210 | set libipa $objdir/../gdbserver/libinproctrace.so | |
211 | gdb_load_shlibs $libipa | |
212 | ||
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. | |
216 | ||
217 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
218 | executable [list debug $additional_flags shlib=$libipa] ] != "" } { | |
219 | untested "failed to compile ftrace tests" | |
220 | return -1 | |
221 | } | |
222 | clean_restart ${executable} | |
223 | ||
224 | if ![runto_main] { | |
225 | fail "Can't run to main for ftrace tests" | |
226 | return 0 | |
227 | } | |
228 | ||
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" | |
232 | } else { | |
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} | |
239 | } | |
240 | } |