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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.base/] [break.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
2
#   2000
3
#   Free Software Foundation, Inc.
4
 
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 
19
# Please email any bugs, comments, and/or additions to this file to:
20
# bug-gdb@prep.ai.mit.edu
21
 
22
# This file was written by Rob Savoye. (rob@cygnus.com)
23
 
24
if $tracelevel then {
25
    strace $tracelevel
26
}
27
 
28
 
29
#
30
# test running programs
31
#
32
set prms_id 0
33
set bug_id 0
34
 
35
set testfile "break"
36
set srcfile ${testfile}.c
37
set binfile ${objdir}/${subdir}/${testfile}
38
 
39
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
40
    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
41
}
42
 
43
if [get_compiler_info ${binfile}] {
44
    return -1
45
}
46
 
47
gdb_exit
48
gdb_start
49
gdb_reinitialize_dir $srcdir/$subdir
50
gdb_load ${binfile}
51
 
52
if [target_info exists gdb_stub] {
53
    gdb_step_for_stub;
54
}
55
#
56
# test simple breakpoint setting commands
57
#
58
 
59
# Test deleting all breakpoints when there are none installed,
60
# GDB should not prompt for confirmation.
61
# Note that gdb-init.exp provides a "delete_breakpoints" proc
62
# for general use elsewhere.
63
 
64
send_gdb "delete breakpoints\n"
65
gdb_expect {
66
     -re "Delete all breakpoints.*$" {
67
            send_gdb "y\n"
68
            gdb_expect {
69
                -re "$gdb_prompt $" {
70
                    fail "Delete all breakpoints when none (unexpected prompt)"
71
                }
72
                timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" }
73
            }
74
        }
75
     -re ".*$gdb_prompt $"       { pass "Delete all breakpoints when none" }
76
    timeout                 { fail "Delete all breakpoints when none (timeout)" }
77
}
78
 
79
#
80
# test break at function
81
#
82
gdb_test "break main" \
83
    "Breakpoint.*at.* file .*$srcfile, line.*" \
84
    "breakpoint function"
85
 
86
#
87
# test break at function in file
88
#
89
gdb_test "break $srcfile:factorial" \
90
    "Breakpoint.*at.* file .*$srcfile, line.*" \
91
    "breakpoint function in file"
92
 
93
#
94
# test break at line number
95
#
96
# Note that the default source file is the last one whose source text
97
# was printed.  For native debugging, before we've executed the
98
# program, this is the file containing main, but for remote debugging,
99
# it's wherever the processor was stopped when we connected to the
100
# board.  So, to be sure, we do a list command.
101
#
102
gdb_test "list main" \
103
    ".*main \\(argc, argv, envp\\).*" \
104
    "use `list' to establish default source file"
105
gdb_test "break 79" \
106
    "Breakpoint.*at.* file .*$srcfile, line 79\\." \
107
    "breakpoint line number"
108
 
109
#
110
# test duplicate breakpoint
111
#
112
gdb_test "break 79" \
113
    "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line 79\\." \
114
    "breakpoint duplicate"
115
 
116
#
117
# test break at line number in file
118
#
119
gdb_test "break $srcfile:85" \
120
    "Breakpoint.*at.* file .*$srcfile, line 85\\." \
121
    "breakpoint line number in file"
122
 
123
 
124
#
125
# check to see what breakpoints are set
126
#
127
if [target_info exists gdb_stub] {
128
    set main_line 72
129
} else {
130
    set main_line 75
131
}
132
 
133
if {$hp_aCC_compiler} {
134
    set proto "\\(int\\)"
135
} else {
136
    set proto ""
137
}
138
gdb_test "info break" \
139
    "Num Type\[ \]+Disp Enb Address\[ \]+What.*
