aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/so-indr-cl.exp
blob: 8d46cc7f306b31f8864fb8a11b7620040fb24176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#   Copyright 1997, 1998, 1999, 2000, 2007 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu

if $tracelevel then {
	strace $tracelevel
	}

set prms_id 0
set bug_id 0

# are we on a target board
if ![isnative] then {
    return
}

# This test is presently only valid on HP-UX, since it requires
# that we use HP-UX-specific compiler & linker options to build
# the testcase.
#
if {! [istarget "hppa*-*-*hpux*"] } {
    return
}

set libfile "solib"
set testfile "so-indr-cl"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}

if [get_compiler_info ${binfile}] {
    return -1
}

# Build the shared libraries this test case needs.
#
#cd ${subdir}
#remote_exec build "$CC -g +z -c ${libfile}1.c -o ${libfile}1.o"


if {$hp_cc_compiler || $hp_aCC_compiler} {
    set additional_flags "additional_flags=+z"
} else {
    set additional_flags "additional_flags=-fpic"
}
if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} {
    perror "Couldn't compile ${libfile}1.c"
    return -1
}

if [istarget "hppa*-hp-hpux*"] then {
    remote_exec build "ld -b ${objdir}/${subdir}/${libfile}1.o -o ${objdir}/${subdir}/${libfile}1.sl"
} else {
    set additional_flags "additional_flags=-shared"
    gdb_compile "${objdir}/${subdir}/${libfile}1.o" "${objdir}/${subdir}/${libfile}1.sl" executable [list debug $additional_flags]
}

# Build the test case
#remote_exec build "$CC -Aa -g ${srcfile} ${libfile}1.sl -o ${binfile}"


if {$hp_cc_compiler} {
    set additional_flags "additional_flags=-Ae"
} else {
    set additional_flags ""
}
if {[gdb_compile "${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}/${libfile}1.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
    perror "Couldn't build ${binfile}"
    return -1
}

#cd ..

# Start with a fresh gdb

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}

# This program implicitly loads SOM shared libraries.  We wish to test
# whether a user can set breakpoints in a shlib before running the
# program, where the program doesn't directly call the shlib, but
# indirectly does via passing its address to another function.
#
# ??rehrauer: Currently, this doesn't work, but we do catch the case
# and explicitly disallow it.  The reason it fails appears to be that
#
#  [1] gdb consults only the linker symbol table in this scenario, and
#  [2] For a shlib function that is only indirectly called from the
#      main a.out, there is in the linker symbol table a stub whose
#      address is negative.  Possibly this is to be interpreted as
#      an index into the DLT??
#
send_gdb "break solib_main\n"
gdb_expect {
  -re "Cannot break on solib_main without a running program.*$gdb_prompt $"\
          {pass "break on indirect solib call before running"}
  -re "Breakpoint.*deferred.*\\(\"solib_main\" was not found.*$gdb_prompt $"\
	  {pass "break on indirect solib call before running 2"}
  -re "$gdb_prompt $"\
          {fail "break on indirect solib call before running"}
  timeout {fail "(timeout) break on indirect solib call before running"}
}

# However, if we do run to the program's main, we then ought to be
# able to set a breakpoint on the indirectly called function.  (Apparently,
# once the inferior is running, gdb consults the debug info rather than
# the linker symbol table, and is able to find the correct address.)
#
if ![runto_main] then { fail "indirect solib call tests suppressed" }

# Verify that we can step over the first shlib call.
#
send_gdb "break solib_main\n"
gdb_expect {
  -re ".*\[Bb\]reakpoint \[0-9\]* at 0x\[0-9a-fA-F\]*: file.*${libfile}1.c.*$gdb_prompt $"\
          {pass "break on indirect solib call after running"}
  -re "$gdb_prompt $"\
          {fail "break on indirect solib call after running"}
  timeout {fail "(timeout) break on indirect solib call after running"}
}

gdb_exit
return 0