1 # Copyright 2011-2019 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 load_lib "trace-support.exp"
18 if {[skip_shlib_tests]} {
23 set executable $testfile
25 # Check that the target supports trace.
26 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
27 untested "failed to compile"
31 clean_restart ${testfile}
34 fail "can't run to main to check for trace support"
38 if ![gdb_target_supports_trace] {
39 unsupported "target does not support trace"
43 # Compile the test case with the in-process agent library.
44 set ipalib [get_in_proc_agent]
46 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
47 executable [concat {debug c} shlib=$ipalib]] != "" } {
48 untested "failed to compile"
52 # Typically we need a little extra time for this test.
62 proc prepare_for_trace_test {} {
66 clean_restart $executable
67 gdb_load_shlib $ipalib
71 set testline [gdb_get_line_number "set pre-run breakpoint here"]
73 gdb_test "break $testline" ".*" ""
75 set testline [gdb_get_line_number "set post-run breakpoint here"]
77 gdb_test "break $testline" ".*" ""
80 proc run_trace_experiment {} {
83 ".*Breakpoint \[0-9\]+, main .*" \
84 "advance to trace begin"
86 gdb_test_no_output "tstart" "start trace experiment"
89 ".*Breakpoint \[0-9\]+, main .*" \
90 "advance through tracing"
92 gdb_test "tstatus" ".*Trace .*" "check on trace status"
94 gdb_test "tstop" "" ""
97 proc gdb_slow_trace_speed_test { } {
99 gdb_delete_tracepoints
101 gdb_test "print iters = init_iters" ".* = .*"
103 set testline [gdb_get_line_number "set tracepoint here"]
105 gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \
106 "Tracepoint \[0-9\]+ at .*" \
107 "set slow tracepoint"
113 proc gdb_fast_trace_speed_test { } {
116 gdb_delete_tracepoints
118 gdb_test "print iters = init_iters" ".* = .*"
122 set testline [gdb_get_line_number "set tracepoint here"]
124 gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \
125 "set conditional fast tracepoint" {
126 -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
127 pass "set conditional fast tracepoint, done"
130 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
131 pass "set conditional fast tracepoint, not allowed at line"
135 # If the fast tracepoint couldn't be set, don't bother with the run.
136 if { $run_ftrace == 1 } then {
143 proc gdb_trace_collection_test {} {
145 prepare_for_trace_test
147 gdb_slow_trace_speed_test
149 gdb_fast_trace_speed_test
152 clean_restart $executable
153 gdb_load_shlib $ipalib
157 if { ![gdb_target_supports_trace] } then {
158 unsupported "current target does not support trace"
162 # Body of test encased in a proc so we can return prematurely.
163 gdb_trace_collection_test