* lib/gdb.exp (skip_altivec_tests, skip_vsx_tests)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / shlib-call.exp
1 # Copyright 1997-2000, 2004, 2007-2012 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
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
31
32 if {[skip_shlib_tests]} {
33 return 0
34 }
35
36 set testfile "shmain"
37 set libfile1 "shr1"
38 set libfile2 "shr2"
39 set srcfile ${srcdir}/${subdir}/${testfile}.c
40 set lib1src ${srcdir}/${subdir}/${libfile1}.c
41 set lib2src ${srcdir}/${subdir}/${libfile2}.c
42 set lib1 ${objdir}/${subdir}/${libfile1}.sl
43 set lib2 ${objdir}/${subdir}/${libfile2}.sl
44 set binfile ${objdir}/${subdir}/${testfile}
45
46 set lib_opts "debug"
47 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
48
49 if [get_compiler_info] {
50 return -1
51 }
52
53 if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != ""
54 || [gdb_compile_shlib ${lib2src} ${lib2} $lib_opts] != ""
55 || [gdb_compile ${srcfile} ${binfile} executable $exec_opts] != ""} {
56 untested "Could not compile $lib1, $lib2, or $srcfile."
57 return -1
58 }
59
60 # Start with a fresh gdb.
61
62 gdb_exit
63 gdb_start
64 gdb_reinitialize_dir $srcdir/$subdir
65 gdb_load ${binfile}
66 gdb_load_shlibs $lib1 $lib2
67
68 gdb_test_no_output "set print sevenbit-strings"
69 gdb_test_no_output "set print address off"
70 gdb_test_no_output "set width 0"
71
72
73 if ![runto_main] then {
74 perror "C function calling tests suppressed"
75 }
76
77
78 #step -over
79
80 gdb_test "next" "g = shr1\\(g\\);" "next to shr1"
81
82 #print g
83
84 gdb_test "print g" "\[0-9\]* = 1" "print g"
85
86 #step -over
87 if ![gdb_skip_stdio_test "next over shr1"] {
88 gdb_test "next" \
89 "address of sgs is $hex.*g = shr2\\(g\\);" \
90 "next over shr1"
91 } else {
92 gdb_test "next" ".*" ""
93 }
94
95
96 #print g
97 gdb_test "print g" "\[0-9\]* = 2" "print g"
98
99 #print shr1(1)
100 if ![gdb_skip_stdio_test "print shr1(1)"] {
101 gdb_test "print shr1(1)" \
102 "address of sgs is $hex.*\[0-9\]* = 2" \
103 "print shr1(1)"
104 }
105
106 #print shr1(g)
107 if ![gdb_skip_stdio_test "print shr1(g)"] {
108 gdb_test "print shr1(g)" \
109 "address of sgs is $hex.*\[0-9\]* = 4" \
110 "print shr1(g)"
111 }
112
113 #break shr2
114 #go
115 gdb_test "break shr2" \
116 "Breakpoint.*file.*shr2.c, line.*" \
117 "breakpoint function shr2"
118
119 gdb_test "continue" \
120 "Continuing\\..*Breakpoint \[0-9\]+, shr2 \\(.*\\) at.*shr2\\.c:7.*7.*return 2.x;" \
121 "run until breakpoint set at a function"
122
123
124 #print shr1(1)
125 if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] {
126 gdb_test "print shr1(1)" \
127 "address of sgs is $hex.*\[0-9\]* = 2" \
128 "print shr1(1) 2nd time"
129 }
130
131 #print mainshr1(1)
132 gdb_test "print mainshr1(1)" "\[0-9\]* = 2" \
133 "print mainshr1(1) from shlib func"
134
135 #step -return
136 # A step at this point will either take us entirely out of
137 # the function or into the function's epilogue. The exact
138 # behavior will differ depending upon upon whether or not
139 # the compiler emits line number information for the epilogue.
140 gdb_test_multiple "step" "step out of shr2 to main" {
141 -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" {
142 pass "step out of shr2 to main"
143 }
144 -re ".*\\\}.*$gdb_prompt $" {
145 pass "step out of shr2 to main (stopped in shr2 epilogue)"
146 gdb_test "step" \
147 "main \\(\\) at.*g = mainshr1\\(g\\);" \
148 "step out of shr2 epilogue to main"
149 }
150 }
151
152 #print mainshr1(1)
153 gdb_test "print mainshr1(1)" "\[0-9\]* = 2" "print mainshr1(1)"
154
155 #step
156 gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \
157 "step into mainshr1"
158
159 # Start with a fresh gdb.
160
161 gdb_exit
162 gdb_start
163 gdb_reinitialize_dir $srcdir/$subdir
164 gdb_load ${binfile}
165 gdb_test_no_output "set print sevenbit-strings"
166 gdb_test_no_output "set print address off"
167 gdb_test_no_output "set width 0"
168
169
170 # PR's 16495, 18213
171 # test that we can re-set breakpoints in shared libraries
172 gdb_breakpoint "shr1" "allow-pending"
173
174 # FIXME: should not send "run" explicitly. Non-portable.
175
176 if ![is_remote target] {
177 gdb_test "run" "Starting program:.*Breakpoint .,.*" \
178 "run to bp in shared library"
179
180 gdb_continue_to_end "" continue 1
181
182 gdb_test "run" "Starting program:.*Breakpoint .,.*" \
183 "re-run to bp in shared library (PR's 16495, 18213)"
184
185 gdb_continue_to_end "" continue 1
186 }
187
188 return 0
This page took 0.032811 seconds and 4 git commands to generate.