1 # Copyright 2002, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
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.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
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).
25 # are we on a target board
26 if { [is_remote target] || ![isnative] } then {
30 proc setup_test { executable } {
34 # load yourself into the debugger
35 # This can take a relatively long time, particularly for testing where
36 # the executable is being accessed over a network, or where gdb does not
37 # support partial symbols for a particular target and has to load the
38 # entire symbol table. Set the timeout to 10 minutes, which should be
39 # adequate for most environments (it *has* timed out with 5 min on a
40 # SPARCstation SLC under moderate load, so this isn't unreasonable).
41 # After gdb is started, set the timeout to 30 seconds for the duration
42 # of this test, and then back to the original value.
44 set oldtimeout $timeout
46 verbose "Timeout is now $timeout seconds" 2
48 global gdb_file_cmd_debug_info
49 set gdb_file_cmd_debug_info "unset"
51 set result [gdb_load $executable]
52 set timeout $oldtimeout
53 verbose "Timeout is now $timeout seconds" 2
55 if { $result != 0 } then {
59 if { $gdb_file_cmd_debug_info != "debug" } then {
60 untested "No debug information, skipping testcase."
64 # Set a breakpoint at main
65 gdb_test "break captured_command_loop" \
66 "Breakpoint.*at.* file.*, line.*" \
67 "breakpoint in captured_command_loop"
70 # It may take a very long time for the inferior gdb to start (lynx),
71 # so we bump it back up for the duration of this command.
74 set description "run until breakpoint at captured_command_loop"
77 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
80 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
81 xfail "$description (line numbers scrambled?)"
83 -re "vfork: No more processes.*$gdb_prompt $" {
84 fail "$description (out of virtual memory)"
85 set timeout $oldtimeout
86 verbose "Timeout is now $timeout seconds" 2
89 -re ".*$gdb_prompt $" {
91 set timeout $oldtimeout
92 verbose "Timeout is now $timeout seconds" 2
96 fail "$description (timeout)"
100 set timeout $oldtimeout
101 verbose "Timeout is now $timeout seconds" 2
106 proc test_initial_complaints { } {
110 # Unsupress complaints
111 gdb_test "set stop_whining = 2"
114 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
115 "During symbol reading, Register a complaint."
117 # Check that the complaint was inserted and where
118 gdb_test "print symfile_complaints->root->fmt" \
119 ".\[0-9\]+ =.*\"Register a complaint\""
121 # Re-issue the first message #1
122 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
123 "During symbol reading, Register a complaint."
125 # Check that there is only one thing in the list
126 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
127 ".\[0-9\]+ = 1" "list has one entry"
129 # Add a second complaint, expect it
130 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
131 "During symbol reading, Testing. Testing. Testing.."
136 proc test_serial_complaints { } {
140 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
143 send_gdb "call complaint (&symfile_complaints, \"serial line 1\")\n"
145 -re "During symbol reading...serial line 1...$gdb_prompt " {
152 fail "serial line 1 (timeout)"
156 # Add a second complaint, expect it
157 send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n"
159 -re "serial line 2...$gdb_prompt " {
166 fail "serial line 2 (timeout)"
170 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
172 -re "\r\n\r\n$gdb_prompt " {
179 fail "serial end (timeout)"
186 # For short complaints, all are the same
188 proc test_short_complaints { } {
192 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
195 send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n"
197 -re "short line 1...$gdb_prompt " {
204 fail "short line 1 (timeout)"
208 # Add a second complaint, expect it
209 send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n"
211 -re "short line 2...$gdb_prompt " {
218 fail "short line 2 (timeout)"
222 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
224 -re "\r\n\r\n$gdb_prompt " {
231 fail "short end (timeout)"
238 # Check that nothing comes out when there haven't been any real
239 # complaints. Note that each test is really checking the previous
242 proc test_empty_complaint { cmd msg } {
246 -re "\r\n\r\n$gdb_prompt " {
253 fail "$msg (timeout)"
259 proc test_empty_complaints { } {
261 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)\n" \
262 "empty non-verbose non-noisy clear"
263 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)\n" \
264 "empty verbose non-noisy clear"
265 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)\n" \
266 "empty verbose noisy clear"
267 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)\n" \
268 "empty non-verbose noisy clear"
273 # Find a pathname to a file that we would execute if the shell was asked
274 # to run $arg using the current PATH.
276 proc find_gdb { arg } {
278 # If the arg directly specifies an existing executable file, then
281 if [file executable $arg] then {
285 set result [which $arg]
286 if [string match "/" [ string range $result 0 0 ]] then {
290 # If everything fails, just return the unqualified pathname as default
296 # Run the test with self.
297 # Copy the file executable file in case this OS doesn't like to edit its own
300 set GDB_FULLPATH [find_gdb $GDB]
302 # Remove any old copy lying around.
303 remote_file host delete x$tool
307 set file [remote_download host $GDB_FULLPATH x$tool]
309 set setup_result [setup_test $file ]
310 if {$setup_result <0} then {
314 test_initial_complaints
315 test_serial_complaints
316 test_short_complaints
317 test_empty_complaints
320 catch "remote_file host delete $file";