]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.perf/skip-command.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.perf / skip-command.exp
CommitLineData
1d506c26 1# Copyright (C) 2016-2024 Free Software Foundation, Inc.
cce0e923
DE
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
16# This test case is to test the speed of GDB when it is single-stepping
17# with skip directives active. There's no need to test skip directives that
18# match functions we're stepping through. That's not the interesting case.
19# The interesting case is where there are 100s or more classes or libraries,
20# each providing their own set of skip directives.
21#
22# Parameters:
23# SKIP_STEP_COUNT: the number of single steps GDB performs
24# SKIP_DIRECTIVE_COUNT: the number of skip directives to create
25
26load_lib perftest.exp
27
c241bf50 28require allow_perf_tests
cce0e923
DE
29
30standard_testfile .cc skip-funcs.cc
31set executable $testfile
32set skip_func_file [standard_output_file $srcfile2]
33set expfile $testfile.exp
34
35# make check-perf RUNTESTFLAGS='skip-command.exp SKIP_STEP_COUNT=1000 ...'
36if ![info exists SKIP_STEP_COUNT] {
37 set SKIP_STEP_COUNT 1000
38}
39if ![info exists SKIP_DIRECTIVE_COUNT] {
40 set SKIP_DIRECTIVE_COUNT 1000
41}
42
43proc delete_all_skips { } {
44 # FIXME: skip currently doesn't ask for confirmation
45 # FIXME: "skip delete" with no skips ->
46 # "No skiplist entries found with number (null)."
47 gdb_test_no_output "set confirm off"
48 gdb_test "skip delete" ""
49 gdb_test_no_output "set confirm on"
50}
51
52proc install_skips { kind text nr_skips } {
53 global gdb_prompt
54 set test "install_skips"
55 delete_all_skips
56 switch $kind {
57 "function" { set skip_arg "-function" }
58 "regexp" { set skip_arg "-rfunction" }
59 default {
60 perror "bad skip kind: $kind"
61 return
62 }
63 }
64 for { set i 0 } { $i < $nr_skips } { incr i } {
65 gdb_test "skip $skip_arg [format $text $i]" ""
66 }
67 # There could be 1000's of these, which can overflow the buffer.
68 # However, it's good to have this in the log, so we go to the effort
69 # to read it all in.
70 gdb_test_multiple "info skip" $test {
71 -re "\[^\r\n\]*\r\n" { exp_continue }
72 -re "\[\r\n\]*$gdb_prompt $" {
73 pass $test
74 }
75 timeout {
76 fail "$test (timeout)"
77 }
78 }
79}
80
81proc write_skip_func_source { file_name func_name_prefix nr_funcs } {
82 set f [open $file_name "w"]
83 puts $f "// DO NOT EDIT, machine generated file. See skip-command.exp."
84 for { set i 0 } { $i < $nr_funcs } { incr i } {
85 set func_name [format "${func_name_prefix}_%02d" $i]
86 puts $f "int $func_name () { return 0; }"
87 }
88 close $f
89}
90
91proc run_skip_bench { kind text } {
92 global SKIP_STEP_COUNT SKIP_DIRECTIVE_COUNT
93
94 if ![runto_main] {
cce0e923
DE
95 return -1
96 }
97
98 gdb_test_no_output "set variable flag = 1"
99
100 for { set i 0 } { $i < 5 } { incr i } {
d8767a72
PA
101 with_test_prefix "iter $i" {
102 set nr_skips [expr $i * $SKIP_DIRECTIVE_COUNT]
103 install_skips $kind $text $nr_skips
104 gdb_test_python_run \
105 "SkipCommand\(\"skip-$kind-$nr_skips\", ${SKIP_STEP_COUNT}\)"
106 }
cce0e923
DE
107 }
108
109 gdb_test "set variable flag = 0"
110}
111
112PerfTest::assemble {
113 global srcdir subdir srcfile binfile skip_func_file
114 global SKIP_DIRECTIVE_COUNT
115
116 write_skip_func_source $skip_func_file "skip_func" [expr 4 * $SKIP_DIRECTIVE_COUNT]
117 if { [gdb_compile [list "$srcdir/$subdir/$srcfile" $skip_func_file] ${binfile} executable {c++ debug}] != "" } {
118 return -1
119 }
120 return 0
121} {
122 global binfile
123 clean_restart $binfile
124 return 0
125} {
126 global SKIP_STEP_COUNT SKIP_DIRECTIVE_COUNT
127
128 with_test_prefix "time_skip_func" {
129 # N.B. The function name must match the ones in skip-command.cc.
130 run_skip_bench "function" "skip_func_%02d"
131 }
132
133 with_test_prefix "time_skip_constructor" {
134 run_skip_bench "regexp" "^(skip_class_%02d)::\\1 *\\("
135 }
136
137 return 0
138}