[gdb/testsuite] Fix gdb_unbuffer_output return-type
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / shlib-call.exp
CommitLineData
b811d2c2 1# Copyright 1997-2020 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# file to test calls into shared libraries
17# the source files for this test are:
18#
19# shmain.c
20# shr1.c (shared lib)
21# shr2.c (shared lib)
22# ss.h (header for shr2.c)
23#
24# file written by Elena Zannoni: elz@ch.apollo.com
25#
26
27#debug shmain
28#prop lib shr1.sl
29#prop lib shr2.sl
30
c906108c 31
93f02886 32if {[skip_shlib_tests]} {
c906108c
SS
33 return 0
34}
35
0ab77f5f
TT
36standard_testfile shmain.c shr1.c shr2.c
37set srcfile ${srcdir}/${subdir}/${srcfile}
38set lib1src ${srcdir}/${subdir}/${srcfile2}
39set lib2src ${srcdir}/${subdir}/${srcfile3}
40set lib1 [standard_output_file shr1.sl]
41set lib2 [standard_output_file shr2.sl]
f07e55f0
PG
42
43set lib_opts "debug"
44set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
c906108c 45
4c93b1db 46if [get_compiler_info] {
c906108c
SS
47 return -1
48}
49
f07e55f0
PG
50if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != ""
51 || [gdb_compile_shlib ${lib2src} ${lib2} $lib_opts] != ""
52 || [gdb_compile ${srcfile} ${binfile} executable $exec_opts] != ""} {
84c93cd5 53 untested "failed to compile"
f07e55f0 54 return -1
c906108c
SS
55}
56
c906108c
SS
57# Start with a fresh gdb.
58
0ab77f5f 59clean_restart ${binfile}
d9019901
SM
60gdb_load_shlib $lib1
61gdb_load_shlib $lib2
93f02886 62
02746bbc
MS
63gdb_test_no_output "set print sevenbit-strings"
64gdb_test_no_output "set print address off"
65gdb_test_no_output "set width 0"
c906108c
SS
66
67
68if ![runto_main] then {
69 perror "C function calling tests suppressed"
70}
71
72
73#step -over
74
dedad4e3 75gdb_test "next 2" "g = shr1\\(g\\);" "next to shr1"
c906108c
SS
76
77#print g
78
11af934b 79gdb_test "print g" "\[0-9\]* = 1"
c906108c
SS
80
81#step -over
02746bbc 82if ![gdb_skip_stdio_test "next over shr1"] {
39413b29
PA
83 gdb_test_stdio "next" \
84 "address of sgs is $hex" \
85 "g = shr2\\(g\\);" \
02746bbc
MS
86 "next over shr1"
87} else {
de7ff789 88 gdb_test "next" ".*" ""
02746bbc 89}
13a5e3b8 90
c906108c
SS
91
92#print g
11af934b 93gdb_test "print g" "\[0-9\]* = 2"
c906108c
SS
94
95#print shr1(1)
02746bbc 96if ![gdb_skip_stdio_test "print shr1(1)"] {
39413b29
PA
97 gdb_test_stdio "print shr1(1)" \
98 "address of sgs is $hex" \
99 "\[0-9\]* = 2" \
02746bbc
MS
100 "print shr1(1)"
101}
c906108c
SS
102
103#print shr1(g)
02746bbc 104if ![gdb_skip_stdio_test "print shr1(g)"] {
39413b29
PA
105 gdb_test_stdio "print shr1(g)" \
106 "address of sgs is $hex" \
107 "\[0-9\]* = 4" \
02746bbc
MS
108 "print shr1(g)"
109}
c906108c
SS
110
111#break shr2
112#go
113gdb_test "break shr2" \
114 "Breakpoint.*file.*shr2.c, line.*" \
115 "breakpoint function shr2"
116
13a5e3b8 117gdb_test "continue" \
b0e59b8f 118 "Continuing\\..*Breakpoint ${decimal}, shr2 \\(.*\\) at.*shr2\\.c:${decimal}.*shr2-return \\*\\/" \
13a5e3b8 119 "run until breakpoint set at a function"
c906108c
SS
120
121
122#print shr1(1)
13a5e3b8 123if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] {
39413b29
PA
124 gdb_test_stdio "print shr1(1)" \
125 "address of sgs is $hex" \
126 "\[0-9\]* = 2" \
02746bbc 127 "print shr1(1) 2nd time"
13a5e3b8 128}
c906108c
SS
129
130#print mainshr1(1)
02746bbc
MS
131gdb_test "print mainshr1(1)" "\[0-9\]* = 2" \
132 "print mainshr1(1) from shlib func"
c906108c
SS
133
134#step -return
02746bbc
MS
135# A step at this point will either take us entirely out of
136# the function or into the function's epilogue. The exact
137# behavior will differ depending upon upon whether or not
138# the compiler emits line number information for the epilogue.
139gdb_test_multiple "step" "step out of shr2 to main" {
140 -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" {
141 pass "step out of shr2 to main"
142 }
143 -re ".*\\\}.*$gdb_prompt $" {
144 pass "step out of shr2 to main (stopped in shr2 epilogue)"
145 gdb_test "step" \
146 "main \\(\\) at.*g = mainshr1\\(g\\);" \
147 "step out of shr2 epilogue to main"
c906108c 148 }
02746bbc 149}
6fde09ad 150
c906108c 151#print mainshr1(1)
11af934b 152gdb_test "print mainshr1(1)" "\[0-9\]* = 2"
c906108c
SS
153
154#step
02746bbc
MS
155gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \
156 "step into mainshr1"
c906108c
SS
157
158# Start with a fresh gdb.
159
160gdb_exit
161gdb_start
162gdb_reinitialize_dir $srcdir/$subdir
163gdb_load ${binfile}
02746bbc
MS
164gdb_test_no_output "set print sevenbit-strings"
165gdb_test_no_output "set print address off"
166gdb_test_no_output "set width 0"
167
c906108c
SS
168
169# PR's 16495, 18213
170# test that we can re-set breakpoints in shared libraries
55264cb4 171gdb_breakpoint "shr1" "allow-pending"
13a5e3b8 172
5e830d98
PA
173set test "run to bp in shared library"
174gdb_run_cmd
175gdb_test_multiple "" $test {
176 -re "Breakpoint .,.*${gdb_prompt} " {
177 pass $test
178 }
179}
13a5e3b8 180
5e830d98 181gdb_continue_to_end "" continue 1
13a5e3b8 182
5e830d98
PA
183set test "re-run to bp in shared library (PR's 16495, 18213)"
184gdb_run_cmd
185gdb_test_multiple "" $test {
186 -re "Breakpoint .,.*${gdb_prompt} " {
187 pass $test
188 }
676a0442 189}
c906108c 190
5e830d98 191gdb_continue_to_end "" continue 1
This page took 2.230984 seconds and 4 git commands to generate.