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