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";
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 libipa $objdir/../gdbserver/libinproctrace.so
43 gdb_load_shlibs $libipa
45 # Can't use prepare_for_testing, because that splits compiling into
46 # building objects and then linking, and we'd fail with "linker input
47 # file unused because linking not done" when building the object.
49 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
50 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
51 untested "failed to compile ftrace tests"
54 clean_restart ${executable}
57 fail "Can't run to main for ftrace tests"
61 proc run_trace_experiment {} {
64 ".*Breakpoint \[0-9\]+, begin .*" \
65 "advance to trace begin"
67 gdb_test_no_output "tstart" "start trace experiment"
70 ".*Breakpoint \[0-9\]+, end .*" \
71 "advance through tracing"
73 gdb_test "tstatus" ".*Trace .*" "check on trace status"
75 gdb_test "tstop" "" ""
78 proc test_fast_tracepoints {} {
82 gdb_test "break begin" ".*" ""
84 gdb_test "break end" ".*" ""
86 gdb_test "print gdb_agent_gdb_trampoline_buffer_error" ".*" ""
88 if { [is_x86_like_target] } {
90 gdb_test "ftrace set_point" "Fast tracepoint .*" \
91 "fast tracepoint at a long insn"
93 gdb_trace_setactions "collect at set_point: define actions" \
95 "collect globvar, anarg" "^$"
97 # Make a test of shorter fast tracepoints, 32-bit x86 only
99 if { [istarget "i?86-*-*"] } {
101 # A Linux target needs to be able to allocate trampolines in the
102 # 16-bit range, check mmap_min_addr so we can warn testers.
103 if { [istarget "i?86-*-linux*"] } {
105 set minaddr [exec sh -c "cat /proc/sys/vm/mmap_min_addr"]
107 if { [expr $minaddr > 64512] } {
108 warning "mmap_min_addr > 64512, fast tracepoint will fail"
109 warning "do \"sudo sysctl -w vm.mmap_min_addr=32768\" to adjust"
113 gdb_test_multiple "ftrace four_byter" "set 4-byte fast tracepoint" {
114 -re "May not have a fast tracepoint at .*" {
115 pass "4-byte fast tracepoint could not be set"
117 -re "Fast tracepoint .*" {
118 pass "4-byte fast tracepoint is set"
125 gdb_trace_setactions "collect at four_byter: define actions" \
127 "collect globvar, anarg" "^$"
133 gdb_test "tfind pc *set_point" "Found trace frame .*" \
134 "tfind set_point frame, first time"
136 gdb_test "print globvar" " = 1"
138 gdb_test "tfind pc *set_point" "Found trace frame .*" \
139 "tfind set_point frame, second time"
141 gdb_test "print anarg" " = 200"
143 gdb_test "tfind start" "Found trace frame .*" \
148 gdb_test "tfind pc *four_byter" "Found trace frame .*" \
149 "tfind four_byter frame, first time"
151 gdb_test "print anarg" " = 101" \
152 "look at collected local, first time"
154 gdb_test "tfind pc *four_byter" "Found trace frame .*" \
155 "tfind four_byter frame, second time"
157 gdb_test "print anarg" " = 201" \
158 "look at collected local, second time"
164 gdb_reinitialize_dir $srcdir/$subdir
166 if { [gdb_test "info sharedlibrary" ".*libinproctrace\.so.*" "IPA loaded"] != 0 } {
167 untested "Could not find IPA lib loaded"
171 test_fast_tracepoints