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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [foll-exec.exp] - Blame information for rev 321

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
#   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
set testfile "foll-exec"
24
set testfile2 "execd-prog"
25
set srcfile ${testfile}.c
26
set srcfile2 ${testfile2}.c
27
set binfile ${objdir}/${subdir}/${testfile}
28
set binfile2 ${objdir}/${subdir}/${testfile2}
29
 
30
# build the first test case
31
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
32
     untested foll-exec.exp
33
     return -1
34
}
35
 
36
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37
     untested foll-exec.exp
38
     return -1
39
}
40
 
41
 
42
# Until "catch exec" is implemented on other targets...
43
#
44
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
45
    continue
46
}
47
 
48
proc zap_session {} {
49
   global gdb_prompt
50
   global binfile
51
 
52
   send_gdb "kill\n"
53
   gdb_expect {
54
     -re ".*Kill the program being debugged.*y or n. $" {
55
       send_gdb "y\n"
56
       send_gdb "file $binfile\n"
57
       gdb_expect {
58
         -re ".*Load new symbol table from.*y or n. $" {
59
           send_gdb "y\n"
60
           gdb_expect {
61
             -re "Reading symbols from.*$gdb_prompt $" {}
62
             timeout { fail "loading symbols (timeout)"; return }
63
           }
64
         }
65
         -re ".*gdb_prompt $" {}
66
         timeout { fail "loading symbols (timeout)"; return }
67
       }
68
    }
69
    -re ".*$gdb_prompt $" {}
70
    timeout { fail "killing inferior (timeout)" ; return }
71
   }
72
}
73
 
