run copyright.sh for 2011.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / so-indr-cl.exp
CommitLineData
7b6bb8da 1# Copyright 1997, 1998, 1999, 2000, 2007, 2008, 2009, 2010, 2011
9b254dd1 2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 16
c906108c
SS
17if $tracelevel then {
18 strace $tracelevel
19 }
20
c906108c
SS
21
22# are we on a target board
23if ![isnative] then {
24 return
25}
26
27# This test is presently only valid on HP-UX, since it requires
28# that we use HP-UX-specific compiler & linker options to build
29# the testcase.
30#
0d06e24b
JM
31if {! [istarget "hppa*-*-*hpux*"] } {
32 return
33}
c906108c
SS
34
35set libfile "solib"
36set testfile "so-indr-cl"
37set srcfile ${testfile}.c
38set binfile ${objdir}/${subdir}/${testfile}
39
40if [get_compiler_info ${binfile}] {
41 return -1
42}
43
44# Build the shared libraries this test case needs.
45#
46#cd ${subdir}
47#remote_exec build "$CC -g +z -c ${libfile}1.c -o ${libfile}1.o"
48
49
085dd6e6
JM
50if {$hp_cc_compiler || $hp_aCC_compiler} {
51 set additional_flags "additional_flags=+z"
c906108c
SS
52} else {
53 set additional_flags "additional_flags=-fpic"
54}
55if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} {
56 perror "Couldn't compile ${libfile}1.c"
57 return -1
58}
59
60if [istarget "hppa*-hp-hpux*"] then {
61 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}1.o -o ${objdir}/${subdir}/${libfile}1.sl"
62} else {
63 set additional_flags "additional_flags=-shared"
64 gdb_compile "${objdir}/${subdir}/${libfile}1.o" "${objdir}/${subdir}/${libfile}1.sl" executable [list debug $additional_flags]
65}
66
67# Build the test case
68#remote_exec build "$CC -Aa -g ${srcfile} ${libfile}1.sl -o ${binfile}"
69
70
085dd6e6
JM
71if {$hp_cc_compiler} {
72 set additional_flags "additional_flags=-Ae"
c906108c
SS
73} else {
74 set additional_flags ""
75}
76if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}/${libfile}1.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
77 perror "Couldn't build ${binfile}"
78 return -1
79}
80
81#cd ..
82
83# Start with a fresh gdb
84
85gdb_exit
86gdb_start
87gdb_reinitialize_dir $srcdir/$subdir
88gdb_load ${binfile}
89
90# This program implicitly loads SOM shared libraries. We wish to test
91# whether a user can set breakpoints in a shlib before running the
92# program, where the program doesn't directly call the shlib, but
93# indirectly does via passing its address to another function.
94#
95# ??rehrauer: Currently, this doesn't work, but we do catch the case
96# and explicitly disallow it. The reason it fails appears to be that
97#
98# [1] gdb consults only the linker symbol table in this scenario, and
99# [2] For a shlib function that is only indirectly called from the
100# main a.out, there is in the linker symbol table a stub whose
101# address is negative. Possibly this is to be interpreted as
102# an index into the DLT??
103#
104send_gdb "break solib_main\n"
105gdb_expect {
106 -re "Cannot break on solib_main without a running program.*$gdb_prompt $"\
107 {pass "break on indirect solib call before running"}
085dd6e6
JM
108 -re "Breakpoint.*deferred.*\\(\"solib_main\" was not found.*$gdb_prompt $"\
109 {pass "break on indirect solib call before running 2"}
c906108c
SS
110 -re "$gdb_prompt $"\
111 {fail "break on indirect solib call before running"}
112 timeout {fail "(timeout) break on indirect solib call before running"}
113}
114
115# However, if we do run to the program's main, we then ought to be
116# able to set a breakpoint on the indirectly called function. (Apparently,
117# once the inferior is running, gdb consults the debug info rather than
118# the linker symbol table, and is able to find the correct address.)
119#
120if ![runto_main] then { fail "indirect solib call tests suppressed" }
121
122# Verify that we can step over the first shlib call.
123#
124send_gdb "break solib_main\n"
125gdb_expect {
126 -re ".*\[Bb\]reakpoint \[0-9\]* at 0x\[0-9a-fA-F\]*: file.*${libfile}1.c.*$gdb_prompt $"\
127 {pass "break on indirect solib call after running"}
128 -re "$gdb_prompt $"\
129 {fail "break on indirect solib call after running"}
130 timeout {fail "(timeout) break on indirect solib call after running"}
131}
132
133gdb_exit
134return 0
This page took 1.228757 seconds and 4 git commands to generate.