Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.trace / tspeed.exp
blobc74680b98186e403f01c1005c00e36140772323b
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] {
22     return 0
25 standard_testfile
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"
31     return -1
34 clean_restart ${testfile}
36 if ![runto_main] {
37     return -1
40 if ![gdb_target_supports_trace] {
41     unsupported "target does not support trace"
42     return -1
45 # Compile the test case with the in-process agent library.
46 require allow_in_proc_agent
47 set ipalib [get_in_proc_agent]
49 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
50           executable [concat {debug c} shlib=$ipalib]] != "" } {
51     untested "failed to compile"
52     return -1
55 # Typically we need a little extra time for this test.
56 set timeout 180
58 set ws "\[\r\n\t \]+"
59 set cr "\[\r\n\]+"
62 # Utility procs
65 proc prepare_for_trace_test {} {
66     global executable
67     global ipalib
69     clean_restart $executable
70     gdb_load_shlib $ipalib
72     runto_main
74     set testline [gdb_get_line_number "set pre-run breakpoint here"]
76     gdb_test "break $testline" ".*" \
77         "break at pre-run"
79     set testline [gdb_get_line_number "set post-run breakpoint here"]
81     gdb_test "break $testline" ".*" \
82         "break at post-run"
85 proc run_trace_experiment {} {
87     gdb_test "continue" \
88         ".*Breakpoint \[0-9\]+, main .*" \
89         "advance to trace begin"
91     gdb_test_no_output "tstart" "start trace experiment"
93     gdb_test "continue" \
94         ".*Breakpoint \[0-9\]+, main .*" \
95         "advance through tracing"
97     gdb_test "tstatus" ".*Trace .*" "check on trace status"
99     gdb_test "tstop" "" ""
102 proc_with_prefix gdb_slow_trace_speed_test { } {
104     gdb_delete_tracepoints
106     gdb_test "print iters = init_iters" ".* = .*"
108     set testline [gdb_get_line_number "set tracepoint here"]
110     gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \
111         "Tracepoint \[0-9\]+ at .*" \
112         "set slow tracepoint"
114     # Begin the test.
115     run_trace_experiment
118 proc_with_prefix gdb_fast_trace_speed_test { } {
119     global gdb_prompt
121     gdb_delete_tracepoints
123     gdb_test "print iters = init_iters" ".* = .*"
125     set run_ftrace 0
127     set testline [gdb_get_line_number "set tracepoint here"]
129     gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \
130         "set conditional fast tracepoint" {
131             -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
132                 pass "set conditional fast tracepoint, done"
133                 set run_ftrace 1
134             }
135             -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
136                 pass "set conditional fast tracepoint, not allowed at line"
137             }
138         }
140     # If the fast tracepoint couldn't be set, don't bother with the run.
141     if {$run_ftrace == 1} {
143         # Begin the test.
144         run_trace_experiment
145     }
148 proc gdb_trace_collection_test {} {
150     prepare_for_trace_test
152     gdb_slow_trace_speed_test
154     gdb_fast_trace_speed_test
157 clean_restart $executable
158 gdb_load_shlib $ipalib
160 runto_main
162 if {![gdb_target_supports_trace]} {
163     unsupported "current target does not support trace"
164     return 1
167 # Body of test encased in a proc so we can return prematurely.
168 gdb_trace_collection_test