ld/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / unload.exp
CommitLineData
0b302171 1# Copyright 2003-2005, 2007-2012 Free Software Foundation, Inc.
37fdf854
JJ
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
37fdf854 6# (at your option) any later version.
e22f8b7c 7#
37fdf854
JJ
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
e22f8b7c 12#
37fdf854 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
37fdf854
JJ
15
16# This file was created by Jeff Johnston. (jjohnstn@redhat.com)
37fdf854 17
37fdf854
JJ
18#
19# test running programs
20#
37fdf854 21
93f02886
DJ
22if {[skip_shlib_tests]} {
23 return 0
24}
25
37fdf854
JJ
26set testfile "unload"
27set libfile "unloadshr"
859825b8 28set libfile2 "unloadshr2"
255e7678 29set libname "${libfile}.sl"
859825b8 30set libname2 "${libfile2}.sl"
37fdf854 31set libsrcfile ${libfile}.c
859825b8 32set libsrcfile2 ${libfile2}.c
5ea106f7
PG
33set srcfile $srcdir/$subdir/$testfile.c
34set binfile $objdir/$subdir/$testfile
37fdf854 35set shlibdir ${objdir}/${subdir}
5ea106f7 36set libsrc $srcdir/$subdir/$libfile.c
859825b8 37set libsrc2 $srcdir/$subdir/$libfile2.c
255e7678 38set lib_sl $objdir/$subdir/$libname
859825b8 39set lib_sl2 $objdir/$subdir/$libname2
759f0f0b
PA
40set lib_dlopen [shlib_target_file ${libname}]
41set lib_dlopen2 [shlib_target_file ${libname2}]
42set lib_syms [shlib_symbol_file ${libname}]
43set lib_syms2 [shlib_symbol_file ${libname2}]
37fdf854 44
5ea106f7
PG
45if [get_compiler_info ${binfile}] {
46 return -1
37fdf854
JJ
47}
48
255e7678 49set lib_opts debug
759f0f0b 50set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2\=\"${lib_dlopen2}\"]
255e7678 51
5ea106f7 52if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
859825b8 53 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
5ea106f7 54 || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
859825b8 55 untested "Couldn't compile $libsrc or $libsrc2 or $srcfile."
5ea106f7 56 return -1
37fdf854
JJ
57}
58
5ea106f7 59# Start with a fresh gdb.
37fdf854
JJ
60
61gdb_exit
62gdb_start
63gdb_reinitialize_dir $srcdir/$subdir
64gdb_load ${binfile}
859825b8 65gdb_load_shlibs $lib_sl $lib_sl2
37fdf854 66
37fdf854
JJ
67#
68# Test setting a breakpoint in a dynamically loaded library which is
69# manually loaded and unloaded
70#
71
859825b8
JK
72gdb_breakpoint "shrfunc1" allow-pending
73gdb_breakpoint "shrfunc2" allow-pending
37fdf854
JJ
74
75gdb_test "info break" \
859825b8
JK
76 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
771\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r?
782\[\t \]+breakpoint keep y *<PENDING> *shrfunc2" \
79"pending breakpoint info before run"
37fdf854 80
0107feed 81set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
37fdf854 82
b741e217
DJ
83gdb_run_cmd
84gdb_test "" \
859825b8 85"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
37fdf854
JJ
86"running program"
87
859825b8
JK
88gdb_test "info break" \
89 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
901\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
912\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \
92"pending breakpoint info on first run at shrfunc1"
93
94gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
95
37fdf854 96gdb_test "continue" \
759f0f0b 97"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \
859825b8
JK
98"continuing to unloaded libfile"
99
100gdb_test "print y" " = 10" "print y from libfile"
37fdf854
JJ
101
102#
103# Try to rerun program and verify that shared breakpoint is reset properly
104#
105
b741e217
DJ
106gdb_run_cmd
107gdb_test "" \
859825b8 108"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
37fdf854
JJ
109"rerun to shared library breakpoint"
110
859825b8
JK
111gdb_test "info break" \
112 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
1131\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
1142\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \
115"pending breakpoint info on second run at shrfunc1"
116
117gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
118
119gdb_test "continue" \
759f0f0b 120"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \
859825b8
JK
121"continuing to unloaded libfile"
122
123set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}]
124
125gdb_test "continue" \
126"Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \
127"continue to shrfunc2"
128
129gdb_test "info break" \
130 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
1311\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r?
132\[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r?
1332\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \
134"pending breakpoint info on second run at shrfunc2"
135
136gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]"
137
37fdf854 138gdb_test "continue" \
759f0f0b 139"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms2}.*y-set-2.*" \
859825b8 140"continuing to unloaded libfile2"
edd9b715 141
859825b8 142gdb_test "print y" " = 200" "print y from libfile2"
This page took 0.78569 seconds and 4 git commands to generate.