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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
# Copyright 2002, 2004, 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 Andrew Cagney (cagney at redhat dot com),
17
# derived from xfullpath.exp (written by Joel Brobecker), derived from
18
# selftest.exp (written by Rob Savoye).
19
 
20
if $tracelevel then {
21
    strace $tracelevel
22
}
23
 
24
set prms_id 0
25
set bug_id 0
26
 
27
# are we on a target board
28
if { [is_remote target] || ![isnative] } then {
29
    return
30
}
31
 
32
proc setup_test { executable } {
33
    global gdb_prompt
34
    global timeout
35
 
36
    # load yourself into the debugger
37
    # This can take a relatively long time, particularly for testing where
38
    # the executable is being accessed over a network, or where gdb does not
39
    # support partial symbols for a particular target and has to load the
40
    # entire symbol table.  Set the timeout to 10 minutes, which should be
41
    # adequate for most environments (it *has* timed out with 5 min on a
42
    # SPARCstation SLC under moderate load, so this isn't unreasonable).
43
    # After gdb is started, set the timeout to 30 seconds for the duration
44
    # of this test, and then back to the original value.
45
 
46
    set oldtimeout $timeout
47
    set timeout 600
48
    verbose "Timeout is now $timeout seconds" 2
49
 
50
    global gdb_file_cmd_debug_info
51
    set gdb_file_cmd_debug_info "unset"
52
 
53
    set result [gdb_load $executable]
54
    set timeout $oldtimeout
55
    verbose "Timeout is now $timeout seconds" 2
56
 
57
    if { $result != 0 } then {
58
        return -1
59
    }
60
 
61
    if { $gdb_file_cmd_debug_info != "debug" } then {
62
        untested "No debug information, skipping testcase."
63
        return -1
64
    }
65
 
66
    # Set a breakpoint at main
67
    gdb_test "break captured_command_loop" \
68
            "Breakpoint.*at.* file.*, line.*" \
69
            "breakpoint in captured_command_loop"
70
 
71
    # run yourself
72
    # It may take a very long time for the inferior gdb to start (lynx),
73
    # so we bump it back up for the duration of this command.
74
    set timeout 600
75
 
76
    set description "run until breakpoint at captured_command_loop"
77
    send_gdb "run -nw\n"
78
    gdb_expect {
79
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
80
            pass "$description"
81
        }
82
        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
83
            xfail "$description (line numbers scrambled?)"
84
        }
85
        -re "vfork: No more processes.*$gdb_prompt $" {
86
            fail "$description (out of virtual memory)"
87
            set timeout $oldtimeout
88
            verbose "Timeout is now $timeout seconds" 2
89
            return -1
90
        }
91
        -re ".*$gdb_prompt $" {
92
            fail "$description"
93
            set timeout $oldtimeout
94
            verbose "Timeout is now $timeout seconds" 2
95
            return -1
96
        }
97
        timeout {
98
            fail "$description (timeout)"
99
        }
100
    }
101
 
102
    set timeout $oldtimeout
103
    verbose "Timeout is now $timeout seconds" 2
104
 
105
    return 0
106
}
107
 
108
proc test_initial_complaints { } {
109
 
110
    global gdb_prompt
111
 
112
    # Unsupress complaints
113
    gdb_test "set stop_whining = 2"
114
 
115
    # Prime the system
116
    gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
117
            "During symbol reading, Register a complaint."
118
 
119
    # Check that the complaint was inserted and where
120
    gdb_test "print symfile_complaints->root->fmt" \
121
            ".\[0-9\]+ =.*\"Register a complaint\""
122
 
123
    # Re-issue the first message #1
124
    gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
125
            "During symbol reading, Register a complaint."
126
 
127
    # Check that there is only one thing in the list
128
    gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
129
            ".\[0-9\]+ = 1" "list has one entry"
130
 
131
    # Add a second complaint, expect it
132
    gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
133
            "During symbol reading, Testing. Testing. Testing.."
134
 
135
    return 0
136
}
137
 
