OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [foll-vfork.exp] - Blame information for rev 842

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
#   Copyright 1997, 1999, 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
if { [is_remote target] || ![isnative] } then {
18
    continue
19
}
20
 
21
set prms_id 0
22
set bug_id 0
23
 
24
# NOTE drow/2002-12-06: I don't know what the referenced kernel problem
25
# is, but it appears to be fixed in recent HP/UX versions.
26
 
27
##if [istarget "hppa2.0w-hp-hpux*"] {
28
##  warning "Don't run gdb.base/foll-vfork.exp until JAGaa43495 kernel problem is fixed."
29
##  return 0
30
##}
31
 
32
global srcfile
33
set testfile "foll-vfork"
34
set testfile2 "vforked-prog"
35
set srcfile ${testfile}.c
36
set srcfile2 ${testfile2}.c
37
set binfile ${objdir}/${subdir}/${testfile}
38
set binfile2 ${objdir}/${subdir}/${testfile2}
39
 
40
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
41
     untested foll-vfork.exp
42
     return -1
43
}
44
 
45
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
46
     untested foll-vfork.exp
47
     return -1
48
}
49
 
50
 
51
# Until "set follow-fork-mode" and "catch vfork" are implemented on
52
# other targets...
53
#
54
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
55
    continue
56
}
57
 
58
# Test to see if we are on an HP-UX 10.20 and if so,
59
# do not run these tests as catching vfork is disabled for
60
# 10.20.
61
 
62
if [istarget "hppa*-hp-hpux10.20"] then {
63
    return 0
64
}
65
 
66
# A few of these tests require a little more time than the standard
67
# timeout allows.
68
set oldtimeout $timeout
69
set timeout [expr "$timeout + 10"]
70
 
71
proc check_vfork_catchpoints {} {
72
  global gdb_prompt
73
  global has_vfork_catchpoints
74
 
75
  # Verify that the system supports "catch vfork".
76
  gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
77
  set has_vfork_catchpoints 0
78
  gdb_test_multiple "continue" "continue to first vfork catchpoint" {
79
    -re ".*Your system does not support vfork catchpoints.*$gdb_prompt $" {
80
      unsupported "continue to first vfork catchpoint"
81
    }
82
    -re ".*Catchpoint.*$gdb_prompt $" {
83
      set has_vfork_catchpoints 1
84
      pass "continue to first vfork catchpoint"
85
    }
86
  }
87
 
88
  if {$has_vfork_catchpoints == 0} {
89
    unsupported "vfork catchpoints"
90
    return -code return
91
  }
92
}
93
 
94
proc vfork_parent_follow_through_step {} {
95
   global gdb_prompt
96
 
97
   send_gdb "set follow-fork parent\n"
98
   gdb_expect {
99
      -re "$gdb_prompt $" {pass "set follow-fork parent, vfork through step"}
100
      timeout         {fail "set follow-fork parent, vfork through step"}
101
   }
102
   send_gdb "next\n"
103
   gdb_expect {
104
      -re "Detaching after fork from.*13.*$gdb_prompt "\
105
                      {pass "vfork parent follow, through step"}
106
      -re "$gdb_prompt $" {fail "vfork parent follow, through step"}
107
      timeout         {fail "(timeout) vfork parent follow, through step" }
108
   }
109
   # The child has been detached; allow time for any output it might
110
   # generate to arrive, so that output doesn't get confused with
111
   # any gdb_expected debugger output from a subsequent testpoint.
112
   #
113
   exec sleep 1
114
}
115
 
