1 # Copyright 2002-2013 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 if [target_info exists gdb,noinferiorio] {
27 verbose "Skipping because of no inferiorio capabilities."
31 proc setup_test { executable } {
34 global INTERNAL_GDBFLAGS
36 # load yourself into the debugger
37 # This can take a relatively long time, particularly for testing where
38 # the executable is being accessed over a network, or where gdb does not
39 # support partial symbols for a particular target and has to load the
40 # entire symbol table. Set the timeout to 10 minutes, which should be
41 # adequate for most environments (it *has* timed out with 5 min on a
42 # SPARCstation SLC under moderate load, so this isn't unreasonable).
43 # After gdb is started, set the timeout to 30 seconds for the duration
44 # of this test, and then back to the original value.
46 set oldtimeout $timeout
48 verbose "Timeout is now $timeout seconds" 2
50 global gdb_file_cmd_debug_info
51 set gdb_file_cmd_debug_info "unset"
53 set result [gdb_load $executable]
54 set timeout $oldtimeout
55 verbose "Timeout is now $timeout seconds" 2
57 if { $result != 0 } then {
61 if { $gdb_file_cmd_debug_info != "debug" } then {
62 untested "No debug information, skipping testcase."
66 # Set a breakpoint at main
67 gdb_test "break captured_command_loop" \
68 "Breakpoint.*at.* file.*, line.*" \
69 "breakpoint in captured_command_loop"
72 # It may take a very long time for the inferior gdb to start (lynx),
73 # so we bump it back up for the duration of this command.
76 set description "run until breakpoint at captured_command_loop"
77 gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
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
98 set timeout $oldtimeout
99 verbose "Timeout is now $timeout seconds" 2
104 proc test_initial_complaints { } {
108 # Unsupress complaints
109 gdb_test "set stop_whining = 2"
112 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
113 "During symbol reading, Register a complaint."
115 # Check that the complaint was inserted and where
116 gdb_test "print symfile_complaints->root->fmt" \
117 ".\[0-9\]+ =.*\"Register a complaint\""
119 # Re-issue the first message #1
120 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
121 "During symbol reading, Register a complaint."
123 # Check that there is only one thing in the list
124 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
125 ".\[0-9\]+ = 1" "list has one entry"
127 # Add a second complaint, expect it
128 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
129 "During symbol reading, Testing. Testing. Testing.."
134 proc test_serial_complaints { } {
138 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
141 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
142 -re "During symbol reading...serial line 1...$gdb_prompt $" {
147 # Add a second complaint, expect it
148 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
149 -re "serial line 2...$gdb_prompt " {
154 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
155 -re "\r\n\r\n$gdb_prompt " {
163 # For short complaints, all are the same
165 proc test_short_complaints { } {
169 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
172 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
173 -re "short line 1...$gdb_prompt " {
178 # Add a second complaint, expect it
179 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
180 -re "short line 2...$gdb_prompt " {
185 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
186 -re "\r\n\r\n$gdb_prompt " {
194 # Check that nothing comes out when there haven't been any real
195 # complaints. Note that each test is really checking the previous
198 proc test_empty_complaint { cmd msg } {
200 gdb_test_multiple $cmd $msg {
201 -re "\r\n\r\n$gdb_prompt $" {
204 "\r\n$gdb_prompt $" {
210 proc test_empty_complaints { } {
212 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
213 "empty non-verbose non-noisy clear"
214 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
215 "empty verbose non-noisy clear"
216 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
217 "empty verbose noisy clear"
218 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
219 "empty non-verbose noisy clear"
224 # Find a pathname to a file that we would execute if the shell was asked
225 # to run $arg using the current PATH.
227 proc find_gdb { arg } {
229 # If the arg directly specifies an existing executable file, then
232 if [file executable $arg] then {
236 set result [which $arg]
237 if [string match "/" [ string range $result 0 0 ]] then {
241 # If everything fails, just return the unqualified pathname as default
247 # Run the test with self.
248 # Copy the file executable file in case this OS doesn't like to edit its own
251 set GDB_FULLPATH [find_gdb $GDB]
253 # Remove any old copy lying around.
254 remote_file host delete x$tool
258 set file [remote_download host $GDB_FULLPATH x$tool]
260 set setup_result [setup_test $file ]
261 if {$setup_result <0} then {
265 test_initial_complaints
266 test_serial_complaints
267 test_short_complaints
268 test_empty_complaints
271 catch "remote_file host delete $file";