140
\[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$main_line.*
141
\[0-9\]+\[\t \]+breakpoint     keep y.* in factorial$proto at .*$srcfile:96.*
142
\[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:79.*
143
\[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:79.*
144
\[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:85" \
145
    "breakpoint info"
146
 
147
 
148
# FIXME: The rest of this test doesn't work with anything that can't
149
# handle arguments.
150
# Huh? There doesn't *appear* to be anything that passes arguments
151
# below.
152
if [istarget "mips-idt-*"] then {
153
    return
154
}
155
 
156
#
157
# run until the breakpoint at main is hit. For non-stubs-using targets.
158
#
159
if ![target_info exists use_gdb_stub] {
160
  if [istarget "*-*-vxworks*"] then {
161
    send_gdb "run vxmain \"2\"\n"
162
    set timeout 120
163
    verbose "Timeout is now $timeout seconds" 2
164
  } else {
165
        send_gdb "run\n"
166
  }
167
  gdb_expect {
168
    -re "The program .* has been started already.*y or n. $" {
169
        send_gdb "y\n"
170
        exp_continue
171
    }
172
    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:75.*75\[\t \]+if .argc.* \{.*$gdb_prompt $"\
173
                            { pass "run until function breakpoint" }
174
    -re ".*$gdb_prompt $"       { fail "run until function breakpoint" }
175
    timeout                 { fail "run until function breakpoint (timeout)" }
176
  }
177
} else {
178
    if ![target_info exists gdb_stub] {
179
        gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue"
180
    }
181
}
182
 
183
#
184
# run until the breakpoint at a line number
185
#
186
gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:79.*79\[\t \]+printf.*factorial.*" \
187
                        "run until breakpoint set at a line number"
188
 
189
#
190
# Run until the breakpoint set in a function in a file
191
#
192
for {set i 6} {$i >= 1} {incr i -1} {
193
        gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:96.*96\[\t \]+.*if .value > 1. \{.*" \
194
                        "run until file:function($i) breakpoint"
195
}
196
 
197
#
198
# run until the file:function breakpoint at a line number in a file
199
#
200
gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:85.*85\[\t \]+argc = \\(argc == 12345\\);.*" \
201
                "run until file:linenum breakpoint"
202
 
203
# Test break at offset +1
204
 
205
gdb_test "break +1" \
206
    "Breakpoint.*at.* file .*$srcfile, line 86\\." \
207
    "breakpoint offset +1"
208
 
209
# Check to see if breakpoint is hit when stepped onto
210
 
211
gdb_test "step" \
212
    ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:86.*86\[\t \]+return argc;" \
213
    "step onto breakpoint"
214
 
215
#
216
# delete all breakpoints so we can start over, course this can be a test too
217
#
218
delete_breakpoints
219
 
220
#
221
# test temporary breakpoint at function
222
#
223
 
224
gdb_test "tbreak main" "Breakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
225
 
226
#
227
# test break at function in file
228
#
229
 
230
gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" \
231
        "Temporary breakpoint function in file"
232
 
233
#
234
# test break at line number
235
#
236
send_gdb "tbreak 79\n"
237
gdb_expect {
238
    -re "Breakpoint.*at.* file .*$srcfile, line 79.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
239
        -re ".*$gdb_prompt $"   { pass "Temporary breakpoint line number #1" }
240
        timeout     { fail "breakpoint line number #1 (timeout)" }
241
}
242
 
243
gdb_test "tbreak 75" "Breakpoint.*at.* file .*$srcfile, line 75.*" "Temporary breakpoint line number #2"
244
 
245
#
246
# test break at line number in file
247
#
248
send_gdb "tbreak $srcfile:85\n"
249
gdb_expect {
250
    -re "Breakpoint.*at.* file .*$srcfile, line 85.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
251
        -re ".*$gdb_prompt $"   { pass "Temporary breakpoint line number in file #1" }
252
        timeout     { fail "Temporary breakpoint line number in file #1 (timeout)" }
253
}
254
 
255
gdb_test  "tbreak $srcfile:81" "Breakpoint.*at.* file .*$srcfile, line 81.*" "Temporary breakpoint line number in file #2"
256
 
257
#
258
# check to see what breakpoints are set (temporary this time)
259
#
260
gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\]
261
\[0-9\]+\[\t \]+breakpoint     del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
262
\[0-9\]+\[\t \]+breakpoint     del.*y.*in factorial$proto at .*$srcfile:96.*\[\r\n\]
263
\[0-9\]+\[\t \]+breakpoint     del.*y.*in main at .*$srcfile:79.*\[\r\n\]
264
\[0-9\]+\[\t \]+breakpoint     del.*y.*in main at .*$srcfile:75.*\[\r\n\]
265
\[0-9\]+\[\t \]+breakpoint     del.*y.*in main at .*$srcfile:85.*\[\r\n\]
266
\[0-9\]+\[\t \]+breakpoint     del.*y.*in main at .*$srcfile:81.*" \
267
    "Temporary breakpoint info"
268
 
269
 
270
#***********
271
 
272
# Verify that catchpoints for fork, vfork and exec don't trigger
273
# inappropriately.  (There are no calls to those system functions
274
# in this test program.)
275
#
276
if ![runto_main] then { fail "break tests suppressed" }
277
 
278
send_gdb "catch\n"
279
gdb_expect {
280
  -re "Catch requires an event name.*$gdb_prompt $"\
281
          {pass "catch requires an event name"}
282
  -re "$gdb_prompt $"\
283
          {fail "catch requires an event name"}
284
  timeout {fail "(timeout) catch requires an event name"}
285
}
286
 
287
 
288
set name "set catch fork, never expected to trigger"
289
send_gdb "catch fork\n"
290
gdb_expect {
291
  -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
292
          {pass $name}
293
  -re "Catch of fork not yet implemented.*$gdb_prompt $"
294
          {pass $name}
295
  -re "$gdb_prompt $"
296
          {fail $name}
297
  timeout {fail "(timeout) $name"}
298
}
299
 
300
 
301
set name "set catch vfork, never expected to trigger"
302
send_gdb "catch vfork\n"
303
 
304
# If we are on HP-UX 10.20, we expect an error message to be
305
# printed if we type "catch vfork" at the gdb gdb_prompt.  This is
306
# because on HP-UX 10.20, we cannot catch vfork events.
307
 
308
if [istarget "hppa*-hp-hpux10.20"] then {
309
    gdb_expect {
310
        -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
311
                {pass $name}
312
        -re "$gdb_prompt $"
313
                {fail $name}
314
        timeout {fail "(timeout) $name"}
315
    }
316
} else {
317
    gdb_expect {
318
        -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
319
                {pass $name}
320
        -re "Catch of vfork not yet implemented.*$gdb_prompt $"
321
                {pass $name}
322
        -re "$gdb_prompt $"
323
                {fail $name}
324
        timeout {fail "(timeout) $name"}
325
    }
326
}
327
 
328
set name "set catch exec, never expected to trigger"
329
send_gdb "catch exec\n"
330
gdb_expect {
331
  -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
332
          {pass $name}
333
  -re "Catch of exec not yet implemented.*$gdb_prompt $"
334
          {pass $name}
335
  -re "$gdb_prompt $" {fail $name}
336
  timeout {fail "(timeout) $name"}
337
}
338
 
339
# Verify that "until " works.  (This is really just syntactic
340
# sugar for "tbreak ; continue".)
341
#
342
send_gdb "until 79\n"
343
gdb_expect {
344
  -re "main .* at .*:79.*$gdb_prompt $"\
345
          {pass "until 79"}
346
  -re "$gdb_prompt $"\
347
          {fail "until 79"}
348
  timeout {fail "(timeout) until 79"}
349
}
350
 
351
# Verify that a malformed "until" is gracefully caught.
352
#
353
send_gdb "until 80 then stop\n"
354
gdb_expect {
355
  -re "Junk at end of arguments..*$gdb_prompt $"\
356
          {pass "malformed until"}
357
  -re "$gdb_prompt $"\
358
          {fail "malformed until"}
359
  timeout {fail "(timeout) malformed until"}
360
}
361
 
362
# Verify that GDB responds gracefully when asked to set a breakpoint
363
# on a nonexistent source line.
364
#
365
send_gdb "break 999\n"
366
gdb_expect {
367
  -re "No line 999 in file .*$gdb_prompt $"\
368
          {pass "break on non-existent source line"}
369
  -re "$gdb_prompt $"\
370
          {fail "break on non-existent source line"}
371
  timeout {fail "(timeout) break on non-existent source line"}
372
}
373
 
374
# Verify that GDB allows one to just say "break", which is treated
375
# as the "default" breakpoint.  Note that GDB gets cute when printing
376
# the informational message about other breakpoints at the same
377
# location.  We'll hit that bird with this stone too.
378
#
379
send_gdb "break\n"
380
gdb_expect {
381
  -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
382
          {pass "break on default location, 1st time"}
383
  -re "$gdb_prompt $"\
384
          {fail "break on default location, 1st time"}
385
  timeout {fail "(timeout) break on default location, 1st time"}
386
}
387
 
388
send_gdb "break\n"
389
gdb_expect {
390
  -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
391
          {pass "break on default location, 2nd time"}
392
  -re "$gdb_prompt $"\
393
          {fail "break on default location, 2nd time"}
394
  timeout {fail "(timeout) break on default location, 2nd time"}
395
}
396
 
397
send_gdb "break\n"
398
gdb_expect {
399
  -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
400
          {pass "break on default location, 3rd time"}
401
  -re "$gdb_prompt $"\
402
          {fail "break on default location, 3rd time"}
403
  timeout {fail "(timeout) break on default location, 3rd time"}
404
}
405
 
406
send_gdb "break\n"
407
gdb_expect {
408
  -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
409
          {pass "break on default location, 4th time"}
410
  -re "$gdb_prompt $"\
411
          {fail "break on default location, 4th time"}
412
  timeout {fail "(timeout) break on default location, 4th time"}
413
}
414
 
415
# Verify that a "silent" breakpoint can be set, and that GDB is indeed
416
# "silent" about its triggering.
417
#
418
if ![runto_main] then { fail "break tests suppressed" }
419
 
420
send_gdb "break 79\n"
421
gdb_expect {
422
  -re "Breakpoint (\[0-9\]*) at .*, line 79.*$gdb_prompt $"\
423
          {pass "set to-be-silent break 79"}
424
  -re "$gdb_prompt $"\
425
          {fail "set to-be-silent break 79"}
426
  timeout {fail "(timeout) set to-be-silent break 79"}
427
}
428
 
429
send_gdb "commands $expect_out(1,string)\n"
430
send_gdb "silent\n"
431
send_gdb "end\n"
432
gdb_expect {
433
  -re ".*$gdb_prompt $"\
434
          {pass "set silent break 79"}
435
  timeout {fail "(timeout) set silent break 79"}
436
}
437
 
438
send_gdb "info break $expect_out(1,string)\n"
439
gdb_expect {
440
  -re "\[0-9\]*\[ \t\]*breakpoint.*:79\r\n\[ \t\]*silent.*$gdb_prompt $"\
441
          {pass "info silent break 79"}
442
  -re "$gdb_prompt $"\
443
          {fail "info silent break 79"}
444
  timeout {fail "(timeout) info silent break 79"}
445
}
446
send_gdb "continue\n"
447
gdb_expect {
448
  -re "Continuing.\r\n$gdb_prompt $"\
449
          {pass "hit silent break 79"}
450
  -re "$gdb_prompt $"\
451
          {fail "hit silent break 79"}
452
  timeout {fail "(timeout) hit silent break 79"}
453
}
454
send_gdb "bt\n"
455
gdb_expect {
456
  -re "#0  main .* at .*:79.*$gdb_prompt $"\
457
          {pass "stopped for silent break 79"}
458
  -re "$gdb_prompt $"\
459
          {fail "stopped for silent break 79"}
460
  timeout {fail "(timeout) stopped for silent break 79"}
461
}
462
 
463
# Verify that GDB can at least parse a breakpoint with the
464
# "thread" keyword.  (We won't attempt to test here that a
465
# thread-specific breakpoint really triggers appropriately.
466
# The gdb.threads subdirectory contains tests for that.)
467
#
468
send_gdb "break 80 thread 999\n"
469
gdb_expect {
470
  -re "Unknown thread 999.*$gdb_prompt $"\
471
          {pass "thread-specific breakpoint on non-existent thread disallowed"}
472
  -re "$gdb_prompt $"\
473
          {fail "thread-specific breakpoint on non-existent thread disallowed"}
474
  timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
475
}
476
send_gdb "break 80 thread foo\n"
477
gdb_expect {
478
  -re "Junk after thread keyword..*$gdb_prompt $"\
479
          {pass "thread-specific breakpoint on bogus thread ID disallowed"}
480
  -re "$gdb_prompt $"\
481
          {fail "thread-specific breakpoint on bogus thread ID disallowed"}
482
  timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
483
}
484
 
485
# Verify that GDB responds gracefully to a breakpoint command with
486
# trailing garbage.
487
#
488
send_gdb "break 80 foo\n"
489
gdb_expect {
490
  -re "Junk at end of arguments..*$gdb_prompt $"\
491
          {pass "breakpoint with trailing garbage disallowed"}
492
  -re "$gdb_prompt $"\
493
          {fail "breakpoint with trailing garbage disallowed"}
494
  timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
495
}
496
 
497
# Verify that GDB responds gracefully to a "clear" command that has
498
# no matching breakpoint.  (First, get us off the current source line,
499
# which we know has a breakpoint.)
500
#
501
send_gdb "next\n"
502
gdb_expect {
503
  -re ".*$gdb_prompt $"\
504
          {pass "step over breakpoint"}
505
  timeout {fail "(timeout) step over breakpoint"}
506
}
507
send_gdb "clear 81\n"
508
gdb_expect {
509
  -re "No breakpoint at 81..*$gdb_prompt $"\
510
          {pass "clear line has no breakpoint disallowed"}
511
  -re "$gdb_prompt $"\
512
          {fail "clear line has no breakpoint disallowed"}
513
  timeout {fail "(timeout) clear line has no breakpoint disallowed"}
514
}
515
send_gdb "clear\n"
516
gdb_expect {
517
  -re "No breakpoint at this line..*$gdb_prompt $"\
518
          {pass "clear current line has no breakpoint disallowed"}
519
  -re "$gdb_prompt $"\
520
          {fail "clear current line has no breakpoint disallowed"}
521
  timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
522
}
523
 
524
# Verify that we can set and clear multiple breakpoints.
525
#
526
# We don't test that it deletes the correct breakpoints.  We do at
527
# least test that it deletes more than one breakpoint.
528
#
529
gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
530
gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
531
gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
532
 
533
# Verify that a breakpoint can be set via a convenience variable.
534
#
535
send_gdb "set \$foo=81\n"
536
gdb_expect {
537
  -re "$gdb_prompt $"\
538
          {pass "set convenience variable \$foo to 81"}
539
  timeout {fail "(timeout) set convenience variable \$foo to 81"}
540
}
541
send_gdb "break \$foo\n"
542
gdb_expect {
543
  -re "Breakpoint (\[0-9\]*) at .*, line 81.*$gdb_prompt $"\
544
          {pass "set breakpoint via convenience variable"}
545
  -re "$gdb_prompt $"\
546
          {fail "set breakpoint via convenience variable"}
547
  timeout {fail "(timeout) set breakpoint via convenience variable"}
548
}
549
 
550
# Verify that GDB responds gracefully to an attempt to set a
551
# breakpoint via a convenience variable whose type is not integer.
552
#
553
send_gdb "set \$foo=81.5\n"
554
gdb_expect {
555
  -re "$gdb_prompt $"\
556
          {pass "set convenience variable \$foo to 81.5"}
557
  timeout {fail "(timeout) set convenience variable \$foo to 81.5"}
558
}
559
send_gdb "break \$foo\n"
560
gdb_expect {
561
  -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
562
          {pass "set breakpoint via non-integer convenience variable disallowed"}
563
  -re "$gdb_prompt $"\
564
          {fail "set breakpoint via non-integer convenience variable disallowed"}
565
  timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
566
}
567
 
568
# Verify that we can set and trigger a breakpoint in a user-called function.
569
#
570
send_gdb "break marker2\n"
571
gdb_expect {
572
    -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\
573
          {pass "set breakpoint on to-be-called function"}
574
  -re "$gdb_prompt $"\
575
          {fail "set breakpoint on to-be-called function"}
576
  timeout {fail "(timeout) set breakpoint on to-be-called function"}
577
}
578
send_gdb "print marker2(99)\n"
579
gdb_expect {
580
  -re "The program being debugged stopped while in a function called from GDB.\r\nWhen the function .marker2$proto. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$gdb_prompt $"\
581
          {pass "hit breakpoint on called function"}
582
  -re "$gdb_prompt $"\
583
          {fail "hit breakpoint on called function"}
584
  timeout {fail "(timeout) hit breakpoint on called function"}
585
}
586
 
587
# As long as we're stopped (breakpointed) in a called function,
588
# verify that we can successfully backtrace & such from here.
589
#
590
# In this and the following test, the _sr4export check apparently is needed
591
# for hppa*-*-hpux.
592
#
593
send_gdb "bt\n"
594
gdb_expect {
595
    -re "#0\[ \t\]*$hex in marker2.*:4\[49\]\r\n#1.*_sr4export.*$gdb_prompt $"\
596
            {pass "backtrace while in called function"}
597
    -re "#0\[ \t\]*($hex in )?marker2.*:4\[49\]\r\n#1.*function called from gdb.*$gdb_prompt $"\
598
            {pass "backtrace while in called function"}
599
    -re "$gdb_prompt $"\
600
            {fail "backtrace while in called function"}
601
    timeout {fail "(timeout) backtrace while in called function"}
602
}
603
 
604
# Return from the called function.  For remote targets, it's important to do
605
# this before runto_main, which otherwise may silently stop on the dummy
606
# breakpoint inserted by GDB at the program's entry point.
607
#
608
send_gdb "finish\n"
609
gdb_expect {
610
    -re "Run till exit from .*marker2.* at .*4\[49\]\r\n.* in _sr4export.*$gdb_prompt $"\
611
            {pass "finish from called function"}
612
    -re "Run till exit from .*marker2.* at .*4\[49\]\r\n.*function called from gdb.*$gdb_prompt $"\
613
            {pass "finish from called function"}
614
    -re "Run till exit from .*marker2.* at .*4\[49\]\r\n.*Value returned.*$gdb_prompt $"\
615
            {pass "finish from called function"}
616
    -re "$gdb_prompt $"\
617
            {fail "finish from called function"}
618
    timeout {fail "(timeout) finish from called function"}
619
}
620
 
621
# Verify that GDB responds gracefully to a "finish" command with
622
# arguments.
623
#
624
if ![runto_main] then { fail "break tests suppressed" }
625
 
626
send_gdb "finish 123\n"
627
gdb_expect {
628
  -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
629
          {pass "finish with arguments disallowed"}
630
  -re "$gdb_prompt $"\
631
          {fail "finish with arguments disallowed"}
632
  timeout {fail "(timeout) finish with arguments disallowed"}
633
}
634
 
635
# Verify that GDB responds gracefully to a request to "finish" from
636
# the outermost frame.  On a stub that never exits, this will just
637
# run to the stubs routine, so we don't get this error...  Thus the
638
# second condition.
639
#
640
 
641
send_gdb "finish\n"
642
gdb_expect {
643
  -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
644
          {pass "finish from outermost frame disallowed"}
645
  -re "Run till exit from.*\r\n$gdb_prompt $" {
646
     pass "finish from outermost frame disallowed"
647
  }
648
  -re "$gdb_prompt $"\
649
          {fail "finish from outermost frame disallowed"}
650
  timeout {fail "(timeout) finish from outermost frame disallowed"}
651
}
652
 
653
# Verify that we can explicitly ask GDB to stop on all shared library
654
# events, and that it does so.
655
#
656
if [istarget "hppa*-*-hpux*"] then {
657
  if ![runto_main] then { fail "break tests suppressed" }
658
 
659
  send_gdb "set stop-on-solib-events 1\n"
660
  gdb_expect {
661
    -re "$gdb_prompt $"\
662
            {pass "set stop-on-solib-events"}
663
    timeout {fail "(timeout) set stop-on-solib-events"}
664
  }
665
 
666
  send_gdb "run\n"
667
  gdb_expect {
668
    -re ".*Start it from the beginning.*y or n. $"\
669
            {send_gdb "y\n"
670
             gdb_expect {
671
               -re ".*Stopped due to shared library event.*$gdb_prompt $"\
672
                       {pass "triggered stop-on-solib-events"}
673
               -re "$gdb_prompt $"\
674
                       {fail "triggered stop-on-solib-events"}
675
               timeout {fail "(timeout) triggered stop-on-solib-events"}
676
             }
677
            }
678
    -re "$gdb_prompt $"\
679
            {fail "rerun for stop-on-solib-events"}
680
    timeout {fail "(timeout) rerun for stop-on-solib-events"}
681
  }
682
 
683
  send_gdb "set stop-on-solib-events 0\n"
684
  gdb_expect {
685
    -re "$gdb_prompt $"\
686
            {pass "reset stop-on-solib-events"}
687
    timeout {fail "(timeout) reset stop-on-solib-events"}
688
  }
689
}
690
 
691
# Hardware breakpoints are unsupported on HP-UX.  Verify that GDB
692
# gracefully responds to requests to create them.
693
#
694
if [istarget "hppa*-*-hpux*"] then {
695
  if ![runto_main] then { fail "break tests suppressed" }
696
 
697
  send_gdb "hbreak\n"
698
  gdb_expect {
699
    -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
700
            {pass "hw breaks disallowed"}
701
    -re "$gdb_prompt $"\
702
            {fail "hw breaks disallowed"}
703
    timeout {fail "(timeout) hw breaks disallowed"}
704
  }
705
 
706
  send_gdb "thbreak\n"
707
  gdb_expect {
708
    -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
709
            {pass "temporary hw breaks disallowed"}
710
    -re "$gdb_prompt $"\
711
            {fail "temporary hw breaks disallowed"}
712
    timeout {fail "(timeout) temporary hw breaks disallowed"}
713
  }
714
}
715
 
716
#********
717
 
718
 
719
#
720
# Test "next" over recursive function call.
721
#
722
 
723
proc test_next_with_recursion {} {
724
    global gdb_prompt
725
    global decimal
726
    global binfile
727
 
728
    if [target_info exists use_gdb_stub] {
729
        # Reload the program.
730
        delete_breakpoints
731
        gdb_load ${binfile};
732
    } else {
733
        # FIXME: should be using runto
734
        gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
735
 
736
        delete_breakpoints
737
    }
738
 
739
    gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
740
 
741
    # Run until we call factorial with 6
742
 
743
    if [istarget "*-*-vxworks*"] then {
744
        send_gdb "run vxmain \"6\"\n"
745
    } else {
746
        gdb_run_cmd
747
    }
748
    gdb_expect {
749
        -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
750
        -re ".*$gdb_prompt $" {
751
            fail "run to factorial(6)";
752
            gdb_suppress_tests;
753
        }
754
        timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
755
    }
756
 
757
    # Continue until we call factorial recursively with 5.
758
 
759
    if [gdb_test "continue" \
760
        "Continuing.*Break.* factorial .value=5. .*" \
761
        "continue to factorial(5)"] then { gdb_suppress_tests }
762
 
763
    # Do a backtrace just to confirm how many levels deep we are.
764
 
765
    if [gdb_test "backtrace" \
766
        "#0\[ \t\]+ factorial .value=5..*" \
767
        "backtrace from factorial(5)"] then { gdb_suppress_tests }
768
 
769
    # Now a "next" should position us at the recursive call, which
770
    # we will be performing with 4.
771
 
772
    if [gdb_test "next" \
773
        ".* factorial .value - 1.;.*" \
774
        "next to recursive call"] then { gdb_suppress_tests }
775
 
776
    # Disable the breakpoint at the entry to factorial by deleting them all.
777
    # The "next" should run until we return to the next line from this
778
    # recursive call to factorial with 4.
779
    # Buggy versions of gdb will stop instead at the innermost frame on
780
    # the line where we are trying to "next" to.
781
 
782
    delete_breakpoints
783
 
784
    if [istarget "mips*tx39-*"] {
785
        set timeout 60
786
    } else {
787
        set timeout 20
788
    }
789
 
790
    gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
791
            "next over recursive call"
792
 
793
    # OK, we should be back in the same stack frame we started from.
794
    # Do a backtrace just to confirm.
795
 
796
    set result [gdb_test "backtrace" \
797
            "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
798
            "backtrace from factorial(5.1)"]
799
    if { $result != 0 } { gdb_suppress_tests }
800
 
801
    if [target_info exists gdb,noresults] { gdb_suppress_tests }
802
  gdb_continue_to_end "recursive next test"
803
   gdb_stop_suppressing_tests;
804
}
805
 
806
test_next_with_recursion
807
 
808
 
809
#********
810
 
811
# build a new file with optimization enabled so that we can try breakpoints
812
# on targets with optimized prologues
813
 
814
set binfileo2 ${objdir}/${subdir}/${testfile}o2
815
 
816
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfileo2}" executable {debug additional_flags="-O2" }] != "" } {
817
    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
818
}
819
 
820
if [get_compiler_info ${binfileo2}] {
821
    return -1
822
}
823
 
824
gdb_exit
825
gdb_start
826
gdb_reinitialize_dir $srcdir/$subdir
827
gdb_load ${binfileo2}
828
 
829
if [target_info exists gdb_stub] {
830
    gdb_step_for_stub;
831
}
832
 
833
#
834
# test break at function
835
#
836
gdb_test "break main" \
837
    "Breakpoint.*at.* file .*$srcfile, line.*" \
838
    "breakpoint function, optimized file"
839
 
840
#
841
# test break at function
842
#
843
gdb_test "break marker4" \
844
    "Breakpoint.*at.* file .*$srcfile, line.*" \
845
    "breakpoint small function, optimized file"
846
 
847
#
848
# run until the breakpoint at main is hit. For non-stubs-using targets.
849
#
850
if ![target_info exists use_gdb_stub] {
851
  if [istarget "*-*-vxworks*"] then {
852
    send_gdb "run vxmain \"2\"\n"
853
    set timeout 120
854
    verbose "Timeout is now $timeout seconds" 2
855
  } else {
856
        send_gdb "run\n"
857
  }
858
  gdb_expect {
859
    -re "The program .* has been started already.*y or n. $" {
860
        send_gdb "y\n"
861
        exp_continue
862
    }
863
    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:75.*75\[\t \]+if .argc.* \{.*$gdb_prompt $"\
864
                            { pass "run until function breakpoint, optimized file" }
865
    -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
866
                            { pass "run until function breakpoint, optimized file (code motion)" }
867
    -re ".*$gdb_prompt $"       { fail "run until function breakpoint, optimized file" }
868
    timeout                 { fail "run until function breakpoint, optimized file (timeout)" }
869
  }
870
} else {
871
    if ![target_info exists gdb_stub] {
872
        gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
873
    }
874
}
875
 
876
#
877
# run until the breakpoint at a small function
878
#
879
 
880
#
881
# Add a second pass pattern.  The behavior differs here between stabs
882
# and dwarf for one-line functions.  Stabs preserves two line symbols
883
# (one before the prologue and one after) with the same line number,
884
# but dwarf regards these as duplicates and discards one of them.
885
# Therefore the address after the prologue (where the breakpoint is)
886
# has no exactly matching line symbol, and GDB reports the breakpoint
887
# as if it were in the middle of a line rather than at the beginning.
888
 
889
send_gdb "continue\n"
890
gdb_expect {
891
    -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:51\[\r\n\]+51\[\t \]+void marker4.*" {
892
        pass "run until breakpoint set at small function, optimized file"
893
    }
894
    -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile:51\[\r\n\]+51\[\t \]+void marker4.*" {
895
        pass "run until breakpoint set at small function, optimized file"
896
    }
897
    -re ".*$gdb_prompt " {
898
        fail "run until breakpoint set at small function, optimized file"
899
    }
900
    timeout {
901
        fail "run until breakpoint set at small function, optimized file (timeout)"
902
    }
903
}
904
 
905
 
906
# Reset the default arguments for VxWorks
907
if [istarget "*-*-vxworks*"] {
908
    set timeout 10
909
    verbose "Timeout is now $timeout seconds" 2
910
    send_gdb "set args main\n"
911
    gdb_expect -re ".*$gdb_prompt $" {}
912
}

powered by: WebSVN 2.1.0

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