]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/msym-bp-shl.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / msym-bp-shl.exp
CommitLineData
4a94e368 1# Copyright 2020-2022 Free Software Foundation, Inc.
77f2120b
PA
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# Test that when setting a breakpoint at "foo", GDB creates a location
17# for an unresolved <foo@plt> PLT in the main binary, even when a
18# static function named "foo" exists in the shared library. Tests
19# both with and without debug info.
20
21if {[skip_shlib_tests]} {
22 return 0
23}
24
25standard_testfile msym-bp-shl-main.c msym-bp-shl-main-2.c msym-bp-shl-lib.c
26set srcfile ${srcdir}/${subdir}/${srcfile}
27set srcfile2 ${srcdir}/${subdir}/${srcfile2}
28set libsrc ${srcdir}/${subdir}/${srcfile3}
29
30# Run "info breakpoints", and check that we find the two locations,
31# LOC_A and LOC_B, in either order.
32proc test_info_break_2 {loc_a loc_b} {
33 set re1 ".*\.1.*${loc_a}\r\n.*\.2.*${loc_b}"
34 set re2 ".*\.1.*${loc_b}\r\n.*\.2.*${loc_a}"
35 gdb_test "info breakpoint" "$re1|$re2"
36}
37
38proc test {debug} {
39 global testfile binfile srcfile srcfile2 libsrc
40 global decimal
41
42 if {$debug} {
43 set options "debug"
44 } else {
45 set options ""
46 }
47
48 set bin ${binfile}-$debug
49 set lib [standard_output_file msym-bp-shl-lib-$debug.sl]
50
51 set exec_opts [list $options shlib=${lib}]
52
53 if { [gdb_compile_shlib $libsrc $lib $options] != ""
54 || [gdb_compile [list $srcfile $srcfile2] $bin \
55 executable $exec_opts] != ""} {
56 untested "failed to compile"
57 return
58 }
59
60 clean_restart $bin
61 gdb_load_shlib $lib
62
63 # Should find two locations: the static foo in the
64 # msym-bp-shl-main-2 file, and <foo@plt>, both in the main binary.
65 with_test_prefix "before run" {
66 gdb_test "break foo" "\\(2 locations\\)"
67
68 if {$debug} {
69 test_info_break_2 \
70 "<foo@plt.*>" \
71 "in foo at .*msym-bp-shl-main-2.c:$decimal"
72 } else {
73 test_info_break_2 \
74 "<foo@plt.*>" \
557fc257 75 "<foo(\\+$decimal)?>"
77f2120b
PA
76 }
77 }
78
79 if ![runto_main] {
77f2120b
PA
80 return
81 }
82
83 delete_breakpoints
84
85 # Should still find two locations, but the <foo@plt> PLT location
86 # should not be present anymore. I.e., we should find the static
87 # foo in the msym-bp-shl-main-2 file, and the extern foo in the
88 # shared library.
89 with_test_prefix "at main" {
90 gdb_test "break foo" "\\(2 locations\\)"
91
92 if {$debug} {
93 test_info_break_2 \
94 "in foo at .*msym-bp-shl-main-2.c:$decimal" \
95 "in foo at .*msym-bp-shl-lib.c:$decimal"
96 } else {
97 test_info_break_2 \
557fc257
LM
98 "<foo(\\+$decimal)?>" \
99 "<foo(\\+$decimal)?>"
77f2120b
PA
100 }
101 }
102}
103
104foreach_with_prefix debug {0 1} {
105 test $debug
106}