1 # Copyright (C) 2013-2024 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 require allow_perf_tests 28 29 standard_testfile .c 30 set executable $testfile 31 set expfile $testfile.exp 32 33 # make check-perf RUNTESTFLAGS='solib.exp SOLIB_COUNT=1024' 34 if ![info exists SOLIB_COUNT] { 35 set SOLIB_COUNT 128 36 } 37 38 PerfTest::assemble { 39 global SOLIB_COUNT 40 global srcdir subdir srcfile binfile 41 42 for {set i 0} {$i < $SOLIB_COUNT} {incr i} { 43 44 # Produce source files. 45 set libname "solib-lib$i" 46 set src [standard_output_file $libname.c] 47 set exe [standard_output_file $libname] 48 49 gdb_produce_source $src "int shr$i (void) {return 0;}" 50 51 # Compile. 52 if { [gdb_compile_shlib $src $exe {debug}] != "" } { 53 return -1 54 } 55 56 # Delete object files to save some space. 57 file delete [standard_output_file "solib-lib$i.c.o"] 58 } 59 60 set compile_flags {debug shlib_load} 61 global SOLIB_DLCLOSE_REVERSED_ORDER 62 63 if [info exists SOLIB_DLCLOSE_REVERSED_ORDER] { 64 lappend compile_flags "additional_flags=-DSOLIB_DLCLOSE_REVERSED_ORDER" 65 } 66 67 if { [gdb_compile "$srcdir/$subdir/$srcfile" ${binfile} executable $compile_flags] != "" } { 68 return -1 69 } 70 71 return 0 72 } { 73 global binfile 74 75 clean_restart $binfile 76 77 if ![runto_main] { 78 return -1 79 } 80 return 0 81 } { 82 global SOLIB_COUNT 83 84 gdb_test_python_run "SolibLoadUnload\($SOLIB_COUNT\)" 85 return 0 86 } 87