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