revert previous patch
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / unload.exp
CommitLineData
4c38e0a4 1# Copyright 2003, 2004, 2005, 2007, 2008, 2009, 2010
0fb0cc75 2# Free Software Foundation, Inc.
37fdf854
JJ
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
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
37fdf854 7# (at your option) any later version.
e22f8b7c 8#
37fdf854
JJ
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.
e22f8b7c 13#
37fdf854 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
37fdf854
JJ
16
17# This file was created by Jeff Johnston. (jjohnstn@redhat.com)
37fdf854
JJ
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
23#
24# test running programs
25#
37fdf854 26
93f02886
DJ
27if {[skip_shlib_tests]} {
28 return 0
29}
30
37fdf854
JJ
31set testfile "unload"
32set libfile "unloadshr"
859825b8 33set libfile2 "unloadshr2"
255e7678 34set libname "${libfile}.sl"
859825b8 35set libname2 "${libfile2}.sl"
37fdf854 36set libsrcfile ${libfile}.c
859825b8 37set libsrcfile2 ${libfile2}.c
5ea106f7
PG
38set srcfile $srcdir/$subdir/$testfile.c
39set binfile $objdir/$subdir/$testfile
37fdf854 40set shlibdir ${objdir}/${subdir}
5ea106f7 41set libsrc $srcdir/$subdir/$libfile.c
859825b8 42set libsrc2 $srcdir/$subdir/$libfile2.c
255e7678 43set lib_sl $objdir/$subdir/$libname
859825b8 44set lib_sl2 $objdir/$subdir/$libname2
759f0f0b
PA
45set lib_dlopen [shlib_target_file ${libname}]
46set lib_dlopen2 [shlib_target_file ${libname2}]
47set lib_syms [shlib_symbol_file ${libname}]
48set lib_syms2 [shlib_symbol_file ${libname2}]
37fdf854 49
5ea106f7
PG
50if [get_compiler_info ${binfile}] {
51 return -1
37fdf854
JJ
52}
53
255e7678 54set lib_opts debug
759f0f0b 55set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2\=\"${lib_dlopen2}\"]
255e7678 56
5ea106f7 57if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
859825b8 58 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
5ea106f7 59 || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
859825b8 60 untested "Couldn't compile $libsrc or $libsrc2 or $srcfile."
5ea106f7 61 return -1
37fdf854
JJ
62}
63
5ea106f7 64# Start with a fresh gdb.
37fdf854
JJ
65
66gdb_exit
67gdb_start
68gdb_reinitialize_dir $srcdir/$subdir
69gdb_load ${binfile}
859825b8 70gdb_load_shlibs $lib_sl $lib_sl2
37fdf854
JJ
71
72if [target_info exists gdb_stub] {
73 gdb_step_for_stub;
74}
75
76#
77# Test setting a breakpoint in a dynamically loaded library which is
78# manually loaded and unloaded
79#
80
859825b8
JK
81gdb_breakpoint "shrfunc1" allow-pending
82gdb_breakpoint "shrfunc2" allow-pending
37fdf854
JJ
83
84gdb_test "info break" \
859825b8
JK
85 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
861\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r?
872\[\t \]+breakpoint keep y *<PENDING> *shrfunc2" \
88"pending breakpoint info before run"
37fdf854 89
0107feed 90set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
37fdf854 91
b741e217
DJ
92gdb_run_cmd
93gdb_test "" \
859825b8 94"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
37fdf854
JJ
95"running program"
96
859825b8
JK
97gdb_test "info break" \
98 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
991\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
1002\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \
101"pending breakpoint info on first run at shrfunc1"
102
103gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
104
37fdf854 105gdb_test "continue" \
759f0f0b 106"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \
859825b8
JK
107"continuing to unloaded libfile"
108
109gdb_test "print y" " = 10" "print y from libfile"
37fdf854
JJ
110
111#
112# Try to rerun program and verify that shared breakpoint is reset properly
113#
114
b741e217
DJ
115gdb_run_cmd
116gdb_test "" \
859825b8 117"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
37fdf854
JJ
118"rerun to shared library breakpoint"
119
859825b8
JK
120gdb_test "info break" \
121 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
1221\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
1232\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \
124"pending breakpoint info on second run at shrfunc1"
125
126gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
127
128gdb_test "continue" \
759f0f0b 129"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \
859825b8
JK
130"continuing to unloaded libfile"
131
132set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}]
133
134gdb_test "continue" \
135"Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \
136"continue to shrfunc2"
137
138gdb_test "info break" \
139 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
1401\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r?
141\[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r?
1422\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \
143"pending breakpoint info on second run at shrfunc2"
144
145gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]"
146
37fdf854 147gdb_test "continue" \
759f0f0b 148"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms2}.*y-set-2.*" \
859825b8 149"continuing to unloaded libfile2"
edd9b715 150
859825b8 151gdb_test "print y" " = 200" "print y from libfile2"
This page took 0.591681 seconds and 4 git commands to generate.