1 # Copyright 2002, 2004, 2007-2012 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).
21 # are we on a target board
22 if { [is_remote target] || ![isnative] } then {
26 proc setup_test { executable } {
30 # load yourself into the debugger
31 # This can take a relatively long time, particularly for testing where
32 # the executable is being accessed over a network, or where gdb does not
33 # support partial symbols for a particular target and has to load the
34 # entire symbol table. Set the timeout to 10 minutes, which should be
35 # adequate for most environments (it *has* timed out with 5 min on a
36 # SPARCstation SLC under moderate load, so this isn't unreasonable).
37 # After gdb is started, set the timeout to 30 seconds for the duration
38 # of this test, and then back to the original value.
40 set oldtimeout $timeout
42 verbose "Timeout is now $timeout seconds" 2
44 global gdb_file_cmd_debug_info
45 set gdb_file_cmd_debug_info "unset"
47 set result [gdb_load $executable]
48 set timeout $oldtimeout
49 verbose "Timeout is now $timeout seconds" 2
51 if { $result != 0 } then {
55 if { $gdb_file_cmd_debug_info != "debug" } then {
56 untested "No debug information, skipping testcase."
60 # Set a breakpoint at main
61 gdb_test "break captured_command_loop" \
62 "Breakpoint.*at.* file.*, line.*" \
63 "breakpoint in captured_command_loop"
66 # It may take a very long time for the inferior gdb to start (lynx),
67 # so we bump it back up for the duration of this command.
70 set description "run until breakpoint at captured_command_loop"
71 gdb_test_multiple "run -nw" "$description" {
72 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
75 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
76 xfail "$description (line numbers scrambled?)"
78 -re "vfork: No more processes.*$gdb_prompt $" {
79 fail "$description (out of virtual memory)"
80 set timeout $oldtimeout
81 verbose "Timeout is now $timeout seconds" 2
84 -re ".*$gdb_prompt $" {
86 set timeout $oldtimeout
87 verbose "Timeout is now $timeout seconds" 2
92 set timeout $oldtimeout
93 verbose "Timeout is now $timeout seconds" 2
98 proc test_initial_complaints { } {
102 # Unsupress complaints
103 gdb_test "set stop_whining = 2"
106 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
107 "During symbol reading, Register a complaint."
109 # Check that the complaint was inserted and where
110 gdb_test "print symfile_complaints->root->fmt" \
111 ".\[0-9\]+ =.*\"Register a complaint\""
113 # Re-issue the first message #1
114 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
115 "During symbol reading, Register a complaint."
117 # Check that there is only one thing in the list
118 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
119 ".\[0-9\]+ = 1" "list has one entry"
121 # Add a second complaint, expect it
122 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
123 "During symbol reading, Testing. Testing. Testing.."
128 proc test_serial_complaints { } {
132 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
135 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
136 -re "During symbol reading...serial line 1...$gdb_prompt $" {
141 # Add a second complaint, expect it
142 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
143 -re "serial line 2...$gdb_prompt " {
148 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
149 -re "\r\n\r\n$gdb_prompt " {
157 # For short complaints, all are the same
159 proc test_short_complaints { } {
163 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
166 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
167 -re "short line 1...$gdb_prompt " {
172 # Add a second complaint, expect it
173 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
174 -re "short line 2...$gdb_prompt " {
179 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
180 -re "\r\n\r\n$gdb_prompt " {
188 # Check that nothing comes out when there haven't been any real
189 # complaints. Note that each test is really checking the previous
192 proc test_empty_complaint { cmd msg } {
194 gdb_test_multiple $cmd $msg {
195 -re "\r\n\r\n$gdb_prompt $" {
198 "\r\n$gdb_prompt $" {
204 proc test_empty_complaints { } {
206 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
207 "empty non-verbose non-noisy clear"
208 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
209 "empty verbose non-noisy clear"
210 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
211 "empty verbose noisy clear"
212 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
213 "empty non-verbose noisy clear"
218 # Find a pathname to a file that we would execute if the shell was asked
219 # to run $arg using the current PATH.
221 proc find_gdb { arg } {
223 # If the arg directly specifies an existing executable file, then
226 if [file executable $arg] then {
230 set result [which $arg]
231 if [string match "/" [ string range $result 0 0 ]] then {
235 # If everything fails, just return the unqualified pathname as default
241 # Run the test with self.
242 # Copy the file executable file in case this OS doesn't like to edit its own
245 set GDB_FULLPATH [find_gdb $GDB]
247 # Remove any old copy lying around.
248 remote_file host delete x$tool
252 set file [remote_download host $GDB_FULLPATH x$tool]
254 set setup_result [setup_test $file ]
255 if {$setup_result <0} then {
259 test_initial_complaints
260 test_serial_complaints
261 test_short_complaints
262 test_empty_complaints
265 catch "remote_file host delete $file";