1 # Copyright 2011-2024 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 require allow_shlib_tests
20 # Do not run if gdbsever debug is enabled - the output file is many Gb.
21 if [gdbserver_debug_enabled] {
26 set executable $testfile
28 # Check that the target supports trace.
29 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
30 untested "failed to compile"
34 clean_restart ${testfile}
40 if ![gdb_target_supports_trace] {
41 unsupported "target does not support trace"
45 # Compile the test case with the in-process agent library.
46 set ipalib [get_in_proc_agent]
48 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
49 executable [concat {debug c} shlib=$ipalib]] != "" } {
50 untested "failed to compile"
54 # Typically we need a little extra time for this test.
64 proc prepare_for_trace_test {} {
68 clean_restart $executable
69 gdb_load_shlib $ipalib
73 set testline [gdb_get_line_number "set pre-run breakpoint here"]
75 gdb_test "break $testline" ".*" \
78 set testline [gdb_get_line_number "set post-run breakpoint here"]
80 gdb_test "break $testline" ".*" \
84 proc run_trace_experiment {} {
87 ".*Breakpoint \[0-9\]+, main .*" \
88 "advance to trace begin"
90 gdb_test_no_output "tstart" "start trace experiment"
93 ".*Breakpoint \[0-9\]+, main .*" \
94 "advance through tracing"
96 gdb_test "tstatus" ".*Trace .*" "check on trace status"
98 gdb_test "tstop" "" ""
101 proc_with_prefix gdb_slow_trace_speed_test { } {
103 gdb_delete_tracepoints
105 gdb_test "print iters = init_iters" ".* = .*"
107 set testline [gdb_get_line_number "set tracepoint here"]
109 gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \
110 "Tracepoint \[0-9\]+ at .*" \
111 "set slow tracepoint"
117 proc_with_prefix gdb_fast_trace_speed_test { } {
120 gdb_delete_tracepoints
122 gdb_test "print iters = init_iters" ".* = .*"
126 set testline [gdb_get_line_number "set tracepoint here"]
128 gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \
129 "set conditional fast tracepoint" {
130 -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
131 pass "set conditional fast tracepoint, done"
134 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
135 pass "set conditional fast tracepoint, not allowed at line"
139 # If the fast tracepoint couldn't be set, don't bother with the run.
140 if {$run_ftrace == 1} {
147 proc gdb_trace_collection_test {} {
149 prepare_for_trace_test
151 gdb_slow_trace_speed_test
153 gdb_fast_trace_speed_test
156 clean_restart $executable
157 gdb_load_shlib $ipalib
161 if {![gdb_target_supports_trace]} {
162 unsupported "current target does not support trace"
166 # Body of test encased in a proc so we can return prematurely.
167 gdb_trace_collection_test