116
proc vfork_parent_follow_to_bp {} {
117
   global gdb_prompt
118
   global srcfile
119
 
120
   send_gdb "set follow-fork parent\n"
121
   gdb_expect {
122
      -re "$gdb_prompt $" {pass "set follow-fork parent, vfork to bp"}
123
      timeout         {fail "set follow-fork parent, vfork to bp"}
124
   }
125
   send_gdb "break ${srcfile}:18\n"
126
   gdb_expect {
127
      -re "$gdb_prompt $" {pass "break, vfork to bp"}
128
      timeout         {fail "break, vfork to bp"}
129
   }
130
   send_gdb "continue\n"
131
   gdb_expect {
132
      -re ".*Detaching after fork from child process.*Breakpoint.*18.*$gdb_prompt "\
133
                      {pass "vfork parent follow, to bp"}
134
      -re "$gdb_prompt $" {fail "vfork parent follow, to bp"}
135
      timeout         {fail "(timeout) vfork parent follow, to bp" }
136
   }
137
   # The child has been detached; allow time for any output it might
138
   # generate to arrive, so that output doesn't get confused with
139
   # any expected debugger output from a subsequent testpoint.
140
   #
141
   exec sleep 1
142
}
143
 
144
proc vfork_and_exec_child_follow_to_main_bp {} {
145
   global gdb_prompt
146
   global binfile
147
 
148
   send_gdb "set follow-fork child\n"
149
   gdb_expect {
150
      -re "$gdb_prompt $" {pass "set follow-fork child, vfork and exec to main bp"}
151
      timeout         {fail "set follow-fork child, vfork and exec to main bp"}
152
   }
153
   send_gdb "continue\n"
154
   gdb_expect {
155
      -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt "\
156
                      {pass "vfork and exec child follow, to main bp"}
157
      -re "$gdb_prompt $" {fail "vfork and exec child follow, to main bp"}
158
      timeout         {fail "(timeout) vfork and exec child follow, to main bp" }
159
   }
160
   # The parent has been detached; allow time for any output it might
161
   # generate to arrive, so that output doesn't get confused with
162
   # any gdb_expected debugger output from a subsequent testpoint.
163
   #
164
   exec sleep 1
165
 
166
   # Explicitly kill this child, or a subsequent rerun actually runs
167
   # the exec'd child, not the original program...
168
   send_gdb "kill\n"
169
   gdb_expect {
170
      -re ".*Kill the program being debugged.*y or n. $" {
171
         send_gdb "y\n"
172
         send_gdb "file $binfile\n"
173
         gdb_expect {
174
            -re ".*Load new symbol table from.*y or n. $" {
175
               send_gdb "y\n"
176
               gdb_expect {
177
                  -re "Reading symbols from.*$gdb_prompt $" {}
178
                  timeout { fail "loading symbols (timeout)"; return }
179
               }
180
            }
181
            -re ".*gdb_prompt $" {}
182
            timeout { fail "loading symbols (timeout)"; return }
183
          }
184
      }
185
      -re ".*$gdb_prompt $" {}
186
      timeout { fail "killing inferior (timeout)" ; return }
187
    }
188
}
189
 
190
proc vfork_and_exec_child_follow_through_step {} {
191
   global gdb_prompt
192
   global binfile
193
 
194
# This test cannot be performed prior to HP-UX 10.30, because ptrace-based
195
# debugging of a vforking program basically doesn't allow the child to do
196
# things like hit a breakpoint between a vfork and exec.  This means that
197
# saying "set follow-fork child; next" at a vfork() call won't work, because
198
# the implementation of "next" sets a "step resume" breakpoint at the
199
# return from the vfork(), which the child will hit on its way to exec'ing.
200
#
201
   if { ![istarget "hppa*-*-hpux11.*"] } {
202
      verbose "vfork child-following next test ignored for non-hppa or pre-HP/UX-10.30 targets."
203
      return 0
204
   }
205
 
206
   send_gdb "set follow-fork child\n"
207
   gdb_expect {
208
      -re "$gdb_prompt $" {pass "set follow-fork child, vfork and exec through step"}
209
      timeout         {fail "set follow-fork child, vfork and exec through step"}
210
   }
211
   send_gdb "next\n"
212
   gdb_expect {
213
      -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt "\
214
                      {pass "vfork and exec child follow, through step"}
215
      -re "$gdb_prompt $" {fail "vfork and exec child follow, through step"}
216
      timeout         {fail "(timeout) vfork and exec child follow, through step" }
217
   }
218
   # The parent has been detached; allow time for any output it might
219
   # generate to arrive, so that output doesn't get confused with
220
   # any expected debugger output from a subsequent testpoint.
221
   #
222
   exec sleep 1
223
 
224
   # Explicitly kill this child, or a subsequent rerun actually runs
225
   # the exec'd child, not the original program...
226
   send_gdb "kill\n"
227
   gdb_expect {
228
      -re ".*Kill the program being debugged.*y or n. $" {
229
         send_gdb "y\n"
230
         send_gdb "file $binfile\n"
231
         gdb_expect {
232
            -re ".*Load new symbol table from.*y or n. $" {
233
               send_gdb "y\n"
234
               gdb_expect {
235
                  -re "Reading symbols from.*$gdb_prompt $" {}
236
                  timeout { fail "loading symbols (timeout)"; return }
237
               }
238
            }
239
            -re ".*gdb_prompt $" {}
240
            timeout { fail "loading symbols (timeout)"; return }
241
          }
242
      }
243
      -re ".*$gdb_prompt $" {}
244
      timeout { fail "killing inferior (timeout)" ; return }
245
    }
246
}
247
 
