1 # Copyright 2002, 2004, 2007, 2008, 2009, 2010, 2011
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 3 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, see <http://www.gnu.org/licenses/>.
17 # This file was written by Andrew Cagney (cagney at redhat dot com),
18 # derived from xfullpath.exp (written by Joel Brobecker), derived from
19 # selftest.exp (written by Rob Savoye).
26 # are we on a target board
27 if { [is_remote target] || ![isnative] } then {
31 proc setup_test { executable } {
35 # load yourself into the debugger
36 # This can take a relatively long time, particularly for testing where
37 # the executable is being accessed over a network, or where gdb does not
38 # support partial symbols for a particular target and has to load the
39 # entire symbol table. Set the timeout to 10 minutes, which should be
40 # adequate for most environments (it *has* timed out with 5 min on a
41 # SPARCstation SLC under moderate load, so this isn't unreasonable).
42 # After gdb is started, set the timeout to 30 seconds for the duration
43 # of this test, and then back to the original value.
45 set oldtimeout $timeout
47 verbose "Timeout is now $timeout seconds" 2
49 global gdb_file_cmd_debug_info
50 set gdb_file_cmd_debug_info "unset"
52 set result [gdb_load $executable]
53 set timeout $oldtimeout
54 verbose "Timeout is now $timeout seconds" 2
56 if { $result != 0 } then {
60 if { $gdb_file_cmd_debug_info != "debug" } then {
61 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"
76 gdb_test_multiple "run -nw" "$description" {
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
97 set timeout $oldtimeout
98 verbose "Timeout is now $timeout seconds" 2
103 proc test_initial_complaints { } {
107 # Unsupress complaints
108 gdb_test "set stop_whining = 2"
111 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
112 "During symbol reading, Register a complaint."
114 # Check that the complaint was inserted and where
115 gdb_test "print symfile_complaints->root->fmt" \
116 ".\[0-9\]+ =.*\"Register a complaint\""
118 # Re-issue the first message #1
119 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
120 "During symbol reading, Register a complaint."
122 # Check that there is only one thing in the list
123 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
124 ".\[0-9\]+ = 1" "list has one entry"
126 # Add a second complaint, expect it
127 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
128 "During symbol reading, Testing. Testing. Testing.."
133 proc test_serial_complaints { } {
137 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
140 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
141 -re "During symbol reading...serial line 1...$gdb_prompt $" {
146 # Add a second complaint, expect it
147 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
148 -re "serial line 2...$gdb_prompt " {
153 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
154 -re "\r\n\r\n$gdb_prompt " {
162 # For short complaints, all are the same
164 proc test_short_complaints { } {
168 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
171 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
172 -re "short line 1...$gdb_prompt " {
177 # Add a second complaint, expect it
178 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
179 -re "short line 2...$gdb_prompt " {
184 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
185 -re "\r\n\r\n$gdb_prompt " {
193 # Check that nothing comes out when there haven't been any real
194 # complaints. Note that each test is really checking the previous
197 proc test_empty_complaint { cmd msg } {
199 gdb_test_multiple $cmd $msg {
200 -re "\r\n\r\n$gdb_prompt $" {
203 "\r\n$gdb_prompt $" {
209 proc test_empty_complaints { } {
211 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
212 "empty non-verbose non-noisy clear"
213 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
214 "empty verbose non-noisy clear"
215 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
216 "empty verbose noisy clear"
217 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
218 "empty non-verbose noisy clear"
223 # Find a pathname to a file that we would execute if the shell was asked
224 # to run $arg using the current PATH.
226 proc find_gdb { arg } {
228 # If the arg directly specifies an existing executable file, then
231 if [file executable $arg] then {
235 set result [which $arg]
236 if [string match "/" [ string range $result 0 0 ]] then {
240 # If everything fails, just return the unqualified pathname as default
246 # Run the test with self.
247 # Copy the file executable file in case this OS doesn't like to edit its own
250 set GDB_FULLPATH [find_gdb $GDB]
252 # Remove any old copy lying around.
253 remote_file host delete x$tool
257 set file [remote_download host $GDB_FULLPATH x$tool]
259 set setup_result [setup_test $file ]
260 if {$setup_result <0} then {
264 test_initial_complaints
265 test_serial_complaints
266 test_short_complaints
267 test_empty_complaints
270 catch "remote_file host delete $file";