gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / ftrace.exp
CommitLineData
c5a57081 1# Copyright 2011-2012 Free Software Foundation, Inc.
405f8e94
SS
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
15load_lib "trace-support.exp";
16
17set testfile "ftrace"
18set executable $testfile
19set srcfile $testfile.c
20set binfile $objdir/$subdir/$testfile
21set expfile $testfile.exp
22
23# Some targets have leading underscores on assembly symbols.
24set additional_flags [gdb_target_symbol_prefix_flags]
25
26if [prepare_for_testing $expfile $executable $srcfile \
27 [list debug $additional_flags]] {
28 untested "failed to prepare for trace tests"
29 return -1
30}
31
32if ![runto_main] {
33 fail "Can't run to main to check for trace support"
34 return -1
35}
36
37if ![gdb_target_supports_trace] {
38 unsupported "target does not support trace"
39 return -1
40}
41
42set libipa $objdir/../gdbserver/libinproctrace.so
43gdb_load_shlibs $libipa
44
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.
48
49if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
50 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
51 untested "failed to compile ftrace tests"
52 return -1
53}
54clean_restart ${executable}
55
56if ![runto_main] {
57 fail "Can't run to main for ftrace tests"
58 return 0
59}
60
61proc run_trace_experiment {} {
62
63 gdb_test "continue" \
64 ".*Breakpoint \[0-9\]+, begin .*" \
65 "advance to trace begin"
66
67 gdb_test_no_output "tstart" "start trace experiment"
68
69 gdb_test "continue" \
70 ".*Breakpoint \[0-9\]+, end .*" \
71 "advance through tracing"
72
73 gdb_test "tstatus" ".*Trace .*" "check on trace status"
74
75 gdb_test "tstop" "" ""
76}
77
78proc test_fast_tracepoints {} {
61638e15 79 global gdb_prompt
405f8e94
SS
80
81 set fourgood 0
82
83 gdb_test "break begin" ".*" ""
84
85 gdb_test "break end" ".*" ""
86
87 gdb_test "print gdb_agent_gdb_trampoline_buffer_error" ".*" ""
88
abe49676 89 if { [istarget "x86_64-*-*"] || [istarget "i\[34567\]86-*-*"] } {
405f8e94
SS
90
91 gdb_test "ftrace set_point" "Fast tracepoint .*" \
92 "fast tracepoint at a long insn"
93
94 gdb_trace_setactions "collect at set_point: define actions" \
95 "" \
96 "collect globvar, anarg" "^$"
97
98 # Make a test of shorter fast tracepoints, 32-bit x86 only
99
100 if { [istarget "i?86-*-*"] } {
101
102 # A Linux target needs to be able to allocate trampolines in the
103 # 16-bit range, check mmap_min_addr so we can warn testers.
104 if { [istarget "i?86-*-linux*"] } {
105
106 set minaddr [exec sh -c "cat /proc/sys/vm/mmap_min_addr"]
107
108 if { [expr $minaddr > 64512] } {
109 warning "mmap_min_addr > 64512, fast tracepoint will fail"
110 warning "do \"sudo sysctl -w vm.mmap_min_addr=32768\" to adjust"
111 }
112 }
113
114 gdb_test_multiple "ftrace four_byter" "set 4-byte fast tracepoint" {
61638e15 115 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
405f8e94
SS
116 pass "4-byte fast tracepoint could not be set"
117 }
61638e15 118 -re "Fast tracepoint .*\r\n$gdb_prompt $" {
405f8e94
SS
119 pass "4-byte fast tracepoint is set"
120 set fourgood 1
121 }
122 }
123
124 if { $fourgood } {
125
126 gdb_trace_setactions "collect at four_byter: define actions" \
127 "" \
128 "collect globvar, anarg" "^$"
129 }
130 }
131
132 run_trace_experiment
133
134 gdb_test "tfind pc *set_point" "Found trace frame .*" \
135 "tfind set_point frame, first time"
136
abe49676 137 setup_kfail_for_target "gdb/13808" "x86_64-*-linux*"
405f8e94
SS
138 gdb_test "print globvar" " = 1"
139
140 gdb_test "tfind pc *set_point" "Found trace frame .*" \
141 "tfind set_point frame, second time"
142
abe49676 143 setup_kfail_for_target "gdb/13808" "x86_64-*-linux*"
405f8e94
SS
144 gdb_test "print anarg" " = 200"
145
146 gdb_test "tfind start" "Found trace frame .*" \
147 "reset tfinding"
148
149 if { $fourgood } {
150
151 gdb_test "tfind pc *four_byter" "Found trace frame .*" \
152 "tfind four_byter frame, first time"
153
154 gdb_test "print anarg" " = 101" \
155 "look at collected local, first time"
156
157 gdb_test "tfind pc *four_byter" "Found trace frame .*" \
158 "tfind four_byter frame, second time"
159
160 gdb_test "print anarg" " = 201" \
161 "look at collected local, second time"
162
163 }
164 }
165}
166
167gdb_reinitialize_dir $srcdir/$subdir
168
169if { [gdb_test "info sharedlibrary" ".*libinproctrace\.so.*" "IPA loaded"] != 0 } {
170 untested "Could not find IPA lib loaded"
171 return 1
172}
173
174test_fast_tracepoints
This page took 0.071704 seconds and 4 git commands to generate.