1 # Copyright
2011-2022 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 if {[skip_shlib_tests
]} {
22 set executable $testfile
23 set expfile $testfile.exp
25 # Some targets have leading underscores
on assembly symbols.
26 set additional_flags
[gdb_target_symbol_prefix_flags
]
28 if ![gdb_trace_common_supports_arch
] {
29 unsupported
"no trace-common.h support for arch"
33 if [prepare_for_testing
"failed to prepare" $executable $srcfile \
34 [list debug $additional_flags
]] {
42 if ![gdb_target_supports_trace
] {
43 unsupported
"target does not support trace"
47 set libipa
[get_in_proc_agent
]
48 set remote_libipa
[gdb_load_shlib $libipa
]
50 # Can
't use prepare_for_testing, because that splits compiling into
51 # building objects and then linking, and we'd fail with
"linker input
52 # file unused because linking not done
" when building the object.
54 if { [gdb_compile
"$srcdir/$subdir/$srcfile" $binfile \
55 executable
[list debug $additional_flags shlib
=$libipa
] ] != "" } {
56 untested
"failed to compile"
60 clean_restart $
{executable
}
66 if { [gdb_test
"info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
67 untested
"could not find IPA lib loaded"
71 proc test_tracepoints
{ trace_command condition num_frames
{ kfail_proc
0 } } {
72 global executable gdb_prompt
74 clean_restart $
{executable
}
80 gdb_breakpoint
"begin" qualified
82 gdb_breakpoint
"end" qualified
84 with_test_prefix
"${trace_command}: ${condition}" {
86 gdb_test
"${trace_command} set_point if ${condition}" \
87 "\(Fast t|T\)racepoint .*" \
90 gdb_test
"continue" ".*Breakpoint \[0-9\]+, begin .*" \
91 "advance to trace begin"
93 gdb_test_no_output
"tstart" "start trace experiment"
95 gdb_test_multiple
"continue" "advance through tracing" {
96 -re
".*Breakpoint \[0-9\]+, end .*$gdb_prompt $" {
97 pass
"advance through tracing"
99 -re
"Program received signal SIGSEGV, Segmentation fault\\..*$gdb_prompt $" {
100 if { $kfail_proc
!= 0 } {
101 $kfail_proc $trace_command
103 fail
"advance through tracing"
107 if { $kfail_proc
!= 0 } {
108 $kfail_proc $trace_command
111 ".*Trace .*Collected $num_frames .*" \
112 "check $num_frames frames were collected."
114 gdb_test
"tstop" "" ""
118 # These callbacks identify known failures
for certain architectures. They
119 # are called either
if GDBserver crashes or has not traced the correct
122 proc
18955_x86_64_failure
{ trace_command
} {
123 if { $trace_command
== "ftrace" } {
124 setup_kfail
"gdb/18955" "x86_64-*-linux*"
128 proc
18955_i386_failure
{ trace_command
} {
129 if { $trace_command
== "ftrace" } {
130 setup_kfail
"gdb/18955" "i\[34567\]86-*-*"
134 foreach trace_command
{ "trace" "ftrace" } {
135 # This condition is always true as the PC should be
set to the tracepoint
137 test_tracepoints $trace_command
"\$$pcreg == *set_point" 10
139 # Can we read local variables?
140 test_tracepoints $trace_command
"arg8 == 1 || arg8 == 2" 2 18955_x86_64_failure
141 test_tracepoints $trace_command
"arg16 == 257 || arg16 == 258" 2 18955_x86_64_failure
142 test_tracepoints $trace_command
"arg32 == 65537 || arg32 == 65538" 2 18955_x86_64_failure
143 test_tracepoints $trace_command
"arg64 == 4294967297 || arg64 == 4294967298" 2 18955_x86_64_failure
144 # Can we read global variables?
145 test_tracepoints $trace_command
"arg16 == 257 && globvar == 1" 1 18955_x86_64_failure
147 # Test various operations to cover as many opcodes as possible.
148 test_tracepoints $trace_command
"21 == 21" 10
149 test_tracepoints $trace_command
"11 == 21" 0
151 test_tracepoints $trace_command
"21 != 42" 10
152 test_tracepoints $trace_command
"42 != 42" 0
154 test_tracepoints $trace_command
"21 + 21 == 42" 10
155 test_tracepoints $trace_command
"21 + 21 == 11" 0
157 test_tracepoints $trace_command
"42 - 21 == 21" 10
158 test_tracepoints $trace_command
"42 - 21 == 11" 0
160 test_tracepoints $trace_command
"21 * 2 == 42" 10
161 test_tracepoints $trace_command
"21 * 2 == 11" 0
163 test_tracepoints $trace_command
"21 << 1 == 42" 10
164 test_tracepoints $trace_command
"21 << 1 == 11" 0
166 test_tracepoints $trace_command
"42 >> 1 == 21" 10
167 test_tracepoints $trace_command
"42 >> 1 == 11" 0
169 test_tracepoints $trace_command
"-(21 << 1) == -42" 10
170 test_tracepoints $trace_command
"-(21 << 1) == -11" 0
172 test_tracepoints $trace_command
"-42 >> 1 == -21" 10
173 test_tracepoints $trace_command
"-42 >> 1 == -11" 0
175 test_tracepoints $trace_command
"(0xabababab & 0x0000ffff) == 0xabab" 10
176 test_tracepoints $trace_command
"(0xabababab & 0x0000ffff) == 0xffff" 0
178 test_tracepoints $trace_command
"(0xabababab | 0x0000ffff) == 0xababffff" 10
179 test_tracepoints $trace_command
"(0xabababab | 0x0000ffff) == 0xeeeedddd" 0
181 test_tracepoints $trace_command
"(0xaaaaaaaa ^ 0x55555555) == 0xffffffff" 10
182 test_tracepoints $trace_command
"(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
184 test_tracepoints $trace_command
"~0xaaaaaaaa == 0x55555555" 10
185 test_tracepoints $trace_command
"~0xaaaaaaaa == 0x11111111" 0
187 test_tracepoints $trace_command
"21 < 42" 10
188 test_tracepoints $trace_command
"61 < 42" 0
190 test_tracepoints $trace_command
"21U < 42U" 10
191 test_tracepoints $trace_command
"61U < 42U" 0
193 test_tracepoints $trace_command
"42 <= 42" 10
194 test_tracepoints $trace_command
"42 <= 11" 0
196 test_tracepoints $trace_command
"42 >= 42" 10
197 test_tracepoints $trace_command
"11 >= 42" 0
199 test_tracepoints $trace_command
"42 > 21" 10
200 test_tracepoints $trace_command
"11 > 21" 0
202 test_tracepoints $trace_command
"(21 < 42 ? 0 : 1) == 0" 10 18955_i386_failure
203 test_tracepoints $trace_command
"(66 < 42 ? 0 : 1) == 0" 0 18955_i386_failure
205 test_tracepoints $trace_command
"(42 <= 42 ? 0 : 1) == 0" 10
206 test_tracepoints $trace_command
"(66 <= 42 ? 0 : 1) == 0" 0
208 test_tracepoints $trace_command
"(42 >= 42 ? 0 : 1) == 0" 10
209 test_tracepoints $trace_command
"(11 >= 42 ? 0 : 1) == 0" 0
211 test_tracepoints $trace_command
"(42 > 21 ? 0 : 1) == 0" 10 18955_i386_failure
212 test_tracepoints $trace_command
"(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
214 test_tracepoints $trace_command
"\$trace_timestamp >= 0" 10
216 # Test operations with
64 bit operands.
217 test_tracepoints $trace_command
"0xabababab00000000 == 0xcdcdcdcd00000000" 0
218 test_tracepoints $trace_command
"0xabababab00000000 == 0xabababab00000000" 10
220 test_tracepoints $trace_command
"!0xabababab00000000 == 0" 10
221 test_tracepoints $trace_command
"!0x0 == 0" 0
223 test_tracepoints $trace_command
"0xababababcdcdcdcd + 0x1111111143434343 == 0xbcbcbcbd11111110" 10
224 test_tracepoints $trace_command
"0xababababcdcdcdff + 0x1111111143434343 == 0xbcbcbcbd11111110" 0
226 test_tracepoints $trace_command
"0xababababcdcdcdcd - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 10
227 test_tracepoints $trace_command
"0xababababcdcdcdff - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 0
229 test_tracepoints $trace_command
"0xababababcdcdcdcd * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 10
230 test_tracepoints $trace_command
"0xababababcdcdcdff * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 0
232 test_tracepoints $trace_command
"0x00abababcdcdcdcd << 1 == 0x15757579b9b9b9a" 10
233 test_tracepoints $trace_command
"0x00abababcdcdcdff << 1 == 0x15757579b9b9b9a" 0
235 test_tracepoints $trace_command
"0x00abababcdcdcdcd << 46 == 0x7373400000000000" 10
236 test_tracepoints $trace_command
"0x00abababcdcdcdff << 46 == 0x7373400000000000" 0
239 test_tracepoints $trace_command
"0x00abababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 10
240 test_tracepoints $trace_command
"0x00bcababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 0
242 test_tracepoints $trace_command
"0x00abababcdcdcdcd >> 46 == 0x2ae" 10
243 test_tracepoints $trace_command
"0x00bcababcdcdcdcd >> 46 == 0x2ae" 0
246 test_tracepoints $trace_command
"0xababababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 10
247 test_tracepoints $trace_command
"0xcdabababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 0
249 test_tracepoints $trace_command
"0xababababcdcdcdcdUL >> 46 == 0x2aeaeUL" 10
250 test_tracepoints $trace_command
"0xcdabababcdcdcdcdUL >> 46 == 0x2aeaeUL" 0
252 test_tracepoints $trace_command
"-(0x00abababcdcdcdcd << 1) == -0x15757579b9b9b9a" 10
253 test_tracepoints $trace_command
"-(0x00abababcdcdcdff << 1) == -0x15757579b9b9b9a" 0
255 test_tracepoints $trace_command
"-(0x00abababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 10
256 test_tracepoints $trace_command
"-(0x00cdababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 0
258 test_tracepoints $trace_command
"(0xababababcdcdcdcd & 0x00000fffffffffff) == 0x00000babcdcdcdcd" 10
259 test_tracepoints $trace_command
"(0xababababcdcdcdcd & 0x00000fffffffff00) == 0x00000babcdcdcdcd" 0
261 test_tracepoints $trace_command
"(0xababababcdcdcdcd | 0x00000fffffffffff) == 0xababafffffffffff" 10
262 test_tracepoints $trace_command
"(0xababababcdcdcdcd | 0x00000fffffffff00) == 0xababafffffffffff" 0
264 test_tracepoints $trace_command
"(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555555) == 0xffffffffffffffff" 10
265 test_tracepoints $trace_command
"(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555111) == 0xffffffffffffffff" 0
267 test_tracepoints $trace_command
"~0xaaaaaaaaaaaaaaaa == 0x5555555555555555" 10
268 test_tracepoints $trace_command
"~0xaaaaaaaaaaaaaaaa == 0x5555555555555111" 0
271 test_tracepoints $trace_command
"0x99999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 10
272 test_tracepoints $trace_command
"0xbb999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 0
274 test_tracepoints $trace_command
"0x99999999bbbbbbbb < 0x99999999cccccccc" 10
275 test_tracepoints $trace_command
"0x99999999eebbbbbb < 0x99999999cccccccc" 0
277 test_tracepoints $trace_command
"0x99999999bbbbbbbb <= 0x99999999bbbbbbbb" 10
278 test_tracepoints $trace_command
"0xbb999999eebbbbbb <= 0x99999999bbbbbbbb" 0
281 test_tracepoints $trace_command
"0x09999999bbbbbbbb < 0x0aaaaaaaaaaaaaaa" 10
282 test_tracepoints $trace_command
"0x0bb99999ccbbbbbb < 0x0aaaaaaaaaaaaaaa" 0
284 test_tracepoints $trace_command
"0x09999999bbbbbbbb < 0x09999999cccccccc" 10
285 test_tracepoints $trace_command
"0x09999999ddbbbbbb < 0x09999999cccccccc" 0
287 test_tracepoints $trace_command
"0x09999999bbbbbbbb <= 0x09999999bbbbbbbb" 10
288 test_tracepoints $trace_command
"0x0aa99999bbbbbbbb <= 0x09999999bbbbbbbb" 0
290 test_tracepoints $trace_command
"0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb" 10
291 test_tracepoints $trace_command
"0x088aaaaabbaaaaaa > 0x09999999bbbbbbbb" 0
293 test_tracepoints $trace_command
"(0xabababab00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 10
294 test_tracepoints $trace_command
"(0xcdcdcdcd00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 0
296 test_tracepoints $trace_command
"(0xabababab00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 10
297 test_tracepoints $trace_command
"(0xcdcdcdcd00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 0
299 test_tracepoints $trace_command
"(0x09999999bbbbbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 10 18955_i386_failure
300 test_tracepoints $trace_command
"(0x09999999eeebbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 0 18955_i386_failure
302 test_tracepoints $trace_command
"(0x09999999bbbbbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
303 test_tracepoints $trace_command
"(0x09999999eeebbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
305 test_tracepoints $trace_command
"(0x09999999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
306 test_tracepoints $trace_command
"(0x00099999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
308 test_tracepoints $trace_command
"(0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
309 test_tracepoints $trace_command
"(0x00088888ccaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 0