GDB: trad-frame: Store length of value_bytes in trad_frame_saved_reg
[binutils-gdb.git] / gdb / testsuite / gdb.base / shlib-call.exp
blob4a963ed6a125d76b0de4ea0983a4af180e9a9d8b
1 # Copyright 1997-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # file to test calls into shared libraries
17 # the source files for this test are:
19 # shmain.c
20 # shr1.c (shared lib)
21 # shr2.c (shared lib)
22 # ss.h (header for shr2.c)
24 # file written by Elena Zannoni: elz@ch.apollo.com
27 #debug shmain
28 #prop lib shr1.sl
29 #prop lib shr2.sl
32 require allow_shlib_tests
34 if { [is_remote host] } {
35 gdb_remote_download host $srcdir/$subdir/ss.h
38 standard_testfile shmain.c shr1.c shr2.c
39 set srcfile ${srcdir}/${subdir}/${srcfile}
40 set lib1src ${srcdir}/${subdir}/${srcfile2}
41 set lib2src ${srcdir}/${subdir}/${srcfile3}
42 set lib1 [standard_output_file shr1.sl]
43 set lib2 [standard_output_file shr2.sl]
45 set lib_opts "debug"
47 set exec_opts {}
48 lappend exec_opts debug
49 lappend exec_opts shlib=$lib1
50 lappend exec_opts shlib=$lib2
51 lappend_include_file exec_opts $srcdir/lib/unbuffer_output.c
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 "failed to compile"
57 return -1
60 # Start with a fresh gdb.
62 clean_restart ${binfile}
63 gdb_load_shlib $lib1
64 gdb_load_shlib $lib2
67 if {![runto_main]} {
68 return
72 #step -over
74 gdb_test "next 2" "g = shr1\\(g\\);" "next to shr1"
76 #print g
78 gdb_test "print g" "\[0-9\]* = 1"
80 #step -over
81 if ![gdb_skip_stdio_test "next over shr1"] {
82 gdb_test_stdio "next" \
83 "address of sgs is $hex" \
84 "g = shr2\\(g\\);" \
85 "next over shr1"
86 } else {
87 gdb_test "next" ".*" ""
91 #print g
92 gdb_test "print g" "\[0-9\]* = 2" "print g two"
94 #print shr1(1)
95 if ![gdb_skip_stdio_test "print shr1(1)"] {
96 gdb_test_stdio "print shr1(1)" \
97 "address of sgs is $hex" \
98 "\[0-9\]* = 2" \
99 "print shr1(1)"
102 #print shr1(g)
103 if ![gdb_skip_stdio_test "print shr1(g)"] {
104 gdb_test_stdio "print shr1(g)" \
105 "address of sgs is $hex" \
106 "\[0-9\]* = 4" \
107 "print shr1(g)"
110 #break shr2
112 gdb_test "break shr2" \
113 "Breakpoint.*file.*shr2.c, line.*" \
114 "breakpoint function shr2"
116 gdb_test "continue" \
117 "Continuing\\..*Breakpoint ${decimal}, shr2 \\(.*\\) at.*shr2\\.c:${decimal}.*shr2-return \\*\\/" \
118 "run until breakpoint set at a function"
121 #print shr1(1)
122 if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] {
123 gdb_test_stdio "print shr1(1)" \
124 "address of sgs is $hex" \
125 "\[0-9\]* = 2" \
126 "print shr1(1) 2nd time"
129 #print mainshr1(1)
130 gdb_test "print mainshr1(1)" "\[0-9\]* = 2" \
131 "print mainshr1(1) from shlib func"
133 #step -return
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.
138 gdb_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"
142 -re ".*\\\}.*$gdb_prompt $" {
143 pass "step out of shr2 to main (stopped in shr2 epilogue)"
144 gdb_test_multiple "step" "step out of shr2 epilogue to main" {
145 -re -wrap "main \\(\\) at.*g = mainshr1\\(g\\);" {
146 pass $gdb_test_name
148 -re -wrap "main \\(\\) at.*g = shr2\\(g\\);" {
149 gdb_test "step" "g = mainshr1\\(g\\);" $gdb_test_name
155 #print mainshr1(1)
156 gdb_test "print mainshr1(1)" "\[0-9\]* = 2"
158 #step
159 gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \
160 "step into mainshr1"
162 # Start with a fresh gdb.
164 clean_restart $binfile
166 # PR's 16495, 18213
167 # test that we can re-set breakpoints in shared libraries
168 gdb_breakpoint "shr1" "allow-pending"
170 set test "run to bp in shared library"
171 gdb_run_cmd
172 gdb_test_multiple "" $test {
173 -re "Breakpoint .,.*${gdb_prompt} " {
174 pass $gdb_test_name
178 gdb_continue_to_end "" continue 1
180 set test "re-run to bp in shared library (PR's 16495, 18213)"
181 gdb_run_cmd
182 gdb_test_multiple "" $test {
183 -re "Breakpoint .,.*${gdb_prompt} " {
184 pass $gdb_test_name
188 gdb_continue_to_end "after re-run" continue 1