]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/so-indr-cl.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / so-indr-cl.exp
1 # Copyright (C) 1997, 1998 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 if $tracelevel then {
21 strace $tracelevel
22 }
23
24 set prms_id 0
25 set bug_id 0
26
27 # are we on a target board
28 if ![isnative] then {
29 return
30 }
31
32 # This test is presently only valid on HP-UX, since it requires
33 # that we use HP-UX-specific compiler & linker options to build
34 # the testcase.
35 #
36 setup_xfail "*-*-*"
37 clear_xfail "hppa*-*-*hpux*"
38
39 set libfile "solib"
40 set testfile "so-indr-cl"
41 set srcfile ${testfile}.c
42 set binfile ${objdir}/${subdir}/${testfile}
43
44 if [get_compiler_info ${binfile}] {
45 return -1
46 }
47
48 # Build the shared libraries this test case needs.
49 #
50 #cd ${subdir}
51 #remote_exec build "$CC -g +z -c ${libfile}1.c -o ${libfile}1.o"
52
53
54 if {$gcc_compiled == 0} {
55 if [istarget "hppa*-hp-hpux*"] then {
56 set additional_flags "additional_flags=+z"
57 } else {
58 # don't know what the compiler is...
59 set additional_flags ""
60 }
61 } else {
62 set additional_flags "additional_flags=-fpic"
63 }
64 if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} {
65 perror "Couldn't compile ${libfile}1.c"
66 return -1
67 }
68
69 if [istarget "hppa*-hp-hpux*"] then {
70 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}1.o -o ${objdir}/${subdir}/${libfile}1.sl"
71 } else {
72 set additional_flags "additional_flags=-shared"
73 gdb_compile "${objdir}/${subdir}/${libfile}1.o" "${objdir}/${subdir}/${libfile}1.sl" executable [list debug $additional_flags]
74 }
75
76 # Build the test case
77 #remote_exec build "$CC -Aa -g ${srcfile} ${libfile}1.sl -o ${binfile}"
78
79
80 if {$gcc_compiled == 0} {
81 if [istarget "hppa*-hp-hpux*"] then {
82 set additional_flags "additional_flags=-Ae"
83 } else {
84 # don't know what the compiler is, hope for the best, maybe it's ANSI...
85 set additional_flags ""
86 }
87 } else {
88 set additional_flags ""
89 }
90 if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}/${libfile}1.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
91 perror "Couldn't build ${binfile}"
92 return -1
93 }
94
95 #cd ..
96
97 # Start with a fresh gdb
98
99 gdb_exit
100 gdb_start
101 gdb_reinitialize_dir $srcdir/$subdir
102 gdb_load ${binfile}
103
104 # This program implicitly loads SOM shared libraries. We wish to test
105 # whether a user can set breakpoints in a shlib before running the
106 # program, where the program doesn't directly call the shlib, but
107 # indirectly does via passing its address to another function.
108 #
109 # ??rehrauer: Currently, this doesn't work, but we do catch the case
110 # and explicitly disallow it. The reason it fails appears to be that
111 #
112 # [1] gdb consults only the linker symbol table in this scenario, and
113 # [2] For a shlib function that is only indirectly called from the
114 # main a.out, there is in the linker symbol table a stub whose
115 # address is negative. Possibly this is to be interpreted as
116 # an index into the DLT??
117 #
118 send_gdb "break solib_main\n"
119 gdb_expect {
120 -re "Cannot break on solib_main without a running program.*$gdb_prompt $"\
121 {pass "break on indirect solib call before running"}
122 -re "$gdb_prompt $"\
123 {fail "break on indirect solib call before running"}
124 timeout {fail "(timeout) break on indirect solib call before running"}
125 }
126
127 # However, if we do run to the program's main, we then ought to be
128 # able to set a breakpoint on the indirectly called function. (Apparently,
129 # once the inferior is running, gdb consults the debug info rather than
130 # the linker symbol table, and is able to find the correct address.)
131 #
132 if ![runto_main] then { fail "indirect solib call tests suppressed" }
133
134 # Verify that we can step over the first shlib call.
135 #
136 send_gdb "break solib_main\n"
137 gdb_expect {
138 -re ".*\[Bb\]reakpoint \[0-9\]* at 0x\[0-9a-fA-F\]*: file.*${libfile}1.c.*$gdb_prompt $"\
139 {pass "break on indirect solib call after running"}
140 -re "$gdb_prompt $"\
141 {fail "break on indirect solib call after running"}
142 timeout {fail "(timeout) break on indirect solib call after running"}
143 }
144
145 gdb_exit
146 return 0