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