]>
Commit | Line | Data |
---|---|---|
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 | |
18 | if $tracelevel then { | |
19 | strace $tracelevel | |
20 | } | |
21 | ||
22 | # | |
23 | # test running programs | |
24 | # | |
37fdf854 | 25 | |
93f02886 DJ |
26 | if {[skip_shlib_tests]} { |
27 | return 0 | |
28 | } | |
29 | ||
37fdf854 JJ |
30 | set testfile "unload" |
31 | set libfile "unloadshr" | |
859825b8 | 32 | set libfile2 "unloadshr2" |
255e7678 | 33 | set libname "${libfile}.sl" |
859825b8 | 34 | set libname2 "${libfile2}.sl" |
37fdf854 | 35 | set libsrcfile ${libfile}.c |
859825b8 | 36 | set libsrcfile2 ${libfile2}.c |
5ea106f7 PG |
37 | set srcfile $srcdir/$subdir/$testfile.c |
38 | set binfile $objdir/$subdir/$testfile | |
37fdf854 | 39 | set shlibdir ${objdir}/${subdir} |
5ea106f7 | 40 | set libsrc $srcdir/$subdir/$libfile.c |
859825b8 | 41 | set libsrc2 $srcdir/$subdir/$libfile2.c |
255e7678 | 42 | set lib_sl $objdir/$subdir/$libname |
859825b8 | 43 | set lib_sl2 $objdir/$subdir/$libname2 |
759f0f0b PA |
44 | set lib_dlopen [shlib_target_file ${libname}] |
45 | set lib_dlopen2 [shlib_target_file ${libname2}] | |
46 | set lib_syms [shlib_symbol_file ${libname}] | |
47 | set lib_syms2 [shlib_symbol_file ${libname2}] | |
37fdf854 | 48 | |
5ea106f7 PG |
49 | if [get_compiler_info ${binfile}] { |
50 | return -1 | |
37fdf854 JJ |
51 | } |
52 | ||
255e7678 | 53 | set lib_opts debug |
759f0f0b | 54 | set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2\=\"${lib_dlopen2}\"] |
255e7678 | 55 | |
5ea106f7 | 56 | if { [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 | |
65 | gdb_exit | |
66 | gdb_start | |
67 | gdb_reinitialize_dir $srcdir/$subdir | |
68 | gdb_load ${binfile} | |
859825b8 | 69 | gdb_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 |
76 | gdb_breakpoint "shrfunc1" allow-pending |
77 | gdb_breakpoint "shrfunc2" allow-pending | |
37fdf854 JJ |
78 | |
79 | gdb_test "info break" \ | |
859825b8 JK |
80 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? |
81 | 1\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r? | |
82 | 2\[\t \]+breakpoint keep y *<PENDING> *shrfunc2" \ | |
83 | "pending breakpoint info before run" | |
37fdf854 | 84 | |
0107feed | 85 | set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}] |
37fdf854 | 86 | |
b741e217 DJ |
87 | gdb_run_cmd |
88 | gdb_test "" \ | |
859825b8 | 89 | "Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \ |
37fdf854 JJ |
90 | "running program" |
91 | ||
859825b8 JK |
92 | gdb_test "info break" \ |
93 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? | |
94 | 1\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .* | |
95 | 2\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \ | |
96 | "pending breakpoint info on first run at shrfunc1" | |
97 | ||
98 | gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary | |
99 | ||
37fdf854 | 100 | gdb_test "continue" \ |
759f0f0b | 101 | "Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \ |
859825b8 JK |
102 | "continuing to unloaded libfile" |
103 | ||
104 | gdb_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 |
110 | gdb_run_cmd |
111 | gdb_test "" \ | |
859825b8 | 112 | "Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \ |
37fdf854 JJ |
113 | "rerun to shared library breakpoint" |
114 | ||
859825b8 JK |
115 | gdb_test "info break" \ |
116 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? | |
117 | 1\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .* | |
118 | 2\[\t \]+breakpoint keep y *<PENDING> *shrfunc2.*" \ | |
119 | "pending breakpoint info on second run at shrfunc1" | |
120 | ||
121 | gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary | |
122 | ||
123 | gdb_test "continue" \ | |
759f0f0b | 124 | "Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms}.*y-set-1.*" \ |
859825b8 JK |
125 | "continuing to unloaded libfile" |
126 | ||
127 | set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}] | |
128 | ||
129 | gdb_test "continue" \ | |
130 | "Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \ | |
131 | "continue to shrfunc2" | |
132 | ||
133 | gdb_test "info break" \ | |
134 | "Num Type\[ \]+Disp Enb Address\[ \]+What\r? | |
135 | 1\[\t \]+breakpoint keep y *<PENDING> *shrfunc1\r? | |
136 | \[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r? | |
137 | 2\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \ | |
138 | "pending breakpoint info on second run at shrfunc2" | |
139 | ||
140 | gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]" | |
141 | ||
37fdf854 | 142 | gdb_test "continue" \ |
759f0f0b | 143 | "Continuing.*warning: Temporarily disabling breakpoints for.*${lib_syms2}.*y-set-2.*" \ |
859825b8 | 144 | "continuing to unloaded libfile2" |
edd9b715 | 145 | |
859825b8 | 146 | gdb_test "print y" " = 200" "print y from libfile2" |