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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
# Copyright 2003, 2004, 2005, 2006, 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
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
 
18
if $tracelevel then {
19
    strace $tracelevel
20
}
21
 
22
 
23
# are we on a target board? If so, don't run these tests.
24
# note: this is necessary because we cannot use runto_main (which would
25
# work for remote targets too) because of the different prompt we get
26
# when using annotation level 2.
27
#
28
if [is_remote target] then {
29
    return 0
30
}
31
 
32
 
33
#
34
# test running programs
35
#
36
set prms_id 0
37
set bug_id 0
38
 
39
set testfile "annota3"
40
set srcfile ${testfile}.c
41
set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
42
 
43
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
44
    untested annota3.exp
45
    return -1
46
}
47
 
48
 
49
gdb_exit
50
gdb_start
51
gdb_reinitialize_dir $srcdir/$subdir
52
gdb_load ${binfile}
53
 
54
if [target_info exists gdb_stub] {
55
    gdb_step_for_stub;
56
}
57
 
58
#
59
# the line at which break main will put the breakpoint
60
#
61
set main_line 32
62
 
63
# The commands we test here produce many lines of output; disable "press
64
#  to continue" prompts.
65
send_gdb "set height 0\n"
66
gdb_expect -re "$gdb_prompt $"
67
 
68
#
69
# break at main
70
#
71
gdb_test "break main" \
72
    "Breakpoint.*at.* file .*$srcfile, line.*" \
73
    "breakpoint main"
74
 
75
 
76
# NOTE: this prompt is OK only when the annotation level is > 1
77
 
78
# NOTE: When this prompt is in use the gdb_test procedure cannot be
79
# used because it assumes that the last char after the gdb_prompt is a
80
# white space. This is not true with this annotated prompt. So we must
81
# use send_gdb and gdb_expect or gdb_expect_list.
82
 
83
set old_gdb_prompt $gdb_prompt
84
set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
85
 
86
 
87
 
88
#
89
# set the annotation level to 3
90
#
91
# of course, this will test:
92
# annotate-pre-prompt
93
# annotate-prompt
94
# annotate-post-prompt (in the next block)
95
#
96
send_gdb "set annotate 3\n"
97
gdb_expect_list "annotation set at level 3" "\r\n$gdb_prompt$" {
98
    "set annotate 3"
99
}
100
 
101
#
102
# if construct:
103
#
104
send_gdb "if 1\n"
105
gdb_expect {
106
    -re "^if 1\r\n\r\n\032\032post-prompt\r\n\r\n\032\032pre-commands\r\n >\r\n\032\032commands\r\n$" {
107
        pass "start if construct"
108
    }
109
    -re ".*\032\032commands\r\n" {
110
        fail "start if construct"
111
    }
112
    timeout { fail "start if construct (timeout)" }
113
}
114
send_gdb "end\n"
115
gdb_expect {
116
    -re "^end\r\n\r\n\032\032post-commands\r\n$gdb_prompt$" {
117
        pass "end if construct"
118
    }
119
    -re ".*$gdb_prompt$" {
120
        fail "end if construct"
121
    }
122
    timeout { fail "end if construct (timeout)" }
123
}
124
#
125
# info break:
126
#
127
send_gdb "info break\n"
128
gdb_expect_list "breakpoint info" "$gdb_prompt$" {
129
    "\r\n\032\032post-prompt\r\n"
130
    "Num     Type           Disp Enb Address    +What\r\n"
131
    "1       breakpoint     keep y   0x\[0-9a-zA-Z\]+ +in main at .*annota3.c:32\r\n"
132
}
133
 
134
 
135
#
136
# run to a break point will test:
137
#
138
#exp_internal 1
139
send_gdb "run\n"
140
gdb_expect_list "run until main breakpoint" "$gdb_prompt$" {
141
    "\r\n\032\032post-prompt\r\n"
142
    "Starting program: .*annota3(|\.exe) \r\n"
143
    "\r\n\032\032starting\r\n"
144
    "\r\n\032\032breakpoint 1\r\n"
145
    "\r\n"
146
    "Breakpoint 1, "
147
    "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
148
    "main \\(\\) at .*annota3.c:32\r\n"
149
    "\r\n\032\032source.*annota3.c:32:.*:beg:0x\[0-9a-z\]+\r\n"
150
    "\r\n\032\032stopped\r\n"
151
}
152
#exp_internal 0
153
#exit 0
154
 
155
#
156
# Let's do a next, to get to a point where the array is initialized
157
# We don't care about the annotated output for this operation, it is the same as
158
# the one produced by run above
159
#
160
send_gdb "next\n"
161
gdb_expect_list "go after array init line" "$gdb_prompt$" {
162
    "\r\n\032\032post-prompt\r\n"
163
    "\r\n\032\032starting\r\n"
164
    "\r\n\032\032source .*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
165
    "\r\n\032\032stopped\r\n"
166
}
167
 
168
 
169
#
170
# printing the array:
171
#
172
send_gdb "print my_array\n"
173
gdb_expect_list "print array" "$gdb_prompt$" {
174
    "\r\n\032\032post-prompt\r\n"
175
    ".*= .1, 2, 3.\r\n"
176
}
177
 
