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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [foll-vfork.exp] - Blame information for rev 25

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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