gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / so-indr-cl.exp
CommitLineData
0fb0cc75 1# Copyright 1997, 1998, 1999, 2000, 2007, 2008, 2009
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
21set prms_id 0
22set bug_id 0
23
24# are we on a target board
25if ![isnative] then {
26 return
27}
28
29# This test is presently only valid on HP-UX, since it requires
30# that we use HP-UX-specific compiler & linker options to build
31# the testcase.
32#
0d06e24b
JM
33if {! [istarget "hppa*-*-*hpux*"] } {
34 return
35}
c906108c
SS
36
37set libfile "solib"
38set testfile "so-indr-cl"
39set srcfile ${testfile}.c
40set binfile ${objdir}/${subdir}/${testfile}
41
42if [get_compiler_info ${binfile}] {
43 return -1
44}
45
46# Build the shared libraries this test case needs.
47#
48#cd ${subdir}
49#remote_exec build "$CC -g +z -c ${libfile}1.c -o ${libfile}1.o"
50
51
085dd6e6
JM
52if {$hp_cc_compiler || $hp_aCC_compiler} {
53 set additional_flags "additional_flags=+z"
c906108c
SS
54} else {
55 set additional_flags "additional_flags=-fpic"
56}
57if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} {
58 perror "Couldn't compile ${libfile}1.c"
59 return -1
60}
61
62if [istarget "hppa*-hp-hpux*"] then {
63 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}1.o -o ${objdir}/${subdir}/${libfile}1.sl"
64} else {
65 set additional_flags "additional_flags=-shared"
66 gdb_compile "${objdir}/${subdir}/${libfile}1.o" "${objdir}/${subdir}/${libfile}1.sl" executable [list debug $additional_flags]
67}
68
69# Build the test case
70#remote_exec build "$CC -Aa -g ${srcfile} ${libfile}1.sl -o ${binfile}"
71
72
085dd6e6
JM
73if {$hp_cc_compiler} {
74 set additional_flags "additional_flags=-Ae"
c906108c
SS
75} else {
76 set additional_flags ""
77}
78if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}/${libfile}1.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
79 perror "Couldn't build ${binfile}"
80 return -1
81}
82
83#cd ..
84
85# Start with a fresh gdb
86
87gdb_exit
88gdb_start
89gdb_reinitialize_dir $srcdir/$subdir
90gdb_load ${binfile}
91
92# This program implicitly loads SOM shared libraries. We wish to test
93# whether a user can set breakpoints in a shlib before running the
94# program, where the program doesn't directly call the shlib, but
95# indirectly does via passing its address to another function.
96#
97# ??rehrauer: Currently, this doesn't work, but we do catch the case
98# and explicitly disallow it. The reason it fails appears to be that
99#
100# [1] gdb consults only the linker symbol table in this scenario, and
101# [2] For a shlib function that is only indirectly called from the
102# main a.out, there is in the linker symbol table a stub whose
103# address is negative. Possibly this is to be interpreted as
104# an index into the DLT??
105#
106send_gdb "break solib_main\n"
107gdb_expect {
108 -re "Cannot break on solib_main without a running program.*$gdb_prompt $"\
109 {pass "break on indirect solib call before running"}
085dd6e6
JM
110 -re "Breakpoint.*deferred.*\\(\"solib_main\" was not found.*$gdb_prompt $"\
111 {pass "break on indirect solib call before running 2"}
c906108c
SS
112 -re "$gdb_prompt $"\
113 {fail "break on indirect solib call before running"}
114 timeout {fail "(timeout) break on indirect solib call before running"}
115}
116
117# However, if we do run to the program's main, we then ought to be
118# able to set a breakpoint on the indirectly called function. (Apparently,
119# once the inferior is running, gdb consults the debug info rather than
120# the linker symbol table, and is able to find the correct address.)
121#
122if ![runto_main] then { fail "indirect solib call tests suppressed" }
123
124# Verify that we can step over the first shlib call.
125#
126send_gdb "break solib_main\n"
127gdb_expect {
128 -re ".*\[Bb\]reakpoint \[0-9\]* at 0x\[0-9a-fA-F\]*: file.*${libfile}1.c.*$gdb_prompt $"\
129 {pass "break on indirect solib call after running"}
130 -re "$gdb_prompt $"\
131 {fail "break on indirect solib call after running"}
132 timeout {fail "(timeout) break on indirect solib call after running"}
133}
134
135gdb_exit
136return 0
This page took 0.893199 seconds and 4 git commands to generate.