178
 
179
#
180
# this should generate an error message, so to test:
181
# annotate-error-begin
182
# FIXME: annotate-error not tested
183
#
184
 
185
#exp_internal 1
186
send_gdb "print non_existent_value\n"
187
gdb_expect_list "print non_existent_value" "$gdb_prompt$" {
188
    "\r\n\032\032post-prompt\r\n"
189
    "\r\n\032\032error-begin\r\n"
190
    "No symbol \"non_existent_value\" in current context.\r\n"
191
    "\r\n\032\032error\r\n"
192
}
193
 
194
 
195
#
196
# break at signal handler
197
#
198
send_gdb "break handle_USR1\n"
199
gdb_expect_list "breakpoint handle_USR1" "$gdb_prompt$" {
200
    "\r\n\032\032post-prompt\r\n"
201
    "Breakpoint.*at 0x\[0-9a-z\]+: file.*annota3.c, line.*\r\n"
202
}
203
 
204
#
205
# break at printf. When we are stopped at printf, we can test
206
#
207
send_gdb "break printf\n"
208
gdb_expect_list "breakpoint printf" "$gdb_prompt$" {
209
    "\r\n\032\032post-prompt\r\n"
210
    "Breakpoint.*at 0x\[0-9a-z\]+.*"
211
}
212
 
213
#
214
# get to printf
215
#
216
send_gdb "continue\n"
217
gdb_expect_list "continue to printf" "$gdb_prompt$" {
218
    "\r\n\032\032post-prompt\r\n"
219
    "Continuing.\r\n"
220
    "\r\n\032\032starting\r\n"
221
    "\r\n\032\032breakpoint 3\r\n"
222
    "\r\n"
223
    "Breakpoint 3, \[^\r\n\]*\r\n"
224
    "\r\n\032\032stopped\r\n"
225
}
226
 
227
send_gdb "backtrace\n"
228
gdb_expect_list "backtrace from shlibrary" "$gdb_prompt$" {
229
    "\r\n\032\032post-prompt\r\n"
230
    "#0 .* .*printf \[^\r\n\]*\r\n"
231
    "#1 .* main \[^\r\n\]*\r\n"
232
}
233
 
234
 
235
#
236
# test printing a frame with some arguments:
237
#
238
 
239
if [target_info exists gdb,nosignals] {
240
    unsupported "send SIGUSR1"
241
    unsupported "backtrace @ signal handler"
242
} else {
243
    send_gdb "signal SIGUSR1\n"
244
    gdb_expect_list "send SIGUSR1" "$gdb_prompt$" {
245
        "\r\n\032\032post-prompt\r\n"
246
        "Continuing with signal SIGUSR1.\r\n"
247
        "\r\n\032\032starting\r\n"
248
        "\r\n\032\032breakpoint 2\r\n"
249
        "\r\n"
250
        "Breakpoint 2, "
251
        "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
252
        "handle_USR1 \\(sig=\[0-9\]+\\) at .*annota3.c:\[0-9\]+\r\n"
253
        "\r\n\032\032source .*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
254
        "\r\n\032\032stopped\r\n"
255
    }
256
 
257
    #
258
    # test:
259
    #
260
    verbose "match_max local is: [match_max]"
261
    verbose "match_max default is: [match_max -d]"
262
    # This is necessary because a 2000 buffer is not enought to get everything
263
    # up to the prompt ad the test gets a timeout.
264
    match_max 3000
265
    verbose "match_max now is: [match_max]"
266
    send_gdb "backtrace\n"
267
    gdb_expect_list "backtrace @ signal handler" "$gdb_prompt$" {
268
        "#0 +handle_USR1 \[^\r\n\]+\r\n"
269
        "#1 +.signal handler called.\r\n"
270
        "#2 .* .*printf \[^\r\n\]+\r\n"
271
        "#3 .* main \[^\r\n\]+\r\n"
272
    }
273
}
274
 
275
#
276
# delete all the breakpoints
277
#
278
send_gdb "delete 1\n"
279
gdb_expect_list "delete bp 1" "$gdb_prompt$" {
280
    "\r\n\032\032post-prompt\r\n"
281
}
282
 
283
send_gdb "delete 2\n"
284
gdb_expect_list "delete bp 2" "$gdb_prompt$" {
285
    "\r\n\032\032post-prompt\r\n"
286
}
287
 
288
send_gdb "delete 3\n"
289
gdb_expect_list "delete bp 3" "$gdb_prompt$" {
290
    "\r\n\032\032post-prompt\r\n"
291
}
292
 
293
#
294
# break at main, after value is initialized. This is in preparation
295
# to test the annotate output for the display command.
296
#
297
send_gdb "break main\n"
298
gdb_expect_list "break at 28" "$gdb_prompt$" {
299
    "\r\n\032\032post-prompt\r\n"
300
    "Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line 32.\r\n"
301
}
302
 
