]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.3-inferior-notification-20050721.patch
- NOTE: does not build with -j2
[packages/gdb.git] / 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-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.c
13 ===================================================================
14 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
15 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.c      2008-12-07 10:06:03.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-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp
38 ===================================================================
39 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
40 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32.exp    2008-12-07 10:08:52.000000000 +0100
41 @@ -0,0 +1,252 @@
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 +if $tracelevel then {
61 +    strace $tracelevel
62 +}
63 +
64 +set prms_id 0
65 +set bug_id 0
66 +
67 +# On HP-UX 11.0, this test is causing a process running the program
68 +# "attach" to be left around spinning.  Until we figure out why, I am
69 +# commenting out the test to avoid polluting tiamat (our 11.0 nightly
70 +# test machine) with these processes. RT
71 +#
72 +# Setting the magic bit in the target app should work.  I added a
73 +# "kill", and also a test for the R3 register warning.  JB
74 +if { ![istarget "x86_64*-*linux*"] 
75 +     && ![istarget "powerpc64*-*linux*"]} {
76 +    return 0
77 +}
78 +
79 +# are we on a target board
80 +if [is_remote target] then {
81 +    return 0
82 +}
83 +
84 +set testfile "attach-32"
85 +set srcfile  ${testfile}.c
86 +set srcfile2 ${testfile}b.c
87 +set binfile  ${objdir}/${subdir}/${testfile}
88 +set binfile2 ${objdir}/${subdir}/${testfile}b
89 +set escapedbinfile  [string_to_regexp ${objdir}/${subdir}/${testfile}]
90 +
91 +#execute_anywhere "rm -f ${binfile} ${binfile2}"
92 +remote_exec build "rm -f ${binfile} ${binfile2}"
93 +# For debugging this test
94 +#
95 +#log_user 1
96 +
97 +# build the first test case
98 +#
99 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
100 +    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
101 +}
102 +
103 +# Build the in-system-call test
104 +
105 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable [list debug "additional_flags=-m32"]] != "" } {
106 +    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
107 +}
108 +
109 +if [get_compiler_info ${binfile}] {
110 +    return -1
111 +}
112 +
113 +proc do_attach_tests {} {
114 +    global gdb_prompt
115 +    global binfile
116 +    global escapedbinfile
117 +    global srcfile
118 +    global testfile
119 +    global objdir
120 +    global subdir
121 +    global timeout
122 +    global testpid
123 +    
124 +    # Verify that we can "see" the variable "should_exit" in the
125 +    # program, and that it is zero.
126 +   
127 +    gdb_test "print should_exit" " = 0" "after attach-32, print should_exit"
128 +
129 +    # Verify that we can modify the variable "should_exit" in the
130 +    # program.
131 +
132 +    gdb_test "set should_exit=1" "" "after attach-32, set should_exit"
133 +
134 +    # Verify that the modification really happened.
135 +
136 +    send_gdb "tbreak 19\n"
137 +    gdb_expect {
138 +       -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $" {
139 +           pass "after attach-32, set tbreak postloop"
140 +       }
141 +       -re "$gdb_prompt $" {
142 +           fail "after attach-32, set tbreak postloop"
143 +       }
144 +       timeout {
145 +           fail "(timeout) after attach-32, set tbreak postloop"
146 +       }
147 +    }
148 +    send_gdb "continue\n"
149 +    gdb_expect {
150 +       -re "main.*at.*$srcfile:19.*$gdb_prompt $" {
151 +           pass "after attach-32, reach tbreak postloop"
152 +       }
153 +       -re "$gdb_prompt $" {
154 +           fail "after attach-32, reach tbreak postloop"
155 +       }
156 +       timeout {
157 +           fail "(timeout) after attach-32, reach tbreak postloop"
158 +       }
159 +    }
160 +
161 +    # Allow the test process to exit, to cleanup after ourselves.
162 +
163 +    gdb_test "continue" "Program exited normally." "after attach-32, exit"
164 +
165 +    # Make sure we don't leave a process around to confuse
166 +    # the next test run (and prevent the compile by keeping
167 +    # the text file busy), in case the "set should_exit" didn't
168 +    # work.
169 +   
170 +    remote_exec build "kill -9 ${testpid}"
171 +
172 +    # Start the program running and then wait for a bit, to be sure
173 +    # that it can be attached to.
174 +   
175 +    set testpid [eval exec $binfile &]
176 +    exec sleep 2
177 +    if { [istarget "*-*-cygwin*"] } {
178 +       # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
179 +       # different due to the way fork/exec works.
180 +       set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
181 +    }
182 +
183 +    # Verify that we can attach to the process, and find its a.out
184 +    # when we're cd'd to some directory that doesn't contain the
185 +    # a.out.  (We use the source path set by the "dir" command.)
186 +    
187 +    gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \
188 +       "set source path"
189 +
190 +    gdb_test "cd /tmp" "Working directory /tmp." \
191 +       "cd away from process working directory"
192 +
193 +    # Explicitly flush out any knowledge of the previous attachment.
194 +
195 +    set test "before attach-32-3, flush symbols"
196 +    gdb_test_multiple "symbol" "$test" {
197 +       -re "Discard symbol table from.*y or n. $" {
198 +           gdb_test "y" "No symbol file now." \
199 +               "$test"
200 +       }
201 +       -re "No symbol file now.*$gdb_prompt $" {
202 +           pass "$test"
203 +       }
204 +    }
205 +
206 +    gdb_test "exec" "No executable file now." \
207 +       "before attach-32-3, flush exec"
208 +
209 +    gdb_test "attach $testpid" \
210 +       "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \
211 +       "attach-32 when process' a.out not in cwd"
212 +
213 +    set test "after attach-32-3, exit"
214 +    gdb_test_multiple "kill" "$test" {
215 +       -re "Kill the program being debugged.*y or n. $" {
216 +           gdb_test "y" "" "$test"
217 +       }
218 +    }
219 +    
220 +    # Another "don't leave a process around"
221 +    remote_exec build "kill -9 ${testpid}"
222 +}
223 +
224 +proc do_call_attach_tests {} {
225 +    global gdb_prompt
226 +    global binfile2
227 +    global testpid
228 +    
229 +    # See if other registers are problems
230 +    
231 +    set test "info other register"
232 +    gdb_test_multiple "i r r3" "$test" {
233 +       -re "warning: reading register.*$gdb_prompt $" {
234 +           fail "$test"
235 +       }
236 +       -re "r3.*$gdb_prompt $" {
237 +           pass "$test"
238 +       }
239 +    }
240 +
241 +    # Get rid of the process
242 +    
243 +    gdb_test "p should_exit = 1"
244 +    gdb_test "c" "Program exited normally."
245 +   
246 +    # Be paranoid
247 +   
248 +    remote_exec build "kill -9 ${testpid}"
249 +}
250 +
251 +
252 +# Start with a fresh gdb
253 +
254 +gdb_exit
255 +set testpid [eval exec $binfile &]
256 +exec sleep 3
257 +if { [istarget "*-*-cygwin*"] } {
258 +    # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
259 +    # different due to the way fork/exec works.
260 +    set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
261 +}
262 +
263 +set GDBFLAGS_orig $GDBFLAGS
264 +set GDBFLAGS "--pid=$testpid"
265 +gdb_start
266 +set GDBFLAGS $GDBFLAGS_orig
267 +
268 +gdb_reinitialize_dir $srcdir/$subdir
269 +
270 +# This is a test of gdb's ability to attach to a running process.
271 +
272 +do_attach_tests
273 +
274 +# Test attaching when the target is inside a system call
275 +
276 +gdb_exit
277 +set testpid [eval exec $binfile2 &]
278 +exec sleep 3
279 +if { [istarget "*-*-cygwin*"] } {
280 +    # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
281 +    # different due to the way fork/exec works.
282 +    set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
283 +}
284 +
285 +set GDBFLAGS_orig $GDBFLAGS
286 +set GDBFLAGS "--pid=$testpid"
287 +gdb_start
288 +set GDBFLAGS $GDBFLAGS_orig
289 +
290 +gdb_reinitialize_dir $srcdir/$subdir
291 +do_call_attach_tests
292 +
293 +return 0
294 Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32b.c
295 ===================================================================
296 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
297 +++ gdb-6.8.50.20081128/gdb/testsuite/gdb.base/attach-32b.c     2008-12-07 10:06:03.000000000 +0100
298 @@ -0,0 +1,24 @@
299 +/* This program is intended to be started outside of gdb, and then
300 +   attached to by gdb.  Thus, it simply spins in a loop.  The loop
301 +   is exited when & if the variable 'should_exit' is non-zero.  (It
302 +   is initialized to zero in this program, so the loop will never
303 +   exit unless/until gdb sets the variable to non-zero.)
304 +   */
305 +#include <stdio.h>
306 +#include <stdlib.h>
307 +#include <unistd.h>
308 +
309 +int  should_exit = 0;
310 +
311 +int main ()
312 +{
313 +  int  local_i = 0;
314 +
315 +  sleep( 10 ); /* System call causes register fetch to fail */
316 +               /* This is a known HPUX "feature"            */
317 +  while (! should_exit)
318 +    {
319 +      local_i++;
320 +    }
321 +  return (0);
322 +}
This page took 0.047548 seconds and 3 git commands to generate.