* configure.host: Use aix.mh for all powerpc-aix hosts.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / unload.exp
CommitLineData
37fdf854
JJ
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
22if $tracelevel then {
23 strace $tracelevel
24}
25
26#
27# test running programs
28#
29set prms_id 0
30set bug_id 0
31
32# are we on a target board?
33if ![isnative] then {
34 return 0
35}
36
37set testfile "unload"
38set libfile "unloadshr"
39set libsrcfile ${libfile}.c
40set srcfile ${testfile}.c
41set binfile ${objdir}/${subdir}/${testfile}
42set shlibdir ${objdir}/${subdir}
43
44if [get_compiler_info ${binfile}] {
45 return -1
46}
47
48set dl_lib_flag ""
49switch -glob [istarget] {
50 "hppa*-hp-hpux*" { }
51 "*-*-linux*" { set dl_lib_flag "libs=-ldl" }
52 default { }
53}
54
55if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"" $dl_lib_flag]] != "" } {
56 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
57}
58
59# Build the shared libraries this test case needs.
60#
61
62if {$gcc_compiled == 0} {
63 if [istarget "hppa*-hp-hpux*"] then {
64 set additional_flags "additional_flags=+z"
65 } elseif { [istarget "mips-sgi-irix*"] } {
66 # Disable SGI compiler's implicit -Dsgi
67 set additional_flags "additional_flags=-Usgi"
68 } else {
69 # don't know what the compiler is...
70 set additional_flags ""
71 }
72} else {
73 if { ([istarget "powerpc*-*-aix*"]
74 || [istarget "rs6000*-*-aix*"]) } {
75 set additional_flags ""
76 } else {
77 set additional_flags "additional_flags=-fpic"
78 }
79}
80
81if {[gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} {
82 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
83}
84
85if [istarget "hppa*-*-hpux*"] {
86 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
87} else {
88 set additional_flags "additional_flags=-shared"
89 if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} {
90 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
91 }
92}
93
94gdb_exit
95gdb_start
96gdb_reinitialize_dir $srcdir/$subdir
97gdb_load ${binfile}
98
99if [target_info exists gdb_stub] {
100 gdb_step_for_stub;
101}
102
103#
104# Test setting a breakpoint in a dynamically loaded library which is
105# manually loaded and unloaded
106#
107
108gdb_test_multiple "break shrfunc1" "set pending breakpoint" {
109 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
110 gdb_test "y" "Breakpoint.*shrfunc1.*pending." "set pending breakpoint"
111 }
112}
113
114gdb_test "info break" \
115 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
116\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*shrfunc1.*" \
117"single pending breakpoint info"
118
119set unloadshr_line [gdb_get_line_number "unloadshr break" ${srcdir}/${subdir}/${libsrcfile}]
120
121gdb_test "run" \
122"Starting program.*unload.*
123Breakpoint.*at.*
124Pending breakpoint \"shrfunc1\" resolved.*
125Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \
126"running program"
127
128gdb_test "continue" \
edd9b715 129"Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
37fdf854
JJ
130"continuing to end of program"
131
132#
133# Try to rerun program and verify that shared breakpoint is reset properly
134#
135
136gdb_test "run" \
137".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
138"rerun to shared library breakpoint"
139
140gdb_test "continue" \
edd9b715
JJ
141"Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
142"continuing to end of program"
143
This page took 0.033906 seconds and 4 git commands to generate.