248
proc tcatch_vfork_then_parent_follow {} {
249
   global gdb_prompt
250
   global srcfile
251
 
252
   send_gdb "set follow-fork parent\n"
253
   gdb_expect {
254
      -re "$gdb_prompt $" {pass "set follow-fork parent, tcatch vfork"}
255
      timeout         {fail "set follow-fork parent, tcatch vfork"}
256
   }
257
   send_gdb "tcatch vfork\n"
258
   gdb_expect {
259
      -re "Catchpoint .*(vfork).*$gdb_prompt $"\
260
                      {pass "vfork parent follow, set tcatch vfork"}
261
      -re "$gdb_prompt $" {fail "vfork parent follow, set tcatch vfork"}
262
      timeout         {fail "(timeout) vfork parent follow, set tcatch vfork"}
263
   }
264
   send_gdb "continue\n"
265
# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
266
# stop you in "_vfork".
267
   gdb_expect {
268
      -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt "\
269
                      {pass "vfork parent follow, tcatch vfork"}
270
      -re "vfork \\(\\) at.*$gdb_prompt "\
271
                      {pass "vfork parent follow, tcatch vfork"}
272
      -re "$gdb_prompt $" {fail "vfork parent follow, tcatch vfork"}
273
      timeout         {fail "(timeout) vfork parent follow, tcatch vfork"}
274
   }
275
   send_gdb "finish\n"
276
   gdb_expect {
277
      -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:12.*$gdb_prompt "\
278
                      {pass "vfork parent follow, finish after tcatch vfork"}
279
      -re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
280
          send_gdb "finish\n"
281
          exp_continue
282
      }
283
      -re "$gdb_prompt $" {fail "vfork parent follow, finish after tcatch vfork"}
284
      timeout         {fail "(timeout) vfork parent follow, finish after tcatch vfork" }
285
   }
286
   # The child has been detached; allow time for any output it might
287
   # generate to arrive, so that output doesn't get confused with
288
   # any expected debugger output from a subsequent testpoint.
289
   #
290
   exec sleep 1
291
}
292
 