303
#
304
# display the value
305
#
306
send_gdb "display value\n"
307
gdb_expect_list "set up display" "$gdb_prompt$" {
308
    "\r\n\032\032post-prompt\r\n"
309
    "1: value = 7\r\n"
310
}
311
 
312
 
313
# should ask query. Test annotate-query.
314
# we don't care about anything else here, only the query.
315
 
316
send_gdb "run\n"
317
gdb_expect {
318
  -re "pre-query.*already.*\\(y or n\\).*query\r\n" {
319
         send_gdb "y\n"
320
         gdb_expect {
321
             -re ".*post-query.*$gdb_prompt$" \
322
                     { pass "re-run" }
323
             -re ".*$gdb_prompt$"  { fail "re-run" }
324
             timeout { fail "re-run (timeout)" }
325
         }
326
     }
327
  -re ".*$gdb_prompt$"  { fail "re-run" }
328
  timeout { fail "re-run (timeout)" }
329
}
330
 
331
#
332
# Test that breakpoints-invalid is issued once and only once for
333
# breakpoint ignore count changes, after annotation stopped.
334
# NOTE: breakpoints-invalid annotations have been removed from
335
# level 3 but keep these tests for continuity and comparison
336
# with annota1.exp.
337
send_gdb "break 46\n"
338
gdb_expect_list  "break at 46" "$gdb_prompt$" {
339
    "\r\n\032\032post-prompt\r\n"
340
    "Breakpoint 5 at 0x\[0-9a-z\]+: file .*annota3.c, line 46.\r\n"
341
}
342
 
343
send_gdb "ignore 5 4\n"
344
gdb_expect_list "ignore 5 4" "$gdb_prompt$" {
345
    "\r\n\032\032post-prompt\r\n"
346
    "Will ignore next 4 crossings of breakpoint 5"
347
    "\r\n"
348
}
349
 
350
send_gdb "continue\n"
351
gdb_expect_list "annotate ignore count change" "$gdb_prompt$" {
352
    "\r\n\032\032post-prompt\r\n"
353
    "\r\n\032\032breakpoint 5\r\n"
354
    "\r\n"
355
    "Breakpoint 5, "
356
    "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
357
    "main \\(\\) at .*annota3.c:46\r\n"
358
    "\r\n\032\032source .*annota3.c:46:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
359
    "1: value = 11\r\n"
360
    "\r\n\032\032stopped\r\n"
361
}
362
 
363
# check that ignore command is working, or the above can provide
364
# misleading assurance ...
365
 
366
send_gdb "next\n"
367
gdb_expect_list "next to exit loop" "$gdb_prompt$"  {
368
    "\r\n\032\032post-prompt\r\n"
369
    "\r\n\032\032starting\r\n"
370
    "\r\n\032\032source.*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
371
    "1: value = 12\r\n"
372
    "\r\n\032\032stopped\r\n"
373
}
374
 
375
send_gdb "next\n"
376
gdb_expect_list "breakpoint ignore count" "$gdb_prompt$" {
377
    "\r\n\032\032post-prompt\r\n"
378
    "\r\n\032\032starting\r\n"
379
    "\r\n\032\032source.*annota3.c:49:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
380
    "1: value = 12\r\n"
381
    "\r\n\032\032stopped\r\n"
382
}
383
 
384
#
385
# Send a signal that is not handled
386
#
387
# SIGTRAP signals are dropped before they get to the inferior process
388
# on hpux11.  In theory, this behaivor can be controlled by setting
389
# TTEO_NORM_SIGTRAP in the inferior, but doing so did not cause
390
# the signal to be properly delivered.
391
#
392
# It has been verified that other signals will be delivered.  However,
393
# rather than twiddle the test, I choose to leave it as-is as it
394
# exposes an interesting failure on hpux11.
395
 
396
if [target_info exists gdb,nosignals] {
397
    unsupported "signal sent"
398
} else {
399
    setup_xfail hppa*-*-hpux11*
400
    send_gdb "signal SIGTRAP\n"
401
    gdb_expect_list "signal sent" "$gdb_prompt$" {
402
        "\r\n\032\032post-prompt\r\n"
403
        "Continuing with signal SIGTRAP.\r\n"
404
        "\r\n\032\032starting\r\n"
405
        "\r\n\032\032signalled\r\n"
406
        "\r\nProgram terminated with signal SIGTRAP, Trace.breakpoint trap.\r\n"
407
        "The program no longer exists.\r\n"
408
        "\r\n\032\032stopped\r\n"
409
    }
410
}
411
 
412
 
413
# Check for production of a core file and remove it!
414
 
415
set exec_output [remote_exec build "ls core"]
416
 
417
set test "cleanup core file"
418
if [ regexp "core not found" $exec_output]  {
419
    pass "$test (not dumped)"
420
} else {
421
    if [ regexp "No such file or directory" $exec_output] {
422
        pass "$test (not dumped)"
423
    } else {
424
        remote_exec build "rm -f core"
425
        pass "$test (removed)"
426
    }
427
}
428
 
429
# restore the original prompt for the rest of the testsuite
430
 
431
set gdb_prompt $old_gdb_prompt

powered by: WebSVN 2.1.0

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