Add variable length tests for emit_ref in trace-condition.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-condition.exp
1 # Copyright 2011-2016 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 standard_testfile
18 set executable $testfile
19 set expfile $testfile.exp
20
21 # Some targets have leading underscores on assembly symbols.
22 set additional_flags [gdb_target_symbol_prefix_flags]
23
24 if [prepare_for_testing $expfile $executable $srcfile \
25 [list debug $additional_flags]] {
26 untested "failed to prepare for trace tests"
27 return -1
28 }
29
30 if ![runto_main] {
31 fail "Can't run to main to check for trace support"
32 return -1
33 }
34
35 if ![gdb_target_supports_trace] {
36 unsupported "target does not support trace"
37 return -1
38 }
39
40 set libipa [get_in_proc_agent]
41 set remote_libipa [gdb_load_shlib $libipa]
42
43 # Can't use prepare_for_testing, because that splits compiling into
44 # building objects and then linking, and we'd fail with "linker input
45 # file unused because linking not done" when building the object.
46
47 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
48 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
49 untested "failed to compile ftrace tests"
50 return -1
51 }
52
53 clean_restart ${executable}
54
55 if ![runto_main] {
56 fail "Can't run to main for ftrace tests"
57 return 0
58 }
59
60 if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
61 untested "Could not find IPA lib loaded"
62 return 1
63 }
64
65 proc test_tracepoints { trace_command condition num_frames { kfail_proc 0 } } {
66 global executable gdb_prompt
67
68 clean_restart ${executable}
69
70 if ![runto_main] {
71 fail "Can't run to main for ftrace tests"
72 return 0
73 }
74
75 gdb_test "break begin" ".*" ""
76
77 gdb_test "break end" ".*" ""
78
79 with_test_prefix "${trace_command}: ${condition}" {
80
81 gdb_test "${trace_command} set_point if ${condition}" \
82 "\(Fast t|T\)racepoint .*" \
83 "set tracepoint"
84
85 gdb_test "continue" ".*Breakpoint \[0-9\]+, begin .*" \
86 "advance to trace begin"
87
88 gdb_test_no_output "tstart" "start trace experiment"
89
90 gdb_test_multiple "continue" "advance through tracing" {
91 -re ".*Breakpoint \[0-9\]+, end .*$gdb_prompt $" {
92 pass "advance through tracing"
93 }
94 -re "Program received signal SIGSEGV, Segmentation fault\\..*$gdb_prompt $" {
95 if { $kfail_proc != 0 } {
96 $kfail_proc $trace_command
97 }
98 fail "advance through tracing"
99 }
100 }
101
102 if { $kfail_proc != 0 } {
103 $kfail_proc $trace_command
104 }
105 gdb_test "tstatus" \
106 ".*Trace .*Collected $num_frames .*" \
107 "check $num_frames frames were collected."
108
109 gdb_test "tstop" "" ""
110 }
111 }
112
113 # These callbacks identify known failures for certain architectures. They
114 # are called either if GDBserver crashes or has not traced the correct
115 # number of frames.
116
117 proc 18955_x86_64_failure { trace_command } {
118 if { $trace_command == "ftrace" } {
119 setup_kfail "gdb/18955" "x86_64-*-linux*"
120 }
121 }
122
123 proc 18955_i386_failure { trace_command } {
124 if { $trace_command == "ftrace" } {
125 setup_kfail "gdb/18955" "i\[34567\]86-*-*"
126 }
127 }
128
129 foreach trace_command { "trace" "ftrace" } {
130 # This condition is always true as the PC should be set to the tracepoint
131 # address when hit.
132 test_tracepoints $trace_command "\$$pcreg == *set_point" 10
133
134 # Can we read local variables?
135 test_tracepoints $trace_command "arg8 == 1 || arg8 == 2" 2 18955_x86_64_failure
136 test_tracepoints $trace_command "arg16 == 257 || arg16 == 258" 2 18955_x86_64_failure
137 test_tracepoints $trace_command "arg32 == 65537 || arg32 == 65538" 2 18955_x86_64_failure
138 test_tracepoints $trace_command "arg64 == 4294967297 || arg64 == 4294967298" 2 18955_x86_64_failure
139 # Can we read global variables?
140 test_tracepoints $trace_command "arg16 == 257 && globvar == 1" 1 18955_x86_64_failure
141
142 # Test various operations to cover as many opcodes as possible.
143 test_tracepoints $trace_command "21 == 21" 10
144 test_tracepoints $trace_command "11 == 21" 0
145
146 test_tracepoints $trace_command "21 != 42" 10
147 test_tracepoints $trace_command "42 != 42" 0
148
149 test_tracepoints $trace_command "21 + 21 == 42" 10
150 test_tracepoints $trace_command "21 + 21 == 11" 0
151
152 test_tracepoints $trace_command "42 - 21 == 21" 10
153 test_tracepoints $trace_command "42 - 21 == 11" 0
154
155 test_tracepoints $trace_command "21 * 2 == 42" 10
156 test_tracepoints $trace_command "21 * 2 == 11" 0
157
158 test_tracepoints $trace_command "21 << 1 == 42" 10
159 test_tracepoints $trace_command "21 << 1 == 11" 0
160
161 test_tracepoints $trace_command "42 >> 1 == 21" 10
162 test_tracepoints $trace_command "42 >> 1 == 11" 0
163
164 test_tracepoints $trace_command "-(21 << 1) == -42" 10
165 test_tracepoints $trace_command "-(21 << 1) == -11" 0
166
167 test_tracepoints $trace_command "-42 >> 1 == -21" 10
168 test_tracepoints $trace_command "-42 >> 1 == -11" 0
169
170 test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xabab" 10
171 test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xffff" 0
172
173 test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xababffff" 10
174 test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xeeeedddd" 0
175
176 test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xffffffff" 10
177 test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
178
179 test_tracepoints $trace_command "~0xaaaaaaaa == 0x55555555" 10
180 test_tracepoints $trace_command "~0xaaaaaaaa == 0x11111111" 0
181
182 test_tracepoints $trace_command "21 < 42" 10
183 test_tracepoints $trace_command "61 < 42" 0
184
185 test_tracepoints $trace_command "21U < 42U" 10
186 test_tracepoints $trace_command "61U < 42U" 0
187
188 test_tracepoints $trace_command "42 <= 42" 10
189 test_tracepoints $trace_command "42 <= 11" 0
190
191 test_tracepoints $trace_command "42 >= 42" 10
192 test_tracepoints $trace_command "11 >= 42" 0
193
194 test_tracepoints $trace_command "42 > 21" 10
195 test_tracepoints $trace_command "11 > 21" 0
196
197 test_tracepoints $trace_command "(21 < 42 ? 0 : 1) == 0" 10 18955_i386_failure
198 test_tracepoints $trace_command "(66 < 42 ? 0 : 1) == 0" 0 18955_i386_failure
199
200 test_tracepoints $trace_command "(42 <= 42 ? 0 : 1) == 0" 10
201 test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
202
203 test_tracepoints $trace_command "(42 >= 42 ? 0 : 1) == 0" 10
204 test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
205
206 test_tracepoints $trace_command "(42 > 21 ? 0 : 1) == 0" 10 18955_i386_failure
207 test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
208
209 test_tracepoints $trace_command "\$trace_timestamp >= 0" 10
210 }
This page took 0.042229 seconds and 4 git commands to generate.