Commit | Line | Data |
---|---|---|
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 | ||
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 | default { } | |
53 | } | |
54 | ||
55 | if { [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 | ||
62 | if {$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 | ||
81 | if {[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 | ||
85 | if [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 | ||
94 | gdb_exit | |
95 | gdb_start | |
96 | gdb_reinitialize_dir $srcdir/$subdir | |
97 | gdb_load ${binfile} | |
98 | ||
99 | if [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 | ||
108 | gdb_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 | ||
114 | gdb_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 | ||
119 | set unloadshr_line [gdb_get_line_number "unloadshr break" ${srcdir}/${subdir}/${libsrcfile}] | |
120 | ||
121 | gdb_test "run" \ | |
122 | "Starting program.*unload.* | |
123 | Breakpoint.*at.* | |
124 | Pending breakpoint \"shrfunc1\" resolved.* | |
125 | Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \ | |
126 | "running program" | |
127 | ||
128 | gdb_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 | ||
136 | gdb_test "run" \ | |
137 | ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \ | |
138 | "rerun to shared library breakpoint" | |
139 | ||
140 | gdb_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 |