Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2003-2020 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 |
22 | if {[skip_shlib_tests]} { |
23 | return 0 | |
24 | } | |
25 | ||
37fdf854 JJ |
26 | set testfile "unload" |
27 | set libfile "unloadshr" | |
859825b8 | 28 | set libfile2 "unloadshr2" |
255e7678 | 29 | set libname "${libfile}.sl" |
859825b8 | 30 | set libname2 "${libfile2}.sl" |
37fdf854 | 31 | set libsrcfile ${libfile}.c |
859825b8 | 32 | set libsrcfile2 ${libfile2}.c |
5ea106f7 | 33 | set srcfile $srcdir/$subdir/$testfile.c |
62cef515 TT |
34 | set binfile [standard_output_file $testfile] |
35 | set shlibdir [standard_output_file {}] | |
5ea106f7 | 36 | set libsrc $srcdir/$subdir/$libfile.c |
859825b8 | 37 | set libsrc2 $srcdir/$subdir/$libfile2.c |
62cef515 TT |
38 | set lib_sl [standard_output_file $libname] |
39 | set lib_sl2 [standard_output_file $libname2] | |
759f0f0b PA |
40 | set lib_dlopen [shlib_target_file ${libname}] |
41 | set lib_dlopen2 [shlib_target_file ${libname2}] | |
42 | set lib_syms [shlib_symbol_file ${libname}] | |
43 | set lib_syms2 [shlib_symbol_file ${libname2}] | |
37fdf854 | 44 | |
4c93b1db | 45 | if [get_compiler_info] { |
5ea106f7 | 46 | return -1 |
37fdf854 JJ |
47 | } |
48 | ||
255e7678 | 49 | set lib_opts debug |
c588eb20 | 50 | set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2=\"${lib_dlopen2}\"] |
255e7678 | 51 | |
5ea106f7 | 52 | if { [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] != ""} { |
84c93cd5 | 55 | untested "failed to compile" |
5ea106f7 | 56 | return -1 |
37fdf854 JJ |
57 | } |
58 | ||
5ea106f7 | 59 | # Start with a fresh gdb. |
37fdf854 JJ |
60 | |
61 | gdb_exit | |
62 | gdb_start | |
63 | gdb_reinitialize_dir $srcdir/$subdir | |
64 | gdb_load ${binfile} | |
d9019901 SM |
65 | gdb_load_shlib $lib_sl |
66 | gdb_load_shlib $lib_sl2 | |
37fdf854 | 67 | |
37fdf854 JJ |
68 | # |
69 | # Test setting a breakpoint in a dynamically loaded library which is | |
70 | # manually loaded and unloaded | |
71 | # | |
72 | ||
859825b8 JK |
73 | gdb_breakpoint "shrfunc1" allow-pending |
74 | gdb_breakpoint "shrfunc2" allow-pending | |
37fdf854 JJ |
75 | |
76 | gdb_test "info break" \ | |
859825b8 JK |
77 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? |
78 | 1\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r? | |
79 | 2\[\t \]+breakpoint keep y *<PENDING> *shrfunc2" \ | |
80 | "pending breakpoint info before run" | |
37fdf854 | 81 | |
0107feed | 82 | set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}] |
37fdf854 | 83 | |
b741e217 DJ |
84 | gdb_run_cmd |
85 | gdb_test "" \ | |
859825b8 | 86 | "Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \ |
37fdf854 JJ |
87 | "running program" |
88 | ||
859825b8 JK |
89 | gdb_test "info break" \ |
90 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? | |
91 | 1\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .* | |
92 | 2\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \ | |
93 | "pending breakpoint info on first run at shrfunc1" | |
94 | ||
95 | gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary | |
96 | ||
37fdf854 | 97 | gdb_test "continue" \ |
759f0f0b | 98 | "Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \ |
859825b8 JK |
99 | "continuing to unloaded libfile" |
100 | ||
101 | gdb_test "print y" " = 10" "print y from libfile" | |
37fdf854 JJ |
102 | |
103 | # | |
104 | # Try to rerun program and verify that shared breakpoint is reset properly | |
105 | # | |
106 | ||
b741e217 DJ |
107 | gdb_run_cmd |
108 | gdb_test "" \ | |
859825b8 | 109 | "Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \ |
37fdf854 JJ |
110 | "rerun to shared library breakpoint" |
111 | ||
859825b8 JK |
112 | gdb_test "info break" \ |
113 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? | |
114 | 1\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .* | |
115 | 2\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \ | |
116 | "pending breakpoint info on second run at shrfunc1" | |
117 | ||
118 | gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary | |
119 | ||
120 | gdb_test "continue" \ | |
759f0f0b | 121 | "Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \ |
859825b8 JK |
122 | "continuing to unloaded libfile" |
123 | ||
124 | set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}] | |
125 | ||
126 | gdb_test "continue" \ | |
127 | "Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \ | |
128 | "continue to shrfunc2" | |
129 | ||
130 | gdb_test "info break" \ | |
131 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? | |
132 | 1\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r? | |
133 | \[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r? | |
134 | 2\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \ | |
135 | "pending breakpoint info on second run at shrfunc2" | |
136 | ||
137 | gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]" | |
138 | ||
37fdf854 | 139 | gdb_test "continue" \ |
759f0f0b | 140 | "Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms2}.*y-set-2.*" \ |
859825b8 | 141 | "continuing to unloaded libfile2" |
edd9b715 | 142 | |
859825b8 | 143 | gdb_test "print y" " = 200" "print y from libfile2" |