]> Git Repo - binutils.git/blame - gdb/testsuite/gdb.base/unload.exp
Copyright year update in most files of the GDB Project.
[binutils.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. ([email protected])
37fdf854
JJ
17
18if $tracelevel then {
19 strace $tracelevel
20}
21
22#
23# test running programs
24#
37fdf854 25
93f02886
DJ
26if {[skip_shlib_tests]} {
27 return 0
28}
29
37fdf854
JJ
30set testfile "unload"
31set libfile "unloadshr"
859825b8 32set libfile2 "unloadshr2"
255e7678 33set libname "${libfile}.sl"
859825b8 34set libname2 "${libfile2}.sl"
37fdf854 35set libsrcfile ${libfile}.c
859825b8 36set libsrcfile2 ${libfile2}.c
5ea106f7
PG
37set srcfile $srcdir/$subdir/$testfile.c
38set binfile $objdir/$subdir/$testfile
37fdf854 39set shlibdir ${objdir}/${subdir}
5ea106f7 40set libsrc $srcdir/$subdir/$libfile.c
859825b8 41set libsrc2 $srcdir/$subdir/$libfile2.c
255e7678 42set lib_sl $objdir/$subdir/$libname
859825b8 43set lib_sl2 $objdir/$subdir/$libname2
759f0f0b
PA
44set lib_dlopen [shlib_target_file ${libname}]
45set lib_dlopen2 [shlib_target_file ${libname2}]
46set lib_syms [shlib_symbol_file ${libname}]
47set lib_syms2 [shlib_symbol_file ${libname2}]
37fdf854 48
5ea106f7
PG
49if [get_compiler_info ${binfile}] {
50 return -1
37fdf854
JJ
51}
52
255e7678 53set lib_opts debug
759f0f0b 54set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2\=\"${lib_dlopen2}\"]
255e7678 55
5ea106f7 56if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
859825b8 57 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
5ea106f7 58 || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
859825b8 59 untested "Couldn't compile $libsrc or $libsrc2 or $srcfile."
5ea106f7 60 return -1
37fdf854
JJ
61}
62
5ea106f7 63# Start with a fresh gdb.
37fdf854
JJ
64
65gdb_exit
66gdb_start
67gdb_reinitialize_dir $srcdir/$subdir
68gdb_load ${binfile}
859825b8 69gdb_load_shlibs $lib_sl $lib_sl2
37fdf854 70
37fdf854
JJ
71#
72# Test setting a breakpoint in a dynamically loaded library which is
73# manually loaded and unloaded
74#
75
859825b8
JK
76gdb_breakpoint "shrfunc1" allow-pending
77gdb_breakpoint "shrfunc2" allow-pending
37fdf854
JJ
78
79gdb_test "info break" \
859825b8
JK
80 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
811\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r?
822\[\t \]+breakpoint keep y *<PENDING> *shrfunc2" \
83"pending breakpoint info before run"
37fdf854 84
0107feed 85set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
37fdf854 86
b741e217
DJ
87gdb_run_cmd
88gdb_test "" \
859825b8 89"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
37fdf854
JJ
90"running program"
91
859825b8
JK
92gdb_test "info break" \
93 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
941\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
952\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \
96"pending breakpoint info on first run at shrfunc1"
97
98gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
99
37fdf854 100gdb_test "continue" \
759f0f0b 101"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \
859825b8
JK
102"continuing to unloaded libfile"
103
104gdb_test "print y" " = 10" "print y from libfile"
37fdf854
JJ
105
106#
107# Try to rerun program and verify that shared breakpoint is reset properly
108#
109
b741e217
DJ
110gdb_run_cmd
111gdb_test "" \
859825b8 112"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
37fdf854
JJ
113"rerun to shared library breakpoint"
114
859825b8
JK
115gdb_test "info break" \
116 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
1171\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
1182\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \
119"pending breakpoint info on second run at shrfunc1"
120
121gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
122
123gdb_test "continue" \
759f0f0b 124"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \
859825b8
JK
125"continuing to unloaded libfile"
126
127set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}]
128
129gdb_test "continue" \
130"Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \
131"continue to shrfunc2"
132
133gdb_test "info break" \
134 "Num Type\[ \]+Disp Enb Address\[ \]+What\r?
1351\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r?
136\[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r?
1372\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \
138"pending breakpoint info on second run at shrfunc2"
139
140gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]"
141
37fdf854 142gdb_test "continue" \
759f0f0b 143"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms2}.*y-set-2.*" \
859825b8 144"continuing to unloaded libfile2"
edd9b715 145
859825b8 146gdb_test "print y" " = 200" "print y from libfile2"
This page took 1.738481 seconds and 4 git commands to generate.