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).
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"
75 gdb_test_multiple "run -nw" "$description" {
76 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
79 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
80 xfail "$description (line numbers scrambled?)"
82 -re "vfork: No more processes.*$gdb_prompt $" {
83 fail "$description (out of virtual memory)"
84 set timeout $oldtimeout
85 verbose "Timeout is now $timeout seconds" 2
88 -re ".*$gdb_prompt $" {
90 set timeout $oldtimeout
91 verbose "Timeout is now $timeout seconds" 2
96 set timeout $oldtimeout
97 verbose "Timeout is now $timeout seconds" 2
102 proc test_initial_complaints { } {
106 # Unsupress complaints
107 gdb_test "set stop_whining = 2"
110 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
111 "During symbol reading, Register a complaint."
113 # Check that the complaint was inserted and where
114 gdb_test "print symfile_complaints->root->fmt" \
115 ".\[0-9\]+ =.*\"Register a complaint\""
117 # Re-issue the first message #1
118 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
119 "During symbol reading, Register a complaint."
121 # Check that there is only one thing in the list
122 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
123 ".\[0-9\]+ = 1" "list has one entry"
125 # Add a second complaint, expect it
126 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
127 "During symbol reading, Testing. Testing. Testing.."
132 proc test_serial_complaints { } {
136 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
139 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
140 -re "During symbol reading...serial line 1...$gdb_prompt $" {
145 # Add a second complaint, expect it
146 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
147 -re "serial line 2...$gdb_prompt " {
152 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
153 -re "\r\n\r\n$gdb_prompt " {
161 # For short complaints, all are the same
163 proc test_short_complaints { } {
167 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
170 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
171 -re "short line 1...$gdb_prompt " {
176 # Add a second complaint, expect it
177 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
178 -re "short line 2...$gdb_prompt " {
183 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
184 -re "\r\n\r\n$gdb_prompt " {
192 # Check that nothing comes out when there haven't been any real
193 # complaints. Note that each test is really checking the previous
196 proc test_empty_complaint { cmd msg } {
198 gdb_test_multiple $cmd $msg {
199 -re "\r\n\r\n$gdb_prompt $" {
202 "\r\n$gdb_prompt $" {
208 proc test_empty_complaints { } {
210 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
211 "empty non-verbose non-noisy clear"
212 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
213 "empty verbose non-noisy clear"
214 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
215 "empty verbose noisy clear"
216 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
217 "empty non-verbose noisy clear"
222 # Find a pathname to a file that we would execute if the shell was asked
223 # to run $arg using the current PATH.
225 proc find_gdb { arg } {
227 # If the arg directly specifies an existing executable file, then
230 if [file executable $arg] then {
234 set result [which $arg]
235 if [string match "/" [ string range $result 0 0 ]] then {
239 # If everything fails, just return the unqualified pathname as default
245 # Run the test with self.
246 # Copy the file executable file in case this OS doesn't like to edit its own
249 set GDB_FULLPATH [find_gdb $GDB]
251 # Remove any old copy lying around.
252 remote_file host delete x$tool
256 set file [remote_download host $GDB_FULLPATH x$tool]
258 set setup_result [setup_test $file ]
259 if {$setup_result <0} then {
263 test_initial_complaints
264 test_serial_complaints
265 test_short_complaints
266 test_empty_complaints
269 catch "remote_file host delete $file";