]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.gdb/complaints.exp
run copyright.sh for 2011.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
1 # Copyright 2002, 2004, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
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/>.
16
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
21 if $tracelevel then {
22 strace $tracelevel
23 }
24
25
26 # are we on a target board
27 if { [is_remote target] || ![isnative] } then {
28 return
29 }
30
31 proc 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
48
49 global gdb_file_cmd_debug_info
50 set gdb_file_cmd_debug_info "unset"
51
52 set result [gdb_load $executable]
53 set timeout $oldtimeout
54 verbose "Timeout is now $timeout seconds" 2
55
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."
62 return -1
63 }
64
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"
76 gdb_test_multiple "run -nw" "$description" {
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 }
95 }
96
97 set timeout $oldtimeout
98 verbose "Timeout is now $timeout seconds" 2
99
100 return 0
101 }
102
103 proc test_initial_complaints { } {
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
133 proc 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
140 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
141 -re "During symbol reading...serial line 1...$gdb_prompt $" {
142 pass "serial line 1"
143 }
144 }
145
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 " {
149 pass "serial line 2"
150 }
151 }
152
153 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
154 -re "\r\n\r\n$gdb_prompt " {
155 pass "serial end"
156 }
157 }
158
159 return 0
160 }
161
162 # For short complaints, all are the same
163
164 proc 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
171 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
172 -re "short line 1...$gdb_prompt " {
173 pass "short line 1"
174 }
175 }
176
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 " {
180 pass "short line 2"
181 }
182 }
183
184 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
185 -re "\r\n\r\n$gdb_prompt " {
186 pass "short end"
187 }
188 }
189
190 return 0
191 }
192
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
197 proc test_empty_complaint { cmd msg } {
198 global gdb_prompt
199 gdb_test_multiple $cmd $msg {
200 -re "\r\n\r\n$gdb_prompt $" {
201 fail $msg
202 }
203 "\r\n$gdb_prompt $" {
204 pass $msg
205 }
206 }
207 }
208
209 proc test_empty_complaints { } {
210
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"
219
220 return 0
221 }
222
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
226 proc 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
250 set GDB_FULLPATH [find_gdb $GDB]
251
252 # Remove any old copy lying around.
253 remote_file host delete x$tool
254
255 gdb_start
256
257 set file [remote_download host $GDB_FULLPATH x$tool]
258
259 set setup_result [setup_test $file ]
260 if {$setup_result <0} then {
261 return -1
262 }
263
264 test_initial_complaints
265 test_serial_complaints
266 test_short_complaints
267 test_empty_complaints
268
269 gdb_exit;
270 catch "remote_file host delete $file";