1# Copyright 2014-2020 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
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]
25
26set lib2name $testfile-solib2
27set srcfile_lib2 $srcdir/$subdir/$lib2name.c
28set binfile_lib2 [standard_output_file $lib2name.so]
29
30if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
31	[list debug additional_flags=-fPIC]] != "" } {
32  untested "failed to compile shared library 1"
33  return -1
34}
35
36if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
37	[list debug additional_flags=-fPIC]] != "" } {
38  untested "failed to compile shared library 2"
39  return -1
40}
41
42if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \
43	[list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != "" } {
44  return -1
45}
46
47clean_restart $binfile
48gdb_load_shlib $binfile_lib1
49gdb_load_shlib $binfile_lib2
50
51if { ![runto_main] } {
52  return -1
53}
54
55gdb_test "next" "$decimal.*b_main \\(\\);"
56gdb_test "next" "$decimal.*return 0;"
57gdb_test "print test" " = 42"
58