138
proc test_serial_complaints { } {
139
 
140
    global gdb_prompt
141
 
142
    gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
143
 
144
    # Prime the system
145
    send_gdb "call complaint (&symfile_complaints, \"serial line  1\")\n"
146
    gdb_expect {
147
        -re "During symbol reading...serial line  1...$gdb_prompt " {
148
            pass "serial line 1"
149
        }
150
        "$gdb_prompt" {
151
            fail "serial line  1"
152
        }
153
        timeout {
154
            fail "serial line  1 (timeout)"
155
        }
156
    }
157
 
158
    # Add a second complaint, expect it
159
    send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n"
160
    gdb_expect {
161
        -re "serial line 2...$gdb_prompt " {
162
            pass "serial line 2"
163
        }
164
        "$gdb_prompt" {
165
            fail "serial line 2"
166
        }
167
        timeout {
168
            fail "serial line 2 (timeout)"
169
        }
170
    }
171
 
172
    send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
173
    gdb_expect {
174
        -re "\r\n\r\n$gdb_prompt " {
175
            pass "serial end"
176
        }
177
        "$gdb_prompt" {
178
            fail "serial end"
179
        }
180
        timeout {
181
            fail "serial end (timeout)"
182
        }
183
    }
184
 
185
    return 0
186
}
187
 
188
# For short complaints, all are the same
189
 
190
proc test_short_complaints { } {
191
 
192
    global gdb_prompt
193
 
194
    gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
195
 
196
    # Prime the system
197
    send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n"
198
    gdb_expect {
199
        -re "short line 1...$gdb_prompt " {
200
            pass "short line 1"
201
        }
202
        "$gdb_prompt" {
203
            fail "short line 1"
204
        }
205
        timeout {
206
            fail "short line 1 (timeout)"
207
        }
208
    }
209
 
210
    # Add a second complaint, expect it
211
    send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n"
212
    gdb_expect {
213
        -re "short line 2...$gdb_prompt " {
214
            pass "short line 2"
215
        }
216
        "$gdb_prompt" {
217
            fail "short line 2"
218
        }
219
        timeout {
220
            fail "short line 2 (timeout)"
221
        }
222
    }
223
 
224
    send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
225
    gdb_expect {
226
        -re "\r\n\r\n$gdb_prompt " {
227
            pass "short end"
228
        }
229
        "$gdb_prompt" {
230
            fail "short end"
231
        }
232
        timeout {
233
            fail "short end (timeout)"
234
        }
235
    }
236
 
237
    return 0
238
}
239
 
240
# Check that nothing comes out when there haven't been any real
241
# complaints.  Note that each test is really checking the previous
242
# command.
243
 
244
proc test_empty_complaint { cmd msg } {
245
    global gdb_prompt
246
    send_gdb $cmd
247
    gdb_expect {
248
        -re "\r\n\r\n$gdb_prompt " {
249
            fail $msg
250
        }
251
        "\r\n$gdb_prompt" {
252
            pass $msg
253
        }
254
        timeout {
255
            fail "$msg (timeout)"
256
        }
257
    }
258
 
259
}
260
 
261
proc test_empty_complaints { } {
262
 
263
    test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)\n" \
264
            "empty non-verbose non-noisy clear"
265
    test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)\n" \
266
            "empty verbose non-noisy clear"
267
    test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)\n" \
268
            "empty verbose noisy clear"
269
    test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)\n" \
270
            "empty non-verbose noisy clear"
271
 
272
    return 0
273
}
274
 
275
# Find a pathname to a file that we would execute if the shell was asked
276
# to run $arg using the current PATH.
277
 
278
proc find_gdb { arg } {
279
 
280
    # If the arg directly specifies an existing executable file, then
281
    # simply use it.
282
 
283
    if [file executable $arg] then {
284
        return $arg
285
    }
286
 
287
    set result [which $arg]
288
    if [string match "/" [ string range $result 0 0 ]] then {
289
        return $result
290
    }
291
 
292
    # If everything fails, just return the unqualified pathname as default
293
    # and hope for best.
294
 
295
    return $arg
296
}
297
 
298
# Run the test with self.
299
# Copy the file executable file in case this OS doesn't like to edit its own
300
# text space.
301
 
302
set GDB_FULLPATH [find_gdb $GDB]
303
 
304
# Remove any old copy lying around.
305
remote_file host delete x$tool
306
 
307
gdb_start
308
 
309
set file [remote_download host $GDB_FULLPATH x$tool]
310
 
311
set setup_result [setup_test $file ]
312
if {$setup_result <0} then {
313
    return -1
314
}
315
 
316
test_initial_complaints
317
test_serial_complaints
318
test_short_complaints
319
test_empty_complaints
320
 
321
gdb_exit;
322
catch "remote_file host delete $file";

powered by: WebSVN 2.1.0

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