2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
19 # The shared library compilation portion was copied from shlib-call.exp which was
20 # written by Elena Zannoni (ezannoni@redhat.com).
27 # test running programs
32 # are we on a target board?
38 set libfile "unloadshr"
39 set libsrcfile ${libfile}.c
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42 set shlibdir ${objdir}/${subdir}
44 if [get_compiler_info ${binfile}] {
49 switch -glob [istarget] {
51 "*-*-linux*" { set dl_lib_flag "libs=-ldl" }
52 "*-*-solaris*" { set dl_lib_flag "libs=-ldl" }
56 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"" $dl_lib_flag]] != "" } {
57 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
60 # Build the shared libraries this test case needs.
63 if {$gcc_compiled == 0} {
64 if [istarget "hppa*-hp-hpux*"] then {
65 set additional_flags "additional_flags=+z"
66 } elseif { [istarget "mips-sgi-irix*"] } {
67 # Disable SGI compiler's implicit -Dsgi
68 set additional_flags "additional_flags=-Usgi"
70 # don't know what the compiler is...
71 set additional_flags ""
74 if { ([istarget "powerpc*-*-aix*"]
75 || [istarget "rs6000*-*-aix*"]) } {
76 set additional_flags ""
78 set additional_flags "additional_flags=-fpic"
82 if {[gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} {
83 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
86 if [istarget "hppa*-*-hpux*"] {
87 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
89 set additional_flags "additional_flags=-shared"
90 if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} {
91 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
97 gdb_reinitialize_dir $srcdir/$subdir
100 if [target_info exists gdb_stub] {
105 # Test setting a breakpoint in a dynamically loaded library which is
106 # manually loaded and unloaded
109 gdb_test_multiple "break shrfunc1" "set pending breakpoint" {
110 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
111 gdb_test "y" "Breakpoint.*shrfunc1.*pending." "set pending breakpoint"
115 gdb_test "info break" \
116 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
117 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*shrfunc1.*" \
118 "single pending breakpoint info"
120 set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
123 "Starting program.*unload.*
125 Pending breakpoint \"shrfunc1\" resolved.*
126 Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \
129 gdb_test "continue" \
130 "Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
131 "continuing to end of program"
134 # Try to rerun program and verify that shared breakpoint is reset properly
138 ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
139 "rerun to shared library breakpoint"
141 gdb_test "continue" \
142 "Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
143 "continuing to end of program second time"