]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/tspeed.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tspeed.exp
CommitLineData
1d506c26 1# Copyright 2011-2024 Free Software Foundation, Inc.
3c9057f3
SS
2
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.
7#
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.
12#
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/>.
15
16load_lib "trace-support.exp"
17
d6195dc9 18require allow_shlib_tests
8bca2978 19
dd06d4d6
AH
20# Do not run if gdbsever debug is enabled - the output file is many Gb.
21if [gdbserver_debug_enabled] {
22 return 0
23}
24
497a5eb0 25standard_testfile
3c9057f3 26set executable $testfile
3c9057f3 27
8bca2978
SL
28# Check that the target supports trace.
29if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
30 untested "failed to compile"
31 return -1
32}
33
34clean_restart ${testfile}
35
36if ![runto_main] {
8bca2978
SL
37 return -1
38}
39
40if ![gdb_target_supports_trace] {
41 unsupported "target does not support trace"
42 return -1
43}
44
45# Compile the test case with the in-process agent library.
c0d4d1c0 46set ipalib [get_in_proc_agent]
3c9057f3
SS
47
48if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
f9c49bff 49 executable [concat {debug c} shlib=$ipalib]] != "" } {
84c93cd5 50 untested "failed to compile"
3c9057f3
SS
51 return -1
52}
53
54# Typically we need a little extra time for this test.
55set timeout 180
56
57set ws "\[\r\n\t \]+"
58set cr "\[\r\n\]+"
59
60#
61# Utility procs
62#
63
64proc prepare_for_trace_test {} {
65 global executable
f9c49bff 66 global ipalib
3c9057f3
SS
67
68 clean_restart $executable
c708f4d2 69 gdb_load_shlib $ipalib
3c9057f3
SS
70
71 runto_main
72
73 set testline [gdb_get_line_number "set pre-run breakpoint here"]
74
cce0ae56
PA
75 gdb_test "break $testline" ".*" \
76 "break at pre-run"
3c9057f3
SS
77
78 set testline [gdb_get_line_number "set post-run breakpoint here"]
79
cce0ae56
PA
80 gdb_test "break $testline" ".*" \
81 "break at post-run"
3c9057f3
SS
82}
83
84proc run_trace_experiment {} {
85
86 gdb_test "continue" \
87 ".*Breakpoint \[0-9\]+, main .*" \
88 "advance to trace begin"
89
90 gdb_test_no_output "tstart" "start trace experiment"
91
92 gdb_test "continue" \
93 ".*Breakpoint \[0-9\]+, main .*" \
94 "advance through tracing"
95
96 gdb_test "tstatus" ".*Trace .*" "check on trace status"
97
98 gdb_test "tstop" "" ""
99}
100
cce0ae56 101proc_with_prefix gdb_slow_trace_speed_test { } {
3c9057f3
SS
102
103 gdb_delete_tracepoints
104
4ec70201 105 gdb_test "print iters = init_iters" ".* = .*"
3c9057f3
SS
106
107 set testline [gdb_get_line_number "set tracepoint here"]
108
109 gdb_test "trace $testline if (globfoo != 12 && globfoo2 == 45)" \
110 "Tracepoint \[0-9\]+ at .*" \
111 "set slow tracepoint"
112
113 # Begin the test.
114 run_trace_experiment
115}
116
cce0ae56 117proc_with_prefix gdb_fast_trace_speed_test { } {
968643aa 118 global gdb_prompt
3c9057f3
SS
119
120 gdb_delete_tracepoints
121
4ec70201 122 gdb_test "print iters = init_iters" ".* = .*"
3c9057f3
SS
123
124 set run_ftrace 0
125
126 set testline [gdb_get_line_number "set tracepoint here"]
127
128 gdb_test_multiple "ftrace $testline if (globfoo != 12 && globfoo2 == 45)" \
129 "set conditional fast tracepoint" {
968643aa 130 -re "Fast tracepoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
3c9057f3
SS
131 pass "set conditional fast tracepoint, done"
132 set run_ftrace 1
133 }
968643aa 134 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
3c9057f3
SS
135 pass "set conditional fast tracepoint, not allowed at line"
136 }
137 }
138
139 # If the fast tracepoint couldn't be set, don't bother with the run.
89c6d320 140 if {$run_ftrace == 1} {
3c9057f3
SS
141
142 # Begin the test.
143 run_trace_experiment
144 }
145}
146
147proc gdb_trace_collection_test {} {
148
149 prepare_for_trace_test
150
151 gdb_slow_trace_speed_test
152
153 gdb_fast_trace_speed_test
154}
155
156clean_restart $executable
c708f4d2
AB
157gdb_load_shlib $ipalib
158
3c9057f3
SS
159runto_main
160
89c6d320 161if {![gdb_target_supports_trace]} {
bc6c7af4 162 unsupported "current target does not support trace"
ae59b1da 163 return 1
3c9057f3
SS
164}
165
166# Body of test encased in a proc so we can return prematurely.
167gdb_trace_collection_test