]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/ftrace.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / ftrace.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 "failed to prepare" $executable $srcfile \
25 [list debug $additional_flags]] {
26 return -1
27 }
28
29 if ![runto_main] {
30 fail "can't run to main to check for trace support"
31 return -1
32 }
33
34 if ![gdb_target_supports_trace] {
35 unsupported "target does not support trace"
36 return -1
37 }
38
39 set libipa [get_in_proc_agent]
40 set remote_libipa [gdb_load_shlib $libipa]
41
42 # Can't use prepare_for_testing, because that splits compiling into
43 # building objects and then linking, and we'd fail with "linker input
44 # file unused because linking not done" when building the object.
45
46 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
47 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
48 untested "failed to compile"
49 return -1
50 }
51 clean_restart ${executable}
52
53 if ![runto_main] {
54 fail "can't run to main for ftrace tests"
55 return 0
56 }
57
58 proc run_trace_experiment {} {
59
60 gdb_test "continue" \
61 ".*Breakpoint \[0-9\]+, begin .*" \
62 "advance to trace begin"
63
64 gdb_test_no_output "tstart" "start trace experiment"
65
66 gdb_test "continue" \
67 ".*Breakpoint \[0-9\]+, end .*" \
68 "advance through tracing"
69
70 gdb_test "tstatus" ".*Trace .*" "check on trace status"
71
72 gdb_test "tstop" "" ""
73 }
74
75 proc test_fast_tracepoints {} {
76 global gdb_prompt
77
78 set fourgood 0
79
80 gdb_test "break begin" ".*" ""
81
82 gdb_test "break end" ".*" ""
83
84 gdb_test "print gdb_agent_gdb_trampoline_buffer_error" ".*" ""
85
86 gdb_test "ftrace set_point" "Fast tracepoint .*" \
87 "fast tracepoint at a long insn"
88
89 gdb_trace_setactions "collect at set_point: define actions" \
90 "" \
91 "collect globvar, anarg" "^$"
92
93 # Make a test of shorter fast tracepoints, 32-bit x86 only
94
95 if { [istarget "i?86-*-*"] } {
96
97 # A Linux target needs to be able to allocate trampolines in the
98 # 16-bit range, check mmap_min_addr so we can warn testers.
99 if { [istarget "i?86-*-linux*"] } {
100
101 set minaddr [exec sh -c "cat /proc/sys/vm/mmap_min_addr"]
102
103 if { [expr $minaddr > 64512] } {
104 warning "mmap_min_addr > 64512, fast tracepoint will fail"
105 warning "do \"sudo sysctl -w vm.mmap_min_addr=32768\" to adjust"
106 }
107 }
108
109 gdb_test_multiple "ftrace four_byter" "set 4-byte fast tracepoint" {
110 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
111 pass "4-byte fast tracepoint could not be set"
112 }
113 -re "Fast tracepoint .*\r\n$gdb_prompt $" {
114 pass "4-byte fast tracepoint is set"
115 set fourgood 1
116 }
117 }
118
119 if { $fourgood } {
120
121 gdb_trace_setactions "collect at four_byter: define actions" \
122 "" \
123 "collect globvar, anarg" "^$"
124 }
125 }
126
127 run_trace_experiment
128
129 gdb_test "tfind pc *set_point" "Found trace frame .*" \
130 "tfind set_point frame, first time"
131
132 gdb_test "print globvar" " = 1"
133
134 gdb_test "tfind pc *set_point" "Found trace frame .*" \
135 "tfind set_point frame, second time"
136
137 setup_kfail "gdb/13808" "x86_64-*-linux*"
138 gdb_test "print anarg" " = 200"
139
140 gdb_test "tfind start" "Found trace frame .*" \
141 "reset tfinding"
142
143 if { $fourgood } {
144
145 gdb_test "tfind pc *four_byter" "Found trace frame .*" \
146 "tfind four_byter frame, first time"
147
148 gdb_test "print anarg" " = 101" \
149 "look at collected local, first time"
150
151 gdb_test "tfind pc *four_byter" "Found trace frame .*" \
152 "tfind four_byter frame, second time"
153
154 gdb_test "print anarg" " = 201" \
155 "look at collected local, second time"
156
157 }
158
159 # If debugging with the remote target, try force disabling the
160 # fast tracepoints RSP feature, and confirm fast tracepoints
161 # can no longer be downloaded.
162 set test "fast tracepoint could not be downloaded with the feature disabled"
163 if [gdb_is_target_remote] {
164 gdb_test "set remote fast-tracepoints-packet off"
165
166 gdb_test_multiple "tstart" $test {
167 -re "warning: Target does not support fast tracepoints, downloading .* as regular tracepoint.*\r\n$gdb_prompt $" {
168 pass $test
169 }
170 }
171 } else {
172 unsupported $test
173 }
174 }
175
176 gdb_reinitialize_dir $srcdir/$subdir
177
178 if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
179 untested "could not find IPA lib loaded"
180 return 1
181 }
182
183 test_fast_tracepoints