]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/shlib-call.exp
Make gdb.base/shlib-call.exp use gdb_test_stdio
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / shlib-call.exp
CommitLineData
32d0add0 1# Copyright 1997-2015 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] != ""} {
53 untested "Could not compile $lib1, $lib2, or $srcfile."
54 return -1
c906108c
SS
55}
56
c906108c
SS
57# Start with a fresh gdb.
58
0ab77f5f 59clean_restart ${binfile}
93f02886
DJ
60gdb_load_shlibs $lib1 $lib2
61
02746bbc
MS
62gdb_test_no_output "set print sevenbit-strings"
63gdb_test_no_output "set print address off"
64gdb_test_no_output "set width 0"
c906108c
SS
65
66
67if ![runto_main] then {
68 perror "C function calling tests suppressed"
69}
70
71
72#step -over
73
02746bbc 74gdb_test "next" "g = shr1\\(g\\);" "next to shr1"
c906108c
SS
75
76#print g
77
02746bbc 78gdb_test "print g" "\[0-9\]* = 1" "print g"
c906108c
SS
79
80#step -over
02746bbc 81if ![gdb_skip_stdio_test "next over shr1"] {
39413b29
PA
82 gdb_test_stdio "next" \
83 "address of sgs is $hex" \
84 "g = shr2\\(g\\);" \
02746bbc
MS
85 "next over shr1"
86} else {
de7ff789 87 gdb_test "next" ".*" ""
02746bbc 88}
13a5e3b8 89
c906108c
SS
90
91#print g
02746bbc 92gdb_test "print g" "\[0-9\]* = 2" "print g"
c906108c
SS
93
94#print shr1(1)
02746bbc 95if ![gdb_skip_stdio_test "print shr1(1)"] {
39413b29
PA
96 gdb_test_stdio "print shr1(1)" \
97 "address of sgs is $hex" \
98 "\[0-9\]* = 2" \
02746bbc
MS
99 "print shr1(1)"
100}
c906108c
SS
101
102#print shr1(g)
02746bbc 103if ![gdb_skip_stdio_test "print shr1(g)"] {
39413b29
PA
104 gdb_test_stdio "print shr1(g)" \
105 "address of sgs is $hex" \
106 "\[0-9\]* = 4" \
02746bbc
MS
107 "print shr1(g)"
108}
c906108c
SS
109
110#break shr2
111#go
112gdb_test "break shr2" \
113 "Breakpoint.*file.*shr2.c, line.*" \
114 "breakpoint function shr2"
115
13a5e3b8 116gdb_test "continue" \
b0e59b8f 117 "Continuing\\..*Breakpoint ${decimal}, shr2 \\(.*\\) at.*shr2\\.c:${decimal}.*shr2-return \\*\\/" \
13a5e3b8 118 "run until breakpoint set at a function"
c906108c
SS
119
120
121#print shr1(1)
13a5e3b8 122if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] {
39413b29
PA
123 gdb_test_stdio "print shr1(1)" \
124 "address of sgs is $hex" \
125 "\[0-9\]* = 2" \
02746bbc 126 "print shr1(1) 2nd time"
13a5e3b8 127}
c906108c
SS
128
129#print mainshr1(1)
02746bbc
MS
130gdb_test "print mainshr1(1)" "\[0-9\]* = 2" \
131 "print mainshr1(1) from shlib func"
c906108c
SS
132
133#step -return
02746bbc
MS
134# A step at this point will either take us entirely out of
135# the function or into the function's epilogue. The exact
136# behavior will differ depending upon upon whether or not
137# the compiler emits line number information for the epilogue.
138gdb_test_multiple "step" "step out of shr2 to main" {
139 -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" {
140 pass "step out of shr2 to main"
141 }
142 -re ".*\\\}.*$gdb_prompt $" {
143 pass "step out of shr2 to main (stopped in shr2 epilogue)"
144 gdb_test "step" \
145 "main \\(\\) at.*g = mainshr1\\(g\\);" \
146 "step out of shr2 epilogue to main"
c906108c 147 }
02746bbc 148}
6fde09ad 149
c906108c 150#print mainshr1(1)
02746bbc 151gdb_test "print mainshr1(1)" "\[0-9\]* = 2" "print mainshr1(1)"
c906108c
SS
152
153#step
02746bbc
MS
154gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \
155 "step into mainshr1"
c906108c
SS
156
157# Start with a fresh gdb.
158
159gdb_exit
160gdb_start
161gdb_reinitialize_dir $srcdir/$subdir
162gdb_load ${binfile}
02746bbc
MS
163gdb_test_no_output "set print sevenbit-strings"
164gdb_test_no_output "set print address off"
165gdb_test_no_output "set width 0"
166
c906108c
SS
167
168# PR's 16495, 18213
169# test that we can re-set breakpoints in shared libraries
55264cb4 170gdb_breakpoint "shr1" "allow-pending"
13a5e3b8
MS
171
172# FIXME: should not send "run" explicitly. Non-portable.
173
676a0442 174if ![is_remote target] {
55264cb4 175 gdb_test "run" "Starting program:.*Breakpoint .,.*" \
13a5e3b8
MS
176 "run to bp in shared library"
177
eceb0c5f 178 gdb_continue_to_end "" continue 1
13a5e3b8 179
55264cb4 180 gdb_test "run" "Starting program:.*Breakpoint .,.*" \
13a5e3b8
MS
181 "re-run to bp in shared library (PR's 16495, 18213)"
182
eceb0c5f 183 gdb_continue_to_end "" continue 1
676a0442 184}
c906108c
SS
185
186return 0