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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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