]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/ftrace.exp
634d77b21c59177525f4e883a39560db5033cfb7
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / ftrace.exp
1 # Copyright 2011-2012 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 set testfile "ftrace"
18 set executable $testfile
19 set srcfile $testfile.c
20 set binfile $objdir/$subdir/$testfile
21 set expfile $testfile.exp
22
23 # Some targets have leading underscores on assembly symbols.
24 set additional_flags [gdb_target_symbol_prefix_flags]
25
26 if [prepare_for_testing $expfile $executable $srcfile \
27 [list debug $additional_flags]] {
28 untested "failed to prepare for trace tests"
29 return -1
30 }
31
32 if ![runto_main] {
33 fail "Can't run to main to check for trace support"
34 return -1
35 }
36
37 if ![gdb_target_supports_trace] {
38 unsupported "target does not support trace"
39 return -1
40 }
41
42 set libipa [get_in_proc_agent]
43 gdb_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
49 if { [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 }
54 clean_restart ${executable}
55
56 if ![runto_main] {
57 fail "Can't run to main for ftrace tests"
58 return 0
59 }
60
61 proc 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
78 proc test_fast_tracepoints {} {
79 global gdb_prompt
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
89 if { [istarget "x86_64-*-*"] || [istarget "i\[34567\]86-*-*"] } {
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" {
115 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
116 pass "4-byte fast tracepoint could not be set"
117 }
118 -re "Fast tracepoint .*\r\n$gdb_prompt $" {
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
137 setup_kfail_for_target "gdb/13808" "x86_64-*-linux*"
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
143 setup_kfail_for_target "gdb/13808" "x86_64-*-linux*"
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
167 gdb_reinitialize_dir $srcdir/$subdir
168
169 if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] != 0 } {
170 untested "Could not find IPA lib loaded"
171 return 1
172 }
173
174 test_fast_tracepoints