]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.gdb/complaints.exp
run copyright.sh for 2011.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
CommitLineData
7b6bb8da
JB
1# Copyright 2002, 2004, 2007, 2008, 2009, 2010, 2011
2# Free Software Foundation, Inc.
54951bd7
AC
3
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
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
54951bd7 7# (at your option) any later version.
e22f8b7c 8#
54951bd7
AC
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.
e22f8b7c 13#
54951bd7 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
54951bd7 16
54951bd7
AC
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).
20
21if $tracelevel then {
22 strace $tracelevel
23}
24
54951bd7
AC
25
26# are we on a target board
c1d88655 27if { [is_remote target] || ![isnative] } then {
54951bd7
AC
28 return
29}
30
31proc setup_test { executable } {
32 global gdb_prompt
33 global timeout
34
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.
44
45 set oldtimeout $timeout
46 set timeout 600
47 verbose "Timeout is now $timeout seconds" 2
3e3ffd2b 48
2db8e78e
MC
49 global gdb_file_cmd_debug_info
50 set gdb_file_cmd_debug_info "unset"
51
3e3ffd2b 52 set result [gdb_load $executable]
54951bd7
AC
53 set timeout $oldtimeout
54 verbose "Timeout is now $timeout seconds" 2
55
2db8e78e
MC
56 if { $result != 0 } then {
57 return -1
58 }
59
60 if { $gdb_file_cmd_debug_info != "debug" } then {
61 untested "No debug information, skipping testcase."
3e3ffd2b
MC
62 return -1
63 }
64
54951bd7
AC
65 # Set a breakpoint at main
66 gdb_test "break captured_command_loop" \
67 "Breakpoint.*at.* file.*, line.*" \
68 "breakpoint in captured_command_loop"
69
70 # run yourself
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.
73 set timeout 600
74
75 set description "run until breakpoint at captured_command_loop"
a127f7b4 76 gdb_test_multiple "run -nw" "$description" {
54951bd7
AC
77 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
78 pass "$description"
79 }
80 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
81 xfail "$description (line numbers scrambled?)"
82 }
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
87 return -1
88 }
89 -re ".*$gdb_prompt $" {
90 fail "$description"
91 set timeout $oldtimeout
92 verbose "Timeout is now $timeout seconds" 2
93 return -1
94 }
54951bd7
AC
95 }
96
97 set timeout $oldtimeout
98 verbose "Timeout is now $timeout seconds" 2
99
100 return 0
101}
102
9dd34b2b 103proc test_initial_complaints { } {
54951bd7
AC
104
105 global gdb_prompt
106
107 # Unsupress complaints
108 gdb_test "set stop_whining = 2"
109
110 # Prime the system
111 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
112 "During symbol reading, Register a complaint."
113
114 # Check that the complaint was inserted and where
115 gdb_test "print symfile_complaints->root->fmt" \
116 ".\[0-9\]+ =.*\"Register a complaint\""
117
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."
121
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"
125
126 # Add a second complaint, expect it
127 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
128 "During symbol reading, Testing. Testing. Testing.."
129
130 return 0
131}
132
133proc test_serial_complaints { } {
134
135 global gdb_prompt
136
137 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
138
139 # Prime the system
a127f7b4
MS
140 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
141 -re "During symbol reading...serial line 1...$gdb_prompt $" {
54951bd7
AC
142 pass "serial line 1"
143 }
54951bd7
AC
144 }
145
146 # Add a second complaint, expect it
a127f7b4 147 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
54951bd7
AC
148 -re "serial line 2...$gdb_prompt " {
149 pass "serial line 2"
150 }
54951bd7
AC
151 }
152
a127f7b4 153 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
54951bd7
AC
154 -re "\r\n\r\n$gdb_prompt " {
155 pass "serial end"
156 }
54951bd7
AC
157 }
158
159 return 0
160}
161
162# For short complaints, all are the same
163
164proc test_short_complaints { } {
165
166 global gdb_prompt
167
168 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
169
170 # Prime the system
a127f7b4 171 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
54951bd7
AC
172 -re "short line 1...$gdb_prompt " {
173 pass "short line 1"
174 }
54951bd7
AC
175 }
176
177 # Add a second complaint, expect it
a127f7b4 178 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
54951bd7
AC
179 -re "short line 2...$gdb_prompt " {
180 pass "short line 2"
181 }
54951bd7
AC
182 }
183
a127f7b4 184 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
54951bd7
AC
185 -re "\r\n\r\n$gdb_prompt " {
186 pass "short end"
187 }
54951bd7
AC
188 }
189
190 return 0
191}
192
9dd34b2b
AC
193# Check that nothing comes out when there haven't been any real
194# complaints. Note that each test is really checking the previous
195# command.
196
197proc test_empty_complaint { cmd msg } {
198 global gdb_prompt
a127f7b4
MS
199 gdb_test_multiple $cmd $msg {
200 -re "\r\n\r\n$gdb_prompt $" {
9dd34b2b
AC
201 fail $msg
202 }
a127f7b4 203 "\r\n$gdb_prompt $" {
9dd34b2b
AC
204 pass $msg
205 }
9dd34b2b 206 }
9dd34b2b
AC
207}
208
209proc test_empty_complaints { } {
210
38979823 211 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
9dd34b2b 212 "empty non-verbose non-noisy clear"
38979823 213 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
9dd34b2b 214 "empty verbose non-noisy clear"
38979823 215 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
9dd34b2b 216 "empty verbose noisy clear"
38979823 217 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
9dd34b2b
AC
218 "empty non-verbose noisy clear"
219
220 return 0
221}
222
54951bd7
AC
223# Find a pathname to a file that we would execute if the shell was asked
224# to run $arg using the current PATH.
225
226proc find_gdb { arg } {
227
228 # If the arg directly specifies an existing executable file, then
229 # simply use it.
230
231 if [file executable $arg] then {
232 return $arg
233 }
234
235 set result [which $arg]
236 if [string match "/" [ string range $result 0 0 ]] then {
237 return $result
238 }
239
240 # If everything fails, just return the unqualified pathname as default
241 # and hope for best.
242
243 return $arg
244}
245
246# Run the test with self.
247# Copy the file executable file in case this OS doesn't like to edit its own
248# text space.
249
250set GDB_FULLPATH [find_gdb $GDB]
251
252# Remove any old copy lying around.
253remote_file host delete x$tool
254
255gdb_start
256
257set file [remote_download host $GDB_FULLPATH x$tool]
258
259set setup_result [setup_test $file ]
260if {$setup_result <0} then {
261 return -1
262}
263
9dd34b2b 264test_initial_complaints
54951bd7
AC
265test_serial_complaints
266test_short_complaints
9dd34b2b 267test_empty_complaints
54951bd7
AC
268
269gdb_exit;
270catch "remote_file host delete $file";