unload.exp revision 1.7
1# Copyright 2003-2017 Free Software Foundation, Inc. 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 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 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. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# This file was created by Jeff Johnston. (jjohnstn@redhat.com) 17 18# 19# test running programs 20# 21 22if {[skip_shlib_tests]} { 23 return 0 24} 25 26set testfile "unload" 27set libfile "unloadshr" 28set libfile2 "unloadshr2" 29set libname "${libfile}.sl" 30set libname2 "${libfile2}.sl" 31set libsrcfile ${libfile}.c 32set libsrcfile2 ${libfile2}.c 33set srcfile $srcdir/$subdir/$testfile.c 34set binfile [standard_output_file $testfile] 35set shlibdir [standard_output_file {}] 36set libsrc $srcdir/$subdir/$libfile.c 37set libsrc2 $srcdir/$subdir/$libfile2.c 38set lib_sl [standard_output_file $libname] 39set lib_sl2 [standard_output_file $libname2] 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}] 44 45if [get_compiler_info] { 46 return -1 47} 48 49set lib_opts debug 50set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2=\"${lib_dlopen2}\"] 51 52if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" 53 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != "" 54 || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { 55 untested "failed to compile" 56 return -1 57} 58 59# Start with a fresh gdb. 60 61gdb_exit 62gdb_start 63gdb_reinitialize_dir $srcdir/$subdir 64gdb_load ${binfile} 65gdb_load_shlib $lib_sl 66gdb_load_shlib $lib_sl2 67 68# 69# Test setting a breakpoint in a dynamically loaded library which is 70# manually loaded and unloaded 71# 72 73gdb_breakpoint "shrfunc1" allow-pending 74gdb_breakpoint "shrfunc2" allow-pending 75 76gdb_test "info break" \ 77 "Num Type\[ \]+Disp Enb Address\[ \]+What\r? 781\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r? 792\[\t \]+breakpoint keep y *<PENDING> *shrfunc2" \ 80"pending breakpoint info before run" 81 82set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}] 83 84gdb_run_cmd 85gdb_test "" \ 86"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \ 87"running program" 88 89gdb_test "info break" \ 90 "Num Type\[ \]+Disp Enb Address\[ \]+What\r? 911\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .* 922\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \ 93"pending breakpoint info on first run at shrfunc1" 94 95gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary 96 97gdb_test "continue" \ 98"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \ 99"continuing to unloaded libfile" 100 101gdb_test "print y" " = 10" "print y from libfile" 102 103# 104# Try to rerun program and verify that shared breakpoint is reset properly 105# 106 107gdb_run_cmd 108gdb_test "" \ 109"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \ 110"rerun to shared library breakpoint" 111 112gdb_test "info break" \ 113 "Num Type\[ \]+Disp Enb Address\[ \]+What\r? 1141\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .* 1152\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \ 116"pending breakpoint info on second run at shrfunc1" 117 118gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary 119 120gdb_test "continue" \ 121"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \ 122"continuing to unloaded libfile" 123 124set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}] 125 126gdb_test "continue" \ 127"Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \ 128"continue to shrfunc2" 129 130gdb_test "info break" \ 131 "Num Type\[ \]+Disp Enb Address\[ \]+What\r? 1321\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r? 133\[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r? 1342\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \ 135"pending breakpoint info on second run at shrfunc2" 136 137gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]" 138 139gdb_test "continue" \ 140"Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms2}.*y-set-2.*" \ 141"continuing to unloaded libfile2" 142 143gdb_test "print y" " = 200" "print y from libfile2" 144