2 # Free Software Foundation
, Inc.
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.
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.
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.
18 # This file was written by Andrew Cagney
(cagney at redhat dot com
),
19 # derived from xfullpath.exp
(written by Joel Brobecker
), derived from
20 # selftest.exp
(written by Rob Savoye
).
29 # are we
on a target board
30 if [is_remote target
] {
34 proc setup_test
{ executable
} {
38 #
load yourself into the debugger
39 # This can take a relatively long time
, particularly
for testing where
40 # the executable is being accessed over a network
, or where gdb does not
41 # support partial symbols
for a particular target and has to
load the
42 # entire symbol table.
Set the timeout to
10 minutes
, which should be
43 # adequate
for most environments
(it
*has
* timed out with
5 min on a
44 # SPARCstation SLC under moderate
load, so this isn
't unreasonable).
45 # After gdb is started, set the timeout to 30 seconds for the duration
46 # of this test, and then back to the original value.
48 set oldtimeout $timeout
50 verbose "Timeout is now $timeout seconds" 2
52 global gdb_file_cmd_debug_info
53 set gdb_file_cmd_debug_info "unset"
55 set result [gdb_load $executable]
56 set timeout $oldtimeout
57 verbose "Timeout is now $timeout seconds" 2
59 if { $result != 0 } then {
63 if { $gdb_file_cmd_debug_info != "debug" } then {
64 untested "No debug information, skipping testcase."
68 # Set a breakpoint at main
69 gdb_test "break captured_command_loop" \
70 "Breakpoint.*at.* file.*, line.*" \
71 "breakpoint in captured_command_loop"
74 # It may take a very long time for the inferior gdb to start (lynx),
75 # so we bump it back up for the duration of this command.
78 set description "run until breakpoint at captured_command_loop"
81 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
84 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
85 xfail "$description (line numbers scrambled?)"
87 -re "vfork: No more processes.*$gdb_prompt $" {
88 fail "$description (out of virtual memory)"
89 set timeout $oldtimeout
90 verbose "Timeout is now $timeout seconds" 2
93 -re ".*$gdb_prompt $" {
95 set timeout $oldtimeout
96 verbose "Timeout is now $timeout seconds" 2
100 fail "$description (timeout)"
104 set timeout $oldtimeout
105 verbose "Timeout is now $timeout seconds" 2
110 proc test_initial_complaints { } {
114 # Unsupress complaints
115 gdb_test "set stop_whining = 2"
118 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
119 "During symbol reading, Register a complaint."
121 # Check that the complaint was inserted and where
122 gdb_test "print symfile_complaints->root->fmt" \
123 ".\[0-9\]+ =.*\"Register a complaint\""
125 # Re-issue the first message #1
126 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
127 "During symbol reading, Register a complaint."
129 # Check that there is only one thing in the list
130 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
131 ".\[0-9\]+ = 1" "list has one entry"
133 # Add a second complaint, expect it
134 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
135 "During symbol reading, Testing. Testing. Testing.."
140 proc test_serial_complaints { } {
144 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
147 send_gdb "call complaint (&symfile_complaints, \"serial line 1\")\n"
149 -re "During symbol reading...serial line 1...$gdb_prompt " {
156 fail "serial line 1 (timeout)"
160 # Add a second complaint, expect it
161 send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n"
163 -re "serial line 2...$gdb_prompt " {
170 fail "serial line 2 (timeout)"
174 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
176 -re "\r\n\r\n$gdb_prompt " {
183 fail "serial end (timeout)"
190 # For short complaints, all are the same
192 proc test_short_complaints { } {
196 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
199 send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n"
201 -re "short line 1...$gdb_prompt " {
208 fail "short line 1 (timeout)"
212 # Add a second complaint, expect it
213 send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n"
215 -re "short line 2...$gdb_prompt " {
222 fail "short line 2 (timeout)"
226 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
228 -re "\r\n\r\n$gdb_prompt " {
235 fail "short end (timeout)"
242 # Check that nothing comes out when there haven't been
any real
243 # complaints. Note that each test is really checking the previous
246 proc test_empty_complaint
{ cmd msg
} {
250 -re
"\r\n\r\n$gdb_prompt " {
257 fail
"$msg (timeout)"
263 proc test_empty_complaints
{ } {
265 test_empty_complaint
"call clear_complaints(&symfile_complaints,0,0)\n" \
266 "empty non-verbose non-noisy clear"
267 test_empty_complaint
"call clear_complaints(&symfile_complaints,1,0)\n" \
268 "empty verbose non-noisy clear"
269 test_empty_complaint
"call clear_complaints(&symfile_complaints,1,1)\n" \
270 "empty verbose noisy clear"
271 test_empty_complaint
"call clear_complaints(&symfile_complaints,0,1)\n" \
272 "empty non-verbose noisy clear"
277 # Find a pathname to a file that we would
execute if the
shell was asked
278 # to run $
arg using the current PATH.
280 proc find_gdb
{ arg } {
282 #
If the
arg directly specifies an existing executable file
, then
285 if [file executable $
arg] then {
289 set result
[which $
arg]
290 if [string match
"/" [ string range $result 0 0 ]] then {
294 #
If everything fails
, just
return the unqualified pathname as default
300 # Run the test with self.
301 # Copy the file executable file in case this OS doesn
't like to edit its own
304 set GDB_FULLPATH [find_gdb $GDB]
306 # Remove any old copy lying around.
307 remote_file host delete x$tool
311 set file [remote_download host $GDB_FULLPATH x$tool]
313 set setup_result [setup_test $file ]
314 if {$setup_result <0} then {
318 test_initial_complaints
319 test_serial_complaints
320 test_short_complaints
321 test_empty_complaints
324 catch "remote_file host delete $file";