293
proc tcatch_vfork_then_child_follow {} {
294
   global gdb_prompt
295
   global srcfile
296
   global srcfile2
297
 
298
   send_gdb "set follow-fork child\n"
299
   gdb_expect {
300
      -re "$gdb_prompt $" {pass "set follow-fork child, tcatch vfork"}
301
      timeout         {fail "set follow-fork child, tcatch vfork"}
302
   }
303
   send_gdb "tcatch vfork\n"
304
   gdb_expect {
305
      -re "Catchpoint .*(vfork).*$gdb_prompt $"\
306
                      {pass "vfork child follow, set tcatch vfork"}
307
      -re "$gdb_prompt $" {fail "vfork child follow, set tcatch vfork"}
308
      timeout         {fail "(timeout) vfork child follow, set tcatch vfork"}
309
   }
310
   send_gdb "continue\n"
311
# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
312
# stop you in "_vfork".
313
   gdb_expect {
314
      -re "vfork \\(\\) at .*$gdb_prompt $"\
315
                      {pass "vfork child follow, tcatch vfork"}
316
      -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt "\
317
                      {pass "vfork child follow, tcatch vfork"}
318
      -re "$gdb_prompt $" {fail "vfork child follow, tcatch vfork"}
319
      timeout         {fail "(timeout) vfork child follow, tcatch vfork"}
320
   }
321
   send_gdb "finish\n"
322
   gdb_expect {
323
      -re "Run till exit from.*vfork.*${srcfile}:12.*$gdb_prompt "\
324
                      {pass "vfork child follow, finish after tcatch vfork"}
325
      -re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
326
          send_gdb "finish\n"
327
          exp_continue
328
      }
329
      -re "Run till exit from.*vfork.*${srcfile2}:9.*$gdb_prompt "\
330
                      {pass "vfork child follow, finish after tcatch vfork (followed exec)"}
331
      -re "$gdb_prompt $" {fail "vfork child follow, finish after tcatch vfork"}
332
      timeout         {fail "(timeout) vfork child follow, finish after tcatch vfork" }
333
   }
334
   # The parent has been detached; allow time for any output it might
335
   # generate to arrive, so that output doesn't get confused with
336
   # any expected debugger output from a subsequent testpoint.
337
   #
338
   exec sleep 1
339
}
340
 
341
proc do_vfork_and_exec_tests {} {
342
   global gdb_prompt
343
 
344
   # Check that vfork catchpoints are supported, as an indicator for whether
345
   # vfork-following is supported.
346
   if [runto_main] then { check_vfork_catchpoints }
347
 
348
   # Try following the parent process by stepping through a call to
349
   # vfork.  Do this without catchpoints.
350
   if [runto_main] then { vfork_parent_follow_through_step }
351
 
352
   # Try following the parent process by setting a breakpoint on the
353
   # other side of a vfork, and running to that point.  Do this
354
   # without catchpoints.
355
   if [runto_main] then { vfork_parent_follow_to_bp }
356
 
357
   # Try following the child process by just continuing through the
358
   # vfork, and letting the parent's breakpoint on "main" be auto-
359
   # magically reset in the child.
360
   #
361
   if [runto_main] then { vfork_and_exec_child_follow_to_main_bp }
362
 
363
   # Try following the child process by stepping through a call to
364
   # vfork.  The child also executes an exec.  Since the child cannot
365
   # be debugged until after it has exec'd, and since there's a bp on
366
   # "main" in the parent, and since the bp's for the parent are
367
   # recomputed in the exec'd child, the step through a vfork should
368
   # land us in the "main" for the exec'd child, too.
369
   #
370
   if [runto_main] then { vfork_and_exec_child_follow_through_step }
371
 
372
   # Try catching a vfork, and stepping out to the parent.
373
   #
374
   if [runto_main] then { tcatch_vfork_then_parent_follow }
375
 
376
   # Try catching a vfork, and stepping out to the child.
377
   #
378
   if [runto_main] then { tcatch_vfork_then_child_follow }
379
 
380
   # Test the ability to follow both child and parent of a vfork.  Do
381
   # this without catchpoints.
382
   # ??rehrauer: NYI.  Will add testpoints here when implemented.
383
   #
384
 
385
   # Test the ability to have the debugger ask the user at vfork-time
386
   # whether to follow the parent, child or both.  Do this without
387
   # catchpoints.
388
   # ??rehrauer: NYI.  Will add testpoints here when implemented.
389
   #
390
}
391
 
392
# Start with a fresh gdb
393
 
394
gdb_exit
395
gdb_start
396
gdb_reinitialize_dir $srcdir/$subdir
397
gdb_load ${binfile}
398
 
399
# The "Detaching..." and "Attaching..." messages may be hidden by
400
# default.
401
gdb_test "set verbose" ""
402
 
403
# This is a test of gdb's ability to follow the parent or child
404
# of a Unix vfork() system call.  (The child will subsequently
405
# call a variant of a Unix exec() system call.)
406
#
407
do_vfork_and_exec_tests
408
 
409
set timeout $oldtimeout
410
return 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.