1 |
227 |
jeremybenn |
# Copyright 2003, 2004, 2005, 2007, 2008, 2009, 2010
|
2 |
|
|
# Free Software Foundation, Inc.
|
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
|
6 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
7 |
|
|
# (at your option) any later version.
|
8 |
|
|
#
|
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.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program. If not, see .
|
16 |
|
|
|
17 |
|
|
# This file was created by Jeff Johnston. (jjohnstn@redhat.com)
|
18 |
|
|
|
19 |
|
|
if $tracelevel then {
|
20 |
|
|
strace $tracelevel
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
#
|
24 |
|
|
# test running programs
|
25 |
|
|
#
|
26 |
|
|
set prms_id 0
|
27 |
|
|
set bug_id 0
|
28 |
|
|
|
29 |
|
|
if {[skip_shlib_tests]} {
|
30 |
|
|
return 0
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
# TODO: Use LoadLibrary on this target instead of dlopen.
|
34 |
|
|
if {[istarget arm*-*-symbianelf*]} {
|
35 |
|
|
return 0
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
set testfile "unload"
|
39 |
|
|
set libfile "unloadshr"
|
40 |
|
|
set libfile2 "unloadshr2"
|
41 |
|
|
set libname "${libfile}.sl"
|
42 |
|
|
set libname2 "${libfile2}.sl"
|
43 |
|
|
set libsrcfile ${libfile}.c
|
44 |
|
|
set libsrcfile2 ${libfile2}.c
|
45 |
|
|
set srcfile $srcdir/$subdir/$testfile.c
|
46 |
|
|
set binfile $objdir/$subdir/$testfile
|
47 |
|
|
set shlibdir ${objdir}/${subdir}
|
48 |
|
|
set libsrc $srcdir/$subdir/$libfile.c
|
49 |
|
|
set libsrc2 $srcdir/$subdir/$libfile2.c
|
50 |
|
|
set lib_sl $objdir/$subdir/$libname
|
51 |
|
|
set lib_sl2 $objdir/$subdir/$libname2
|
52 |
|
|
|
53 |
|
|
if [get_compiler_info ${binfile}] {
|
54 |
|
|
return -1
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
set lib_opts debug
|
58 |
|
|
set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${libname}\" additional_flags=-DSHLIB_NAME2\=\"${libname2}\"]
|
59 |
|
|
|
60 |
|
|
if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
|
61 |
|
|
|| [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
|
62 |
|
|
|| [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
|
63 |
|
|
untested "Couldn't compile $libsrc or $libsrc2 or $srcfile."
|
64 |
|
|
return -1
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
# Start with a fresh gdb.
|
68 |
|
|
|
69 |
|
|
gdb_exit
|
70 |
|
|
gdb_start
|
71 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
72 |
|
|
gdb_load ${binfile}
|
73 |
|
|
gdb_load_shlibs $lib_sl $lib_sl2
|
74 |
|
|
|
75 |
|
|
if [target_info exists gdb_stub] {
|
76 |
|
|
gdb_step_for_stub;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
#
|
80 |
|
|
# Test setting a breakpoint in a dynamically loaded library which is
|
81 |
|
|
# manually loaded and unloaded
|
82 |
|
|
#
|
83 |
|
|
|
84 |
|
|
gdb_breakpoint "shrfunc1" allow-pending
|
85 |
|
|
gdb_breakpoint "shrfunc2" allow-pending
|
86 |
|
|
|
87 |
|
|
gdb_test "info break" \
|
88 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What\r?
|
89 |
|
|
1\[\t \]+breakpoint keep y * *shrfunc1\r?
|
90 |
|
|
2\[\t \]+breakpoint keep y * *shrfunc2" \
|
91 |
|
|
"pending breakpoint info before run"
|
92 |
|
|
|
93 |
|
|
set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
|
94 |
|
|
|
95 |
|
|
gdb_run_cmd
|
96 |
|
|
gdb_test "" \
|
97 |
|
|
"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
|
98 |
|
|
"running program"
|
99 |
|
|
|
100 |
|
|
gdb_test "info break" \
|
101 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What\r?
|
102 |
|
|
1\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
|
103 |
|
|
2\[\t \]+breakpoint keep y * *shrfunc2.*" \
|
104 |
|
|
"pending breakpoint info on first run at shrfunc1"
|
105 |
|
|
|
106 |
|
|
gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
|
107 |
|
|
|
108 |
|
|
gdb_test "continue" \
|
109 |
|
|
"Continuing.*warning: Temporarily disabling breakpoints for.*${libname}.*y-set-1.*" \
|
110 |
|
|
"continuing to unloaded libfile"
|
111 |
|
|
|
112 |
|
|
gdb_test "print y" " = 10" "print y from libfile"
|
113 |
|
|
|
114 |
|
|
#
|
115 |
|
|
# Try to rerun program and verify that shared breakpoint is reset properly
|
116 |
|
|
#
|
117 |
|
|
|
118 |
|
|
gdb_run_cmd
|
119 |
|
|
gdb_test "" \
|
120 |
|
|
"Breakpoint 1, shrfunc1 \\\(x=1\\\).*${libsrcfile}:$unloadshr_line.*" \
|
121 |
|
|
"rerun to shared library breakpoint"
|
122 |
|
|
|
123 |
|
|
gdb_test "info break" \
|
124 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What\r?
|
125 |
|
|
1\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc1 at .*
|
126 |
|
|
2\[\t \]+breakpoint keep y * *shrfunc2.*" \
|
127 |
|
|
"pending breakpoint info on second run at shrfunc1"
|
128 |
|
|
|
129 |
|
|
gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-1" $testfile.c]" temporary
|
130 |
|
|
|
131 |
|
|
gdb_test "continue" \
|
132 |
|
|
"Continuing.*warning: Temporarily disabling breakpoints for.*${libname}.*y-set-1.*" \
|
133 |
|
|
"continuing to unloaded libfile"
|
134 |
|
|
|
135 |
|
|
set unloadshr_line2 [gdb_get_line_number "unloadshr2 break" ${libsrcfile2}]
|
136 |
|
|
|
137 |
|
|
gdb_test "continue" \
|
138 |
|
|
"Breakpoint 2, shrfunc2 \\\(x=2\\\).*${libsrcfile2}:$unloadshr_line2\r\n.*" \
|
139 |
|
|
"continue to shrfunc2"
|
140 |
|
|
|
141 |
|
|
gdb_test "info break" \
|
142 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What\r?
|
143 |
|
|
1\[\t \]+breakpoint keep y * *shrfunc1\r?
|
144 |
|
|
\[\t \]+breakpoint already hit \[0-9\]+ (time|times)\r?
|
145 |
|
|
2\[\t \]+breakpoint keep y *0x\[0-9a-f\]+ *in shrfunc2 at .*" \
|
146 |
|
|
"pending breakpoint info on second run at shrfunc2"
|
147 |
|
|
|
148 |
|
|
gdb_breakpoint "$testfile.c:[gdb_get_line_number "y-set-2" $testfile.c]"
|
149 |
|
|
|
150 |
|
|
gdb_test "continue" \
|
151 |
|
|
"Continuing.*warning: Temporarily disabling breakpoints for.*${libname2}.*y-set-2.*" \
|
152 |
|
|
"continuing to unloaded libfile2"
|
153 |
|
|
|
154 |
|
|
gdb_test "print y" " = 200" "print y from libfile2"
|