Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.perf / solib.exp
CommitLineData
88b9d363 1# Copyright (C) 2013-2022 Free Software Foundation, Inc.
6dbb6798
YQ
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
25load_lib perftest.exp
26
27if [skip_perf_tests] {
28 return 0
29}
30
31standard_testfile .c
32set executable $testfile
33set expfile $testfile.exp
34
35# make check-perf RUNTESTFLAGS='solib.exp SOLIB_COUNT=1024'
36if ![info exists SOLIB_COUNT] {
37 set SOLIB_COUNT 128
38}
39
40PerfTest::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] {
bc6c7af4 80 fail "can't run to main"
6dbb6798
YQ
81 return -1
82 }
63738bfd 83 return 0
6dbb6798
YQ
84} {
85 global SOLIB_COUNT
86
87 gdb_test_no_output "python SolibLoadUnload\($SOLIB_COUNT\).run()"
63738bfd 88 return 0
6dbb6798 89}
This page took 1.010424 seconds and 4 git commands to generate.