1 # Copyright
(C
) 2016-2022 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 # 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.
23 # SKIP_STEP_COUNT: the number of single steps GDB performs
24 # SKIP_DIRECTIVE_COUNT: the number of skip directives to create
28 if [skip_perf_tests] {
32 standard_testfile .cc skip-funcs.cc
33 set executable $testfile
34 set skip_func_file [standard_output_file $srcfile2]
35 set expfile $testfile.exp
37 # make check-perf RUNTESTFLAGS='skip
-command.exp SKIP_STEP_COUNT
=1000 ...
'
38 if ![info exists SKIP_STEP_COUNT] {
39 set SKIP_STEP_COUNT 1000
41 if ![info exists SKIP_DIRECTIVE_COUNT] {
42 set SKIP_DIRECTIVE_COUNT 1000
45 proc delete_all_skips { } {
46 # FIXME: skip currently doesn't ask
for confirmation
47 # FIXME
: "skip delete" with no skips ->
48 #
"No skiplist entries found with number (null)."
49 gdb_test_no_output
"set confirm off"
50 gdb_test
"skip delete" ""
51 gdb_test_no_output
"set confirm on"
54 proc install_skips
{ kind
text nr_skips
} {
56 set test
"install_skips"
59 "function" { set skip_arg "-function" }
60 "regexp" { set skip_arg "-rfunction" }
62 perror
"bad skip kind: $kind"
66 for { set i
0 } { $i
< $nr_skips
} { incr i
} {
67 gdb_test
"skip $skip_arg [format $text $i]" ""
69 # There could be
1000's of these, which can overflow the buffer.
70 # However, it's good to have this in the
log, so we go to the effort
72 gdb_test_multiple
"info skip" $test {
73 -re
"\[^\r\n\]*\r\n" { exp_continue }
74 -re
"\[\r\n\]*$gdb_prompt $" {
78 fail
"$test (timeout)"
83 proc write_skip_func_source
{ file_name func_name_prefix nr_funcs
} {
84 set f
[open $file_name
"w"]
85 puts $f
"// DO NOT EDIT, machine generated file. See skip-command.exp."
86 for { set i
0 } { $i
< $nr_funcs
} { incr i
} {
87 set func_name
[format
"${func_name_prefix}_%02d" $i]
88 puts $f
"int $func_name () { return 0; }"
93 proc run_skip_bench
{ kind
text } {
94 global SKIP_STEP_COUNT SKIP_DIRECTIVE_COUNT
100 gdb_test_no_output
"set variable flag = 1"
102 for { set i
0 } { $i
< 5 } { incr i
} {
103 with_test_prefix
"iter $i" {
104 set nr_skips
[expr $i
* $SKIP_DIRECTIVE_COUNT
]
105 install_skips $kind $
text $nr_skips
106 gdb_test_python_run \
107 "SkipCommand\(\"skip-$kind-$nr_skips\", ${SKIP_STEP_COUNT}\)"
111 gdb_test
"set variable flag = 0"
115 global srcdir subdir srcfile binfile skip_func_file
116 global SKIP_DIRECTIVE_COUNT
118 write_skip_func_source $skip_func_file
"skip_func" [expr 4 * $SKIP_DIRECTIVE_COUNT]
119 if { [gdb_compile
[list
"$srcdir/$subdir/$srcfile" $skip_func_file] ${binfile} executable {c++ debug}] != "" } {
125 clean_restart $binfile
128 global SKIP_STEP_COUNT SKIP_DIRECTIVE_COUNT
130 with_test_prefix
"time_skip_func" {
131 # N.B. The function
name must match the ones in skip
-command.cc.
132 run_skip_bench
"function" "skip_func_%02d"
135 with_test_prefix
"time_skip_constructor" {
136 run_skip_bench
"regexp" "^(skip_class_%02d)::\\1 *\\("