1 # Copyright (C) 2013-2020 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 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
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.
27 if [skip_perf_tests] {
32 set executable $testfile
33 set expfile $testfile.exp
35 # make check-perf RUNTESTFLAGS='solib.exp SOLIB_COUNT=1024'
36 if ![info exists SOLIB_COUNT] {
42 global srcdir subdir srcfile binfile
44 for {set i 0} {$i < $SOLIB_COUNT} {incr i} {
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]
51 gdb_produce_source $src "int shr$i (void) {return 0;}"
54 if { [gdb_compile_shlib $src $exe {debug}] != "" } {
58 # Delete object files to save some space.
59 file delete [standard_output_file "solib-lib$i.c.o"]
62 set compile_flags {debug shlib_load}
63 global SOLIB_DLCLOSE_REVERSED_ORDER
65 if [info exists SOLIB_DLCLOSE_REVERSED_ORDER] {
66 lappend compile_flags "additional_flags=-DSOLIB_DLCLOSE_REVERSED_ORDER"
69 if { [gdb_compile "$srcdir/$subdir/$srcfile" ${binfile} executable $compile_flags] != "" } {
77 clean_restart $binfile
80 fail "can't run to main"
87 gdb_test_no_output "python SolibLoadUnload\($SOLIB_COUNT\).run()"