74
proc do_exec_tests {} {
75
   global gdb_prompt
76
   global binfile
77
   global srcfile
78
   global srcfile2
79
   global testfile
80
   global testfile2
81
 
82
   # Start the program running, and stop at main.
83
   #
84
   if ![runto_main] then {
85
     perror "Couldn't run ${testfile}"
86
     return
87
   }
88
 
89
   # Verify that the system supports "catch exec".
90
   gdb_test "catch exec" "Catchpoint \[0-9\]* \\(exec\\)" "insert first exec catchpoint"
91
   set has_exec_catchpoints 0
92
   gdb_test_multiple "continue" "continue to first exec catchpoint" {
93
     -re ".*Your system does not support exec catchpoints.*$gdb_prompt $" {
94
       unsupported "continue to first exec catchpoint"
95
     }
96
     -re ".*Catchpoint.*$gdb_prompt $" {
97
       set has_exec_catchpoints 1
98
       pass "continue to first exec catchpoint"
99
     }
100
   }
101
 
102
   if {$has_exec_catchpoints == 0} {
103
     unsupported "exec catchpoints"
104
     return
105
   }
106
 
107
   zap_session
108
 
109
   # Start the program running, and stop at main.
110
   #
111
   if ![runto_main] then {
112
     perror "Couldn't run ${testfile}"
113
     return
114
   }
115
 
116
   # Verify that we can see various global and local variables
117
   # in this program, and that they have expected values.  Some
118
   # of these variables are also declared in the program we'll
119
   # exec in a moment.
120
   #
121
   send_gdb "next 3\n"
122
   gdb_expect {
123
     -re "20.*execlp.*$gdb_prompt $"\
124
                     {pass "step to exec call"}
125
     -re "$gdb_prompt $" {fail "step to exec call"}
126
     timeout         {fail "(timeout) step to exec call"}
127
   }
128
   send_gdb "print global_i\n"
129
   gdb_expect {
130
     -re ".* = 100.*$gdb_prompt $"\
131
                     {pass "print follow-exec/global_i"}
132
     -re "$gdb_prompt $" {fail "print follow-exec/global_i"}
133
     timeout         {fail "(timeout) print follow-exec/global_i"}
134
   }
135
   send_gdb "print local_j\n"
136
   gdb_expect {
137
     -re ".* = 101.*$gdb_prompt $"\
138
                     {pass "print follow-exec/local_j"}
139
     -re "$gdb_prompt $" {fail "print follow-exec/local_j"}
140
     timeout         {fail "(timeout) print follow-exec/local_j"}
141
   }
142
   send_gdb "print local_k\n"
143
   gdb_expect {
144
     -re ".* = 102.*$gdb_prompt $"\
145
                     {pass "print follow-exec/local_k"}
146
     -re "$gdb_prompt $" {fail "print follow-exec/local_k"}
147
     timeout         {fail "(timeout) print follow-exec/local_k"}
148
   }
149
 
150
   # Try stepping through an execlp call, without catching it.
151
   # We should stop in execd-program, at its first statement.
152
   #
153
   send_gdb "next\n"
154
   gdb_expect {
155
     -re "Executing new program: .*${testfile2}.*${srcfile2}:23.*int  local_j = argc;.*$gdb_prompt $"\
156
                     {pass "step through execlp call"}
157
     -re "$gdb_prompt $" {fail "step through execlp call"}
158
     timeout         {fail "(timeout) step through execlp call"}
159
   }
160
 
161
   # Verify that we can see the variables defined in the newly-exec'd
162
   # program, and CANNOT see those defined in the exec'ing program.
163
   #
164
   send_gdb "next\n"
165
   gdb_expect {
166
     -re "26.*printf.*$gdb_prompt $"\
167
                     {pass "step after execlp call"}
168
     -re "$gdb_prompt $" {fail "step after execlp call"}
169
     timeout         {fail "(timeout) step after execlp call"}
170
   }
171
   send_gdb "print global_i\n"
172
   gdb_expect {
173
     -re ".* = 0.*$gdb_prompt $"\
174
                     {pass "print execd-program/global_i (after execlp)"}
175
     -re "$gdb_prompt $" {fail "print execd-program/global_i (after execlp)"}
176
     timeout         {fail "(timeout) print execd-program/global_i (after execlp)"}
177
   }
178
   send_gdb "print local_j\n"
179
   gdb_expect {
180
     -re ".* = 2.*$gdb_prompt $"\
181
                     {pass "print execd-program/local_j (after execlp)"}
182
     -re "$gdb_prompt $" {fail "print execd-program/local_j (after execlp)"}
183
     timeout         {fail "(timeout) print execd-program/local_j (after execlp)"}
184
   }
185
   send_gdb "print local_k\n"
186
   gdb_expect {
187
     -re "No symbol \"local_k\" in current context.*$gdb_prompt $"\
188
                     {pass "print follow-exec/local_k (after execlp)"}
189
     -re "$gdb_prompt $" {fail "print follow-exec/local_k (after execlp)"}
190
     timeout         {fail "(timeout) print follow-exec/local_k (after execlp)"}
191
   }
192
 
193
   # Explicitly kill this program, or a subsequent rerun actually runs
194
   # the exec'd program, not the original program...
195
   zap_session
196
 
197
   # Start the program running, and stop at main.
198
   #
199
   if ![runto_main] then {
200
     perror "Couldn't run ${testfile} (2nd try)"
201
     return
202
   }
203
 
204
   # Verify that we can catch an exec event, and then continue
205
   # to follow through the exec.  (Since there's a breakpoint on
206
   # "main", it'll also be transferred to the exec'd program,
207
   # and we expect to stop there.)
208
   #
209
   send_gdb "catch exec\n"
210
   gdb_expect {
211
     -re "Catchpoint .*(exec).*$gdb_prompt $"\
212
                     {pass "set catch exec"}
213
     -re "$gdb_prompt $" {fail "set catch exec"}
214
     timeout         {fail "(timeout) set catch exec"}
215
   }
216
 
217
   # Verify that the catchpoint is mentioned in an "info breakpoints",
218
   # and further that the catchpoint mentions no program name.
219
   #
220
   send_gdb "info breakpoints\n"
221
   gdb_expect {
222
     -re ".*catch exec.*keep y.*$gdb_prompt $"\
223
                     {pass "info shows catchpoint without exec pathname"}
224
     -re ".*catch exec.*program \"\".*$gdb_prompt $"\
225
                     {fail "info shows catchpoint without exec pathname"}
226
     -re "$gdb_prompt $" {fail "info shows catchpoint without exec pathname"}
227
     timeout         {fail "(timeout) info shows catchpoint without exec pathname"}
228
   }
229
 
230
   # DTS CLLbs16760
231
   # PA64 doesn't know about $START$ in dld.sl at this point.  It should.
232
   # - Michael Coulter
233
   setup_xfail hppa2.0w-hp-hpux* CLLbs16760
234
   send_gdb "continue\n"
235
   gdb_expect {
236
     -re ".*Executing new program:.*${testfile2}.*Catchpoint .*(exec\'d .*${testfile2}).*in .*$gdb_prompt $"\
237
                     {pass "hit catch exec"}
238
     -re "$gdb_prompt $" {fail "hit catch exec"}
239
     timeout         {fail "(timeout) hit catch exec"}
240
   }
241
 
242
   # DTS CLLbs16760
243
   # test gets out of sync if previous test fails.
244
   gdb_test "bt" ".*" "sync up after possible failure 1"
245
   gdb_test "bt" "#0.*" "sync up after possible failure 2"
246
 
247
   # Verify that the catchpoint is mentioned in an "info breakpoints",
248
   # and further that the catchpoint managed to capture the exec'd
249
   # program's name.
250
   #
251
   send_gdb "info breakpoints\n"
252
   gdb_expect {
253
     -re ".*catch exec .*program \".*${testfile2}\".*$gdb_prompt $"\
254
                     {pass "info shows catchpoint exec pathname"}
255
     -re "$gdb_prompt $" {fail "info shows catchpoint exec pathname"}
256
     timeout         {fail "(timeout) info shows catchpoint exec pathname"}
257
   }
258
 
259
   # Verify that we can continue from the catchpoint, and land in the
260
   # main of the newly-exec'd program.
261
   #
262
   send_gdb "continue\n"
263
   gdb_expect {
264
     -re ".*${srcfile2}:23.*$gdb_prompt $"\
265
                     {pass "continue after hit catch exec"}
266
     -re "$gdb_prompt $" {fail "continue after hit catch exec"}
267
     timeout         {fail "(timeout) continue after hit catch exec"}
268
   }
269
 
270
   # Explicitly kill this program, or a subsequent rerun actually runs
271
   # the exec'd program, not the original program...
272
   zap_session
273
 
274
   # Start the program running, and stop at main.
275
   #
276
   if ![runto_main] then {
277
     perror "Couldn't run ${testfile} (3rd try)"
278
     return
279
   }
280
 
281
   # Verify that we can follow through follow an execl()
282
   # call.  (We must jump around earlier exec* calls.)
283
   #
284
   send_gdb "tbreak 27\n"
285
   gdb_expect {
286
     -re "Breakpoint .*file .*${srcfile}, line 27.*$gdb_prompt $"\
287
                     {pass "prepare to jump to execl call"}
288
     -re "$gdb_prompt $" {fail "prepare to jump to execl call"}
289
     timeout         {fail "(timeout) prepare to jump to execl call"}
290
   }
291
   send_gdb "jump 27\n"
292
   gdb_expect {
293
     -re "main.* at .*${srcfile}:27.*$gdb_prompt $"\
294
                     {pass "jump to execl call"}
295
     -re "$gdb_prompt $" {fail "jump to execl call"}
296
     timeout         {fail "(timeout) jump to execl call"}
297
   }
298
   # Note that stepping through an exec call causes the step-count
299
   # to be reset to zero.  I.e.: you may specify "next 2" at the
300
   # call, but you'll actually stop at the first breakpoint set in
301
   # the newly-exec'd program, not after the remaining step-count
302
   # reaches zero.
303
   #
304
   send_gdb "next 2\n"
305
   gdb_expect {
306
     -re "Executing new program: .*${testfile2}.*${srcfile2}:23.*int  local_j = argc;.*$gdb_prompt $"\
307
                     {pass "step through execl call"}
308
     -re "$gdb_prompt $" {fail "step through execl call"}
309
     timeout         {fail "(timeout) step through execl call"}
310
   }
311
   send_gdb "next\n"
312
   gdb_expect {
313
     -re "26.*printf.*$gdb_prompt $"\
314
                     {pass "step after execl call"}
315
     -re "$gdb_prompt $" {fail "step after execl call"}
316
     timeout         {fail "(timeout) step after execl call"}
317
   }
318
 
319
   # Verify that we can print a local variable (which happens to be
320
   # assigned the value of main's argc).
321
   #
322
   send_gdb "print local_j\n"
323
   gdb_expect {
324
     -re ".* = 3.*$gdb_prompt $"\
325
                     {pass "print execd-program/local_j (after execl)"}
326
     -re "$gdb_prompt $" {fail "print execd-program/local_j (after execl)"}
327
     timeout         {fail "(timeout) print execd-program/local_j (after execl)"}
328
   }
329
 
330
   # Explicitly kill this program, or a subsequent rerun actually runs
331
   # the exec'd program, not the original program...
332
   zap_session
333
 
334
   # Start the program running, and stop at main.
335
   #
336
   if ![runto_main] then {
337
     perror "Couldn't run ${testfile} (4th try)"
338
     return
339
   }
340
 
341
   # Verify that we can follow through follow an execv()
342
   # call.  (We must jump around earlier exec* calls.)
343
   #
344
   send_gdb "tbreak 41\n"
345
   gdb_expect {
346
     -re "Breakpoint .*file .*${srcfile}, line 41.*$gdb_prompt $"\
347
                     {pass "prepare to jump to execv call"}
348
     -re "$gdb_prompt $" {fail "prepare to jump to execv call"}
349
     timeout         {fail "(timeout) prepare to jump to execv call"}
350
   }
351
   send_gdb "jump 41\n"
352
   gdb_expect {
353
     -re "main.* at .*${srcfile}:41.*$gdb_prompt $"\
354
                     {pass "jump to execv call"}
355
     -re "$gdb_prompt $" {fail "jump to execv call"}
356
     timeout         {fail "(timeout) jump to execv call"}
357
   }
358
   send_gdb "next\n"
359
   gdb_expect {
360
     -re "Executing new program: .*${testfile2}.*${srcfile2}:23.*int  local_j = argc;.*$gdb_prompt $"\
361
                     {pass "step through execv call"}
362
     -re "$gdb_prompt $" {fail "step through execv call"}
363
     timeout         {fail "(timeout) step through execv call"}
364
   }
365
   send_gdb "next\n"
366
   gdb_expect {
367
     -re "26.*printf.*$gdb_prompt $"\
368
                     {pass "step after execv call"}
369
     -re "$gdb_prompt $" {fail "step after execv call"}
370
     timeout         {fail "(timeout) step after execv call"}
371
   }
372
 
373
   # Verify that we can print a local variable (which happens to be
374
   # assigned the value of main's argc).
375
   #
376
   send_gdb "print local_j\n"
377
   gdb_expect {
378
     -re ".* = 2.*$gdb_prompt $"\
379
                     {pass "print execd-program/local_j (after execv)"}
380
     -re "$gdb_prompt $" {fail "print execd-program/local_j (after execv)"}
381
     timeout         {fail "(timeout) print execd-program/local_j (after execv)"}
382
   }
383
 
384
   # Explicitly kill this program, or a subsequent rerun actually runs
385
   # the exec'd program, not the original program...
386
   zap_session
387
 
388
   # Start the program running, and stop at main.
389
   #
390
   if ![runto_main] then {
391
     perror "Couldn't run ${testfile} (5th try)"
392
     return
393
   }
394
 
395
   # Verify that we can just continue and thereby follow through an
396
   # exec call.  (Since the breakpoint on "main" is reset, we should
397
   # just stop in main of the newly-exec'd program.)
398
   #
399
   send_gdb "continue\n"
400
   gdb_expect {
401
     -re "Executing new program: .*${testfile2}.*${srcfile2}:23.*int  local_j = argc;.*$gdb_prompt $"\
402
                     {pass "continue through exec"}
403
     -re "$gdb_prompt $" {fail "continue through exec"}
404
     timeout         {fail "(timeout) continue through exec"}
405
   }
406
}
407
 
408
# Start with a fresh gdb
409
 
410
gdb_exit
411
gdb_start
412
gdb_reinitialize_dir $srcdir/$subdir
413
gdb_load ${binfile}
414
 
415
 
416
# This is a test of gdb's ability to follow a process through a
417
# Unix exec() system call.
418
#
419
do_exec_tests
420
 
421
return 0

powered by: WebSVN 2.1.0

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