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