]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - gdb/patches/gdb-6.3-inferior-notification-20050721.patch
Merge remote-tracking branch 'stevee/pcre'
[people/ms/ipfire-3.x.git] / gdb / patches / gdb-6.3-inferior-notification-20050721.patch
1 2005-07-21 Jeff Johnston <jjohnstn@redhat.com>
2
3 * gdb.base/attach-32.exp: New test for attaching in 32-bit
4 mode on 64-bit systems.
5 * gdb.base/attach-32.c: Ditto.
6 * gdb.base/attach-32b.c: Ditto.
7
8 2007-12-26 Jan Kratochvil <jan.kratochvil@redhat.com>
9
10 * gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set.
11
12 Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c
13 ===================================================================
14 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
15 +++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.c 2011-03-20 20:15:57.000000000 +0100
16 @@ -0,0 +1,20 @@
17 +/* This program is intended to be started outside of gdb, and then
18 + attached to by gdb. Thus, it simply spins in a loop. The loop
19 + is exited when & if the variable 'should_exit' is non-zero. (It
20 + is initialized to zero in this program, so the loop will never
21 + exit unless/until gdb sets the variable to non-zero.)
22 + */
23 +#include <stdio.h>
24 +
25 +int should_exit = 0;
26 +
27 +int main ()
28 +{
29 + int local_i = 0;
30 +
31 + while (! should_exit)
32 + {
33 + local_i++;
34 + }
35 + return 0;
36 +}
37 Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp
38 ===================================================================
39 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
40 +++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32.exp 2011-03-20 20:20:03.000000000 +0100
41 @@ -0,0 +1,245 @@
42 +# Copyright 2005 Free Software Foundation, Inc.
43 +
44 +# This program is free software; you can redistribute it and/or modify
45 +# it under the terms of the GNU General Public License as published by
46 +# the Free Software Foundation; either version 2 of the License, or
47 +# (at your option) any later version.
48 +#
49 +# This program is distributed in the hope that it will be useful,
50 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
51 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52 +# GNU General Public License for more details.
53 +#
54 +# You should have received a copy of the GNU General Public License
55 +# along with this program; if not, write to the Free Software
56 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
57 +#
58 +# This test was based on attach.exp and modified for 32/64 bit Linux systems. */
59 +
60 +# On HP-UX 11.0, this test is causing a process running the program
61 +# "attach" to be left around spinning. Until we figure out why, I am
62 +# commenting out the test to avoid polluting tiamat (our 11.0 nightly
63 +# test machine) with these processes. RT
64 +#
65 +# Setting the magic bit in the target app should work. I added a
66 +# "kill", and also a test for the R3 register warning. JB
67 +if { ![istarget "x86_64*-*linux*"]
68 + && ![istarget "powerpc64*-*linux*"]} {
69 + return 0
70 +}
71 +
72 +# are we on a target board
73 +if [is_remote target] then {
74 + return 0
75 +}
76 +
77 +set testfile "attach-32"
78 +set srcfile ${testfile}.c
79 +set srcfile2 ${testfile}b.c
80 +set binfile ${objdir}/${subdir}/${testfile}
81 +set binfile2 ${objdir}/${subdir}/${testfile}b
82 +set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
83 +
84 +#execute_anywhere "rm -f ${binfile} ${binfile2}"
85 +remote_exec build "rm -f ${binfile} ${binfile2}"
86 +# For debugging this test
87 +#
88 +#log_user 1
89 +
90 +# build the first test case
91 +#
92 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
93 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
94 +}
95 +
96 +# Build the in-system-call test
97 +
98 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable [list debug "additional_flags=-m32"]] != "" } {
99 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
100 +}
101 +
102 +if [get_compiler_info ${binfile}] {
103 + return -1
104 +}
105 +
106 +proc do_attach_tests {} {
107 + global gdb_prompt
108 + global binfile
109 + global escapedbinfile
110 + global srcfile
111 + global testfile
112 + global objdir
113 + global subdir
114 + global timeout
115 + global testpid
116 +
117 + # Verify that we can "see" the variable "should_exit" in the
118 + # program, and that it is zero.
119 +
120 + gdb_test "print should_exit" " = 0" "after attach-32, print should_exit"
121 +
122 + # Verify that we can modify the variable "should_exit" in the
123 + # program.
124 +
125 + gdb_test "set should_exit=1" "" "after attach-32, set should_exit"
126 +
127 + # Verify that the modification really happened.
128 +
129 + send_gdb "tbreak 19\n"
130 + gdb_expect {
131 + -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $" {
132 + pass "after attach-32, set tbreak postloop"
133 + }
134 + -re "$gdb_prompt $" {
135 + fail "after attach-32, set tbreak postloop"
136 + }
137 + timeout {
138 + fail "(timeout) after attach-32, set tbreak postloop"
139 + }
140 + }
141 + send_gdb "continue\n"
142 + gdb_expect {
143 + -re "main.*at.*$srcfile:19.*$gdb_prompt $" {
144 + pass "after attach-32, reach tbreak postloop"
145 + }
146 + -re "$gdb_prompt $" {
147 + fail "after attach-32, reach tbreak postloop"
148 + }
149 + timeout {
150 + fail "(timeout) after attach-32, reach tbreak postloop"
151 + }
152 + }
153 +
154 + # Allow the test process to exit, to cleanup after ourselves.
155 +
156 + gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, exit"
157 +
158 + # Make sure we don't leave a process around to confuse
159 + # the next test run (and prevent the compile by keeping
160 + # the text file busy), in case the "set should_exit" didn't
161 + # work.
162 +
163 + remote_exec build "kill -9 ${testpid}"
164 +
165 + # Start the program running and then wait for a bit, to be sure
166 + # that it can be attached to.
167 +
168 + set testpid [eval exec $binfile &]
169 + exec sleep 2
170 + if { [istarget "*-*-cygwin*"] } {
171 + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
172 + # different due to the way fork/exec works.
173 + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
174 + }
175 +
176 + # Verify that we can attach to the process, and find its a.out
177 + # when we're cd'd to some directory that doesn't contain the
178 + # a.out. (We use the source path set by the "dir" command.)
179 +
180 + gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \
181 + "set source path"
182 +
183 + gdb_test "cd /tmp" "Working directory /tmp." \
184 + "cd away from process working directory"
185 +
186 + # Explicitly flush out any knowledge of the previous attachment.
187 +
188 + set test "before attach-32-3, flush symbols"
189 + gdb_test_multiple "symbol" "$test" {
190 + -re "Discard symbol table from.*y or n. $" {
191 + gdb_test "y" "No symbol file now." \
192 + "$test"
193 + }
194 + -re "No symbol file now.*$gdb_prompt $" {
195 + pass "$test"
196 + }
197 + }
198 +
199 + gdb_test "exec" "No executable file now." \
200 + "before attach-32-3, flush exec"
201 +
202 + gdb_test "attach $testpid" \
203 + "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \
204 + "attach-32 when process' a.out not in cwd"
205 +
206 + set test "after attach-32-3, exit"
207 + gdb_test_multiple "kill" "$test" {
208 + -re "Kill the program being debugged.*y or n. $" {
209 + gdb_test "y" "" "$test"
210 + }
211 + }
212 +
213 + # Another "don't leave a process around"
214 + remote_exec build "kill -9 ${testpid}"
215 +}
216 +
217 +proc do_call_attach_tests {} {
218 + global gdb_prompt
219 + global binfile2
220 + global testpid
221 +
222 + # See if other registers are problems
223 +
224 + set test "info other register"
225 + gdb_test_multiple "i r r3" "$test" {
226 + -re "warning: reading register.*$gdb_prompt $" {
227 + fail "$test"
228 + }
229 + -re "r3.*$gdb_prompt $" {
230 + pass "$test"
231 + }
232 + }
233 +
234 + # Get rid of the process
235 +
236 + gdb_test "p should_exit = 1"
237 + gdb_test "c" {\[Inferior .* exited normally\]}
238 +
239 + # Be paranoid
240 +
241 + remote_exec build "kill -9 ${testpid}"
242 +}
243 +
244 +
245 +# Start with a fresh gdb
246 +
247 +gdb_exit
248 +set testpid [eval exec $binfile &]
249 +exec sleep 3
250 +if { [istarget "*-*-cygwin*"] } {
251 + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
252 + # different due to the way fork/exec works.
253 + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
254 +}
255 +
256 +set GDBFLAGS_orig $GDBFLAGS
257 +set GDBFLAGS "--pid=$testpid"
258 +gdb_start
259 +set GDBFLAGS $GDBFLAGS_orig
260 +
261 +gdb_reinitialize_dir $srcdir/$subdir
262 +
263 +# This is a test of gdb's ability to attach to a running process.
264 +
265 +do_attach_tests
266 +
267 +# Test attaching when the target is inside a system call
268 +
269 +gdb_exit
270 +set testpid [eval exec $binfile2 &]
271 +exec sleep 3
272 +if { [istarget "*-*-cygwin*"] } {
273 + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
274 + # different due to the way fork/exec works.
275 + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
276 +}
277 +
278 +set GDBFLAGS_orig $GDBFLAGS
279 +set GDBFLAGS "--pid=$testpid"
280 +gdb_start
281 +set GDBFLAGS $GDBFLAGS_orig
282 +
283 +gdb_reinitialize_dir $srcdir/$subdir
284 +do_call_attach_tests
285 +
286 +return 0
287 Index: gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c
288 ===================================================================
289 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
290 +++ gdb-7.2.50.20110320/gdb/testsuite/gdb.base/attach-32b.c 2011-03-20 20:15:57.000000000 +0100
291 @@ -0,0 +1,24 @@
292 +/* This program is intended to be started outside of gdb, and then
293 + attached to by gdb. Thus, it simply spins in a loop. The loop
294 + is exited when & if the variable 'should_exit' is non-zero. (It
295 + is initialized to zero in this program, so the loop will never
296 + exit unless/until gdb sets the variable to non-zero.)
297 + */
298 +#include <stdio.h>
299 +#include <stdlib.h>
300 +#include <unistd.h>
301 +
302 +int should_exit = 0;
303 +
304 +int main ()
305 +{
306 + int local_i = 0;
307 +
308 + sleep( 10 ); /* System call causes register fetch to fail */
309 + /* This is a known HPUX "feature" */
310 + while (! should_exit)
311 + {
312 + local_i++;
313 + }
314 + return (0);
315 +}