61e9a95841db5e8de495ac2b754710850322a581
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.perf / solib.exp
1 # Copyright (C) 2013-2021 Free Software Foundation, Inc.
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 performance of GDB when it is handling
17 # the shared libraries of inferior are loaded and unloaded.
18 # There are two parameters in this test:
19 # - SOLIB_COUNT is the number of shared libraries program will load
20 # and unload
21 # - SOLIB_DLCLOSE_REVERSED_ORDER controls the order of dlclose shared
22 # libraries. If it is set, program dlclose shared libraries in a
23 # reversed order of loading.
24
25 load_lib perftest.exp
26
27 if [skip_perf_tests] {
28 return 0
29 }
30
31 standard_testfile .c
32 set executable $testfile
33 set expfile $testfile.exp
34
35 # make check-perf RUNTESTFLAGS='solib.exp SOLIB_COUNT=1024'
36 if ![info exists SOLIB_COUNT] {
37 set SOLIB_COUNT 128
38 }
39
40 PerfTest::assemble {
41 global SOLIB_COUNT
42 global srcdir subdir srcfile binfile
43
44 for {set i 0} {$i < $SOLIB_COUNT} {incr i} {
45
46 # Produce source files.
47 set libname "solib-lib$i"
48 set src [standard_output_file $libname.c]
49 set exe [standard_output_file $libname]
50
51 gdb_produce_source $src "int shr$i (void) {return 0;}"
52
53 # Compile.
54 if { [gdb_compile_shlib $src $exe {debug}] != "" } {
55 return -1
56 }
57
58 # Delete object files to save some space.
59 file delete [standard_output_file "solib-lib$i.c.o"]
60 }
61
62 set compile_flags {debug shlib_load}
63 global SOLIB_DLCLOSE_REVERSED_ORDER
64
65 if [info exists SOLIB_DLCLOSE_REVERSED_ORDER] {
66 lappend compile_flags "additional_flags=-DSOLIB_DLCLOSE_REVERSED_ORDER"
67 }
68
69 if { [gdb_compile "$srcdir/$subdir/$srcfile" ${binfile} executable $compile_flags] != "" } {
70 return -1
71 }
72
73 return 0
74 } {
75 global binfile
76
77 clean_restart $binfile
78
79 if ![runto_main] {
80 fail "can't run to main"
81 return -1
82 }
83 return 0
84 } {
85 global SOLIB_COUNT
86
87 gdb_test_no_output "python SolibLoadUnload\($SOLIB_COUNT\).run()"
88 return 0
89 }
This page took 0.030667 seconds and 3 git commands to generate.