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 set result [gdb_load $executable]
53 set timeout $oldtimeout
54 verbose "Timeout is now $timeout seconds" 2
56 if { [lindex $result 0] != "" } then {
59 if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
60 untested "No debug information, skipping testcase."
65 # Set a breakpoint at main
66 gdb_test "break captured_command_loop" \
67 "Breakpoint.*at.* file.*, line.*" \
68 "breakpoint in captured_command_loop"
71 # It may take a very long time for the inferior gdb to start (lynx),
72 # so we bump it back up for the duration of this command.
75 set description "run until breakpoint at captured_command_loop"
78 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
81 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
82 xfail "$description (line numbers scrambled?)"
84 -re "vfork: No more processes.*$gdb_prompt $" {
85 fail "$description (out of virtual memory)"
86 set timeout $oldtimeout
87 verbose "Timeout is now $timeout seconds" 2
90 -re ".*$gdb_prompt $" {
92 set timeout $oldtimeout
93 verbose "Timeout is now $timeout seconds" 2
97 fail "$description (timeout)"
101 set timeout $oldtimeout
102 verbose "Timeout is now $timeout seconds" 2
107 proc test_initial_complaints { } {
111 # Unsupress complaints
112 gdb_test "set stop_whining = 2"
115 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
116 "During symbol reading, Register a complaint."
118 # Check that the complaint was inserted and where
119 gdb_test "print symfile_complaints->root->fmt" \
120 ".\[0-9\]+ =.*\"Register a complaint\""
122 # Re-issue the first message #1
123 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
124 "During symbol reading, Register a complaint."
126 # Check that there is only one thing in the list
127 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
128 ".\[0-9\]+ = 1" "list has one entry"
130 # Add a second complaint, expect it
131 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
132 "During symbol reading, Testing. Testing. Testing.."
137 proc test_serial_complaints { } {
141 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
144 send_gdb "call complaint (&symfile_complaints, \"serial line 1\")\n"
146 -re "During symbol reading...serial line 1...$gdb_prompt " {
153 fail "serial line 1 (timeout)"
157 # Add a second complaint, expect it
158 send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n"
160 -re "serial line 2...$gdb_prompt " {
167 fail "serial line 2 (timeout)"
171 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
173 -re "\r\n\r\n$gdb_prompt " {
180 fail "serial end (timeout)"
187 # For short complaints, all are the same
189 proc test_short_complaints { } {
193 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
196 send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n"
198 -re "short line 1...$gdb_prompt " {
205 fail "short line 1 (timeout)"
209 # Add a second complaint, expect it
210 send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n"
212 -re "short line 2...$gdb_prompt " {
219 fail "short line 2 (timeout)"
223 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
225 -re "\r\n\r\n$gdb_prompt " {
232 fail "short end (timeout)"
239 # Check that nothing comes out when there haven't been any real
240 # complaints. Note that each test is really checking the previous
243 proc test_empty_complaint { cmd msg } {
247 -re "\r\n\r\n$gdb_prompt " {
254 fail "$msg (timeout)"
260 proc test_empty_complaints { } {
262 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)\n" \
263 "empty non-verbose non-noisy clear"
264 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)\n" \
265 "empty verbose non-noisy clear"
266 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)\n" \
267 "empty verbose noisy clear"
268 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)\n" \
269 "empty non-verbose noisy clear"
274 # Find a pathname to a file that we would execute if the shell was asked
275 # to run $arg using the current PATH.
277 proc find_gdb { arg } {
279 # If the arg directly specifies an existing executable file, then
282 if [file executable $arg] then {
286 set result [which $arg]
287 if [string match "/" [ string range $result 0 0 ]] then {
291 # If everything fails, just return the unqualified pathname as default
297 # Run the test with self.
298 # Copy the file executable file in case this OS doesn't like to edit its own
301 set GDB_FULLPATH [find_gdb $GDB]
303 # Remove any old copy lying around.
304 remote_file host delete x$tool
308 set file [remote_download host $GDB_FULLPATH x$tool]
310 set setup_result [setup_test $file ]
311 if {$setup_result <0} then {
315 test_initial_complaints
316 test_serial_complaints
317 test_short_complaints
318 test_empty_complaints
321 catch "remote_file host delete $file";