xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/solib-symbol.exp (revision 22ebeae4b2252475e0ebe332f69734639cb946ea)
1# Copyright 2007-2023 Free Software Foundation, Inc.
2# This program is free software; you can redistribute it and/or modify
3# it under the terms of the GNU General Public License as published by
4# the Free Software Foundation; either version 3 of the License, or
5# (at your option) any later version.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program.  If not, see <http://www.gnu.org/licenses/>.
14#
15# Contributed by Markus Deuling <deuling@de.ibm.com>.
16#
17
18if {[skip_shlib_tests]} {
19    return 0
20}
21
22# Library file.
23set libname "solib-symbol-lib"
24set srcfile_lib ${srcdir}/${subdir}/${libname}.c
25set binfile_lib [standard_output_file ${libname}.so]
26set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
27# Binary file.
28set testfile "solib-symbol-main"
29set srcfile ${srcdir}/${subdir}/${testfile}.c
30set binfile [standard_output_file ${testfile}]
31set bin_flags [list debug shlib=${binfile_lib}]
32
33if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
34     || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
35  untested "failed to compile"
36  return -1
37}
38
39gdb_exit
40gdb_start
41gdb_reinitialize_dir $srcdir/$subdir
42gdb_load ${binfile}
43gdb_load_shlib $binfile_lib
44
45# Set a breakpoint in the binary.
46gdb_test "br foo2" \
47	 "Breakpoint.*file.*${testfile}\\.c.*" \
48	 "foo2 in main"
49
50delete_breakpoints
51
52if {![runto_main]} {
53  return 0
54}
55
56# Break in the library.
57gdb_test "br foo" \
58	 "Breakpoint.*file.*${libname}\\.c.*" \
59	 "foo in libmd"
60
61gdb_test "continue" \
62	 "Continuing.*"
63
64# This symbol is now looked up in the ELF library and the binary.
65gdb_test "br foo2" \
66	 "Breakpoint.*: foo2. .2 locations..*" \
67	 "foo2 in mdlib"
68
69gdb_exit
70
71return 0
72
73
74