2012-01-16 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
1 # Copyright 2002, 2004, 2007-2012 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
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).
19
20
21 # are we on a target board
22 if { [is_remote target] || ![isnative] } then {
23 return
24 }
25
26 proc setup_test { executable } {
27 global gdb_prompt
28 global timeout
29
30 # load yourself into the debugger
31 # This can take a relatively long time, particularly for testing where
32 # the executable is being accessed over a network, or where gdb does not
33 # support partial symbols for a particular target and has to load the
34 # entire symbol table. Set the timeout to 10 minutes, which should be
35 # adequate for most environments (it *has* timed out with 5 min on a
36 # SPARCstation SLC under moderate load, so this isn't unreasonable).
37 # After gdb is started, set the timeout to 30 seconds for the duration
38 # of this test, and then back to the original value.
39
40 set oldtimeout $timeout
41 set timeout 600
42 verbose "Timeout is now $timeout seconds" 2
43
44 global gdb_file_cmd_debug_info
45 set gdb_file_cmd_debug_info "unset"
46
47 set result [gdb_load $executable]
48 set timeout $oldtimeout
49 verbose "Timeout is now $timeout seconds" 2
50
51 if { $result != 0 } then {
52 return -1
53 }
54
55 if { $gdb_file_cmd_debug_info != "debug" } then {
56 untested "No debug information, skipping testcase."
57 return -1
58 }
59
60 # Set a breakpoint at main
61 gdb_test "break captured_command_loop" \
62 "Breakpoint.*at.* file.*, line.*" \
63 "breakpoint in captured_command_loop"
64
65 # run yourself
66 # It may take a very long time for the inferior gdb to start (lynx),
67 # so we bump it back up for the duration of this command.
68 set timeout 600
69
70 set description "run until breakpoint at captured_command_loop"
71 gdb_test_multiple "run -nw" "$description" {
72 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
73 pass "$description"
74 }
75 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
76 xfail "$description (line numbers scrambled?)"
77 }
78 -re "vfork: No more processes.*$gdb_prompt $" {
79 fail "$description (out of virtual memory)"
80 set timeout $oldtimeout
81 verbose "Timeout is now $timeout seconds" 2
82 return -1
83 }
84 -re ".*$gdb_prompt $" {
85 fail "$description"
86 set timeout $oldtimeout
87 verbose "Timeout is now $timeout seconds" 2
88 return -1
89 }
90 }
91
92 set timeout $oldtimeout
93 verbose "Timeout is now $timeout seconds" 2
94
95 return 0
96 }
97
98 proc test_initial_complaints { } {
99
100 global gdb_prompt
101
102 # Unsupress complaints
103 gdb_test "set stop_whining = 2"
104
105 # Prime the system
106 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
107 "During symbol reading, Register a complaint."
108
109 # Check that the complaint was inserted and where
110 gdb_test "print symfile_complaints->root->fmt" \
111 ".\[0-9\]+ =.*\"Register a complaint\""
112
113 # Re-issue the first message #1
114 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
115 "During symbol reading, Register a complaint."
116
117 # Check that there is only one thing in the list
118 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
119 ".\[0-9\]+ = 1" "list has one entry"
120
121 # Add a second complaint, expect it
122 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
123 "During symbol reading, Testing. Testing. Testing.."
124
125 return 0
126 }
127
128 proc test_serial_complaints { } {
129
130 global gdb_prompt
131
132 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
133
134 # Prime the system
135 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
136 -re "During symbol reading...serial line 1...$gdb_prompt $" {
137 pass "serial line 1"
138 }
139 }
140
141 # Add a second complaint, expect it
142 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
143 -re "serial line 2...$gdb_prompt " {
144 pass "serial line 2"
145 }
146 }
147
148 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
149 -re "\r\n\r\n$gdb_prompt " {
150 pass "serial end"
151 }
152 }
153
154 return 0
155 }
156
157 # For short complaints, all are the same
158
159 proc test_short_complaints { } {
160
161 global gdb_prompt
162
163 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
164
165 # Prime the system
166 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
167 -re "short line 1...$gdb_prompt " {
168 pass "short line 1"
169 }
170 }
171
172 # Add a second complaint, expect it
173 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
174 -re "short line 2...$gdb_prompt " {
175 pass "short line 2"
176 }
177 }
178
179 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
180 -re "\r\n\r\n$gdb_prompt " {
181 pass "short end"
182 }
183 }
184
185 return 0
186 }
187
188 # Check that nothing comes out when there haven't been any real
189 # complaints. Note that each test is really checking the previous
190 # command.
191
192 proc test_empty_complaint { cmd msg } {
193 global gdb_prompt
194 gdb_test_multiple $cmd $msg {
195 -re "\r\n\r\n$gdb_prompt $" {
196 fail $msg
197 }
198 "\r\n$gdb_prompt $" {
199 pass $msg
200 }
201 }
202 }
203
204 proc test_empty_complaints { } {
205
206 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
207 "empty non-verbose non-noisy clear"
208 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
209 "empty verbose non-noisy clear"
210 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
211 "empty verbose noisy clear"
212 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
213 "empty non-verbose noisy clear"
214
215 return 0
216 }
217
218 # Find a pathname to a file that we would execute if the shell was asked
219 # to run $arg using the current PATH.
220
221 proc find_gdb { arg } {
222
223 # If the arg directly specifies an existing executable file, then
224 # simply use it.
225
226 if [file executable $arg] then {
227 return $arg
228 }
229
230 set result [which $arg]
231 if [string match "/" [ string range $result 0 0 ]] then {
232 return $result
233 }
234
235 # If everything fails, just return the unqualified pathname as default
236 # and hope for best.
237
238 return $arg
239 }
240
241 # Run the test with self.
242 # Copy the file executable file in case this OS doesn't like to edit its own
243 # text space.
244
245 set GDB_FULLPATH [find_gdb $GDB]
246
247 # Remove any old copy lying around.
248 remote_file host delete x$tool
249
250 gdb_start
251
252 set file [remote_download host $GDB_FULLPATH x$tool]
253
254 set setup_result [setup_test $file ]
255 if {$setup_result <0} then {
256 return -1
257 }
258
259 test_initial_complaints
260 test_serial_complaints
261 test_short_complaints
262 test_empty_complaints
263
264 gdb_exit;
265 catch "remote_file host delete $file";
This page took 0.035019 seconds and 4 git commands to generate.