Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2011-2016 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 | ||
4ec70201 | 15 | load_lib "trace-support.exp" |
405f8e94 | 16 | |
497a5eb0 | 17 | standard_testfile |
405f8e94 | 18 | set executable $testfile |
405f8e94 SS |
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 | ||
5b362f04 | 24 | if [prepare_for_testing "failed to prepare" $executable $srcfile \ |
405f8e94 | 25 | [list debug $additional_flags]] { |
405f8e94 SS |
26 | return -1 |
27 | } | |
28 | ||
29 | if ![runto_main] { | |
bc6c7af4 | 30 | fail "can't run to main to check for trace support" |
405f8e94 SS |
31 | return -1 |
32 | } | |
33 | ||
34 | if ![gdb_target_supports_trace] { | |
35 | unsupported "target does not support trace" | |
36 | return -1 | |
37 | } | |
38 | ||
c0d4d1c0 | 39 | set libipa [get_in_proc_agent] |
952ebca5 | 40 | set remote_libipa [gdb_load_shlib $libipa] |
405f8e94 SS |
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] ] != "" } { | |
84c93cd5 | 48 | untested "failed to compile" |
405f8e94 SS |
49 | return -1 |
50 | } | |
51 | clean_restart ${executable} | |
52 | ||
53 | if ![runto_main] { | |
bc6c7af4 | 54 | fail "can't run to main for ftrace tests" |
405f8e94 SS |
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 {} { | |
61638e15 | 76 | global gdb_prompt |
405f8e94 SS |
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 | ||
678b48b7 MK |
86 | gdb_test "ftrace set_point" "Fast tracepoint .*" \ |
87 | "fast tracepoint at a long insn" | |
405f8e94 | 88 | |
678b48b7 MK |
89 | gdb_trace_setactions "collect at set_point: define actions" \ |
90 | "" \ | |
91 | "collect globvar, anarg" "^$" | |
405f8e94 | 92 | |
678b48b7 | 93 | # Make a test of shorter fast tracepoints, 32-bit x86 only |
405f8e94 | 94 | |
678b48b7 | 95 | if { [istarget "i?86-*-*"] } { |
405f8e94 | 96 | |
678b48b7 MK |
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*"] } { | |
405f8e94 | 100 | |
678b48b7 | 101 | set minaddr [exec sh -c "cat /proc/sys/vm/mmap_min_addr"] |
405f8e94 | 102 | |
678b48b7 MK |
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 | } | |
405f8e94 | 108 | |
678b48b7 MK |
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 | } | |
405f8e94 | 118 | |
678b48b7 | 119 | if { $fourgood } { |
405f8e94 | 120 | |
678b48b7 MK |
121 | gdb_trace_setactions "collect at four_byter: define actions" \ |
122 | "" \ | |
123 | "collect globvar, anarg" "^$" | |
124 | } | |
125 | } | |
405f8e94 | 126 | |
678b48b7 | 127 | run_trace_experiment |
405f8e94 | 128 | |
678b48b7 MK |
129 | gdb_test "tfind pc *set_point" "Found trace frame .*" \ |
130 | "tfind set_point frame, first time" | |
405f8e94 | 131 | |
678b48b7 | 132 | gdb_test "print globvar" " = 1" |
405f8e94 | 133 | |
678b48b7 MK |
134 | gdb_test "tfind pc *set_point" "Found trace frame .*" \ |
135 | "tfind set_point frame, second time" | |
405f8e94 | 136 | |
678b48b7 MK |
137 | setup_kfail "gdb/13808" "x86_64-*-linux*" |
138 | gdb_test "print anarg" " = 200" | |
405f8e94 | 139 | |
678b48b7 MK |
140 | gdb_test "tfind start" "Found trace frame .*" \ |
141 | "reset tfinding" | |
405f8e94 | 142 | |
678b48b7 | 143 | if { $fourgood } { |
405f8e94 | 144 | |
678b48b7 MK |
145 | gdb_test "tfind pc *four_byter" "Found trace frame .*" \ |
146 | "tfind four_byter frame, first time" | |
405f8e94 | 147 | |
678b48b7 MK |
148 | gdb_test "print anarg" " = 101" \ |
149 | "look at collected local, first time" | |
405f8e94 | 150 | |
678b48b7 MK |
151 | gdb_test "tfind pc *four_byter" "Found trace frame .*" \ |
152 | "tfind four_byter frame, second time" | |
405f8e94 | 153 | |
678b48b7 MK |
154 | gdb_test "print anarg" " = 201" \ |
155 | "look at collected local, second time" | |
4082afcc | 156 | |
678b48b7 | 157 | } |
4082afcc | 158 | |
678b48b7 MK |
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 | |
405f8e94 SS |
173 | } |
174 | } | |
175 | ||
176 | gdb_reinitialize_dir $srcdir/$subdir | |
177 | ||
952ebca5 | 178 | if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } { |
bc6c7af4 | 179 | untested "could not find IPA lib loaded" |
405f8e94 SS |
180 | return 1 |
181 | } | |
182 | ||
183 | test_fast_tracepoints |