]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/info-shared.exp
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / info-shared.exp
CommitLineData
61baf725 1# Copyright 2012-2017 Free Software Foundation, Inc.
afacd7f3
GB
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
16if { [skip_shlib_tests] } {
17 return 0
18}
19
20standard_testfile
21
22set lib1name $testfile-solib1
23set srcfile_lib1 $srcdir/$subdir/$lib1name.c
24set binfile_lib1 [standard_output_file $lib1name.so]
25set define1 -DSHLIB1_NAME=\"$binfile_lib1\"
26
27set lib2name $testfile-solib2
28set srcfile_lib2 $srcdir/$subdir/$lib2name.c
29set binfile_lib2 [standard_output_file $lib2name.so]
30set define2 -DSHLIB2_NAME=\"$binfile_lib2\"
31
32if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
33 [list additional_flags=-fPIC]] != "" } {
84c93cd5 34 untested "failed to compile shared library 1"
afacd7f3
GB
35 return -1
36}
37
38if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
39 [list additional_flags=-fPIC]] != "" } {
84c93cd5 40 untested "failed to compile shared library 2"
afacd7f3
GB
41 return -1
42}
43
44set cflags "$define1 $define2"
5b362f04 45if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
afacd7f3
GB
46 [list additional_flags=$cflags libs=-ldl]] } {
47 return -1
48}
49
50# Run "info sharedlibrary" and check for the presence or absence of
51# our libraries.
52proc check_info_shared { test expect1 expect2 } {
53 global lib1name
54 global lib2name
55 global gdb_prompt
56
57 set actual1 0
58 set actual2 0
59
60 gdb_test_multiple "info sharedlibrary" $test {
61 -re $lib1name {
62 set actual1 1
63 exp_continue
64 }
65 -re $lib2name {
66 set actual2 1
67 exp_continue
68 }
69 -re "\r\n$gdb_prompt $" {
70 if { $actual1 == $expect1 && $actual2 == $expect2 } {
71 pass $test
72 } else {
73 fail $test
74 }
75 }
76 }
77}
78
79# Start the inferior, and check neither of the libraries are loaded at
80# the start.
81if ![runto_main] {
82 return 0
83}
84check_info_shared "info sharedlibrary #1" 0 0
85
86# Set up breakpoints.
87gdb_breakpoint "stop"
88gdb_breakpoint "foo" allow-pending
89gdb_breakpoint "bar" allow-pending
90
91# Run to the first stop and check that only the first library is loaded.
8b924729 92gdb_continue_to_breakpoint "library load #1" "\\.?stop .*"
afacd7f3
GB
93check_info_shared "info sharedlibrary #2" 1 0
94
95# Run to the second stop and check that both libraries are loaded.
8b924729 96gdb_continue_to_breakpoint "library load #2" "\\.?stop .*"
afacd7f3
GB
97check_info_shared "info sharedlibrary #3" 1 1
98
99# Check that the next stop is in foo.
8b924729 100gdb_continue_to_breakpoint "library function #1" "\\.?foo .*"
afacd7f3
GB
101
102# Check that the next stop is in bar.
8b924729 103gdb_continue_to_breakpoint "library function #2" "\\.?bar .*"
afacd7f3
GB
104
105# Restart the inferior and make sure there are no breakpoint reset
106# errors. These can happen with the probes-based runtime linker
107# interface if the cache is not cleared correctly.
108set test "restart"
109gdb_run_cmd
110gdb_test_multiple "" $test {
111 -re {Start it from the beginning\? \(y or n\) $} {
112 send_gdb "y\n"
113 exp_continue
114 }
115 -re {Error in re-setting breakpoint} {
116 fail $test
117 }
118 -re "\r\n$gdb_prompt $" {
119 pass $test
120 }
121}
122
123# Check that neither library is loaded.
124check_info_shared "info sharedlibrary #4" 0 0
125
126# Run to the first stop and check that only the first library is loaded.
8b924729 127gdb_continue_to_breakpoint "library load #3" "\\.?stop .*"
afacd7f3
GB
128check_info_shared "info sharedlibrary #5" 1 0
129
130# Run to the second stop and check that both libraries are loaded.
8b924729 131gdb_continue_to_breakpoint "library load #4" "\\.?stop .*"
afacd7f3
GB
132check_info_shared "info sharedlibrary #6" 1 1
133
134# Check that the next stop is in foo.
8b924729 135gdb_continue_to_breakpoint "library function #3" "\\.?foo .*"
afacd7f3
GB
136
137# Check that the next stop is in bar.
8b924729 138gdb_continue_to_breakpoint "library function #4" "\\.?bar .*"
afacd7f3
GB
139
140# Run to the next stop and check that the first library has been unloaded.
8b924729 141gdb_continue_to_breakpoint "library unload #1" "\\.?stop .*"
afacd7f3
GB
142check_info_shared "info sharedlibrary #7" 0 1
143
144# Run to the last stop and check that both libraries are gone.
8b924729 145gdb_continue_to_breakpoint "library unload #2" "\\.?stop .*"
afacd7f3 146check_info_shared "info sharedlibrary #8" 0 0