]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/unload.exp
This commit was manufactured by cvs2svn to create branch 'csl-
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / unload.exp
1 # Copyright 2003, 2004
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
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.
17
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).
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 #
27 # test running programs
28 #
29 set prms_id 0
30 set bug_id 0
31
32 # are we on a target board?
33 if ![isnative] then {
34 return 0
35 }
36
37 set testfile "unload"
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}
43
44 if [get_compiler_info ${binfile}] {
45 return -1
46 }
47
48 set dl_lib_flag ""
49 switch -glob [istarget] {
50 "hppa*-hp-hpux*" { }
51 "*-*-linux*" { set dl_lib_flag "libs=-ldl" }
52 "*-*-solaris*" { set dl_lib_flag "libs=-ldl" }
53 default { }
54 }
55
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."
58 }
59
60 # Build the shared libraries this test case needs.
61 #
62
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"
69 } else {
70 # don't know what the compiler is...
71 set additional_flags ""
72 }
73 } else {
74 if { ([istarget "powerpc*-*-aix*"]
75 || [istarget "rs6000*-*-aix*"]) } {
76 set additional_flags ""
77 } else {
78 set additional_flags "additional_flags=-fpic"
79 }
80 }
81
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."
84 }
85
86 if [istarget "hppa*-*-hpux*"] {
87 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
88 } else {
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."
92 }
93 }
94
95 gdb_exit
96 gdb_start
97 gdb_reinitialize_dir $srcdir/$subdir
98 gdb_load ${binfile}
99
100 if [target_info exists gdb_stub] {
101 gdb_step_for_stub;
102 }
103
104 #
105 # Test setting a breakpoint in a dynamically loaded library which is
106 # manually loaded and unloaded
107 #
108
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"
112 }
113 }
114
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"
119
120 set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
121
122 gdb_test "run" \
123 "Starting program.*unload.*
124 Breakpoint.*at.*
125 Pending breakpoint \"shrfunc1\" resolved.*
126 Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \
127 "running program"
128
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"
132
133 #
134 # Try to rerun program and verify that shared breakpoint is reset properly
135 #
136
137 gdb_test "run" \
138 ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
139 "rerun to shared library breakpoint"
140
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"
144