2012-02-02 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
CommitLineData
0b302171 1# Copyright 2002, 2004, 2007-2012 Free Software Foundation, Inc.
54951bd7
AC
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
54951bd7 6# (at your option) any later version.
e22f8b7c 7#
54951bd7
AC
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.
e22f8b7c 12#
54951bd7 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
54951bd7 15
54951bd7
AC
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
54951bd7
AC
20
21# are we on a target board
c1d88655 22if { [is_remote target] || ![isnative] } then {
54951bd7
AC
23 return
24}
25
26proc 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
3e3ffd2b 43
2db8e78e
MC
44 global gdb_file_cmd_debug_info
45 set gdb_file_cmd_debug_info "unset"
46
3e3ffd2b 47 set result [gdb_load $executable]
54951bd7
AC
48 set timeout $oldtimeout
49 verbose "Timeout is now $timeout seconds" 2
50
2db8e78e
MC
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."
3e3ffd2b
MC
57 return -1
58 }
59
54951bd7
AC
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"
a127f7b4 71 gdb_test_multiple "run -nw" "$description" {
54951bd7
AC
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 }
54951bd7
AC
90 }
91
92 set timeout $oldtimeout
93 verbose "Timeout is now $timeout seconds" 2
94
95 return 0
96}
97
9dd34b2b 98proc test_initial_complaints { } {
54951bd7
AC
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
128proc 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
a127f7b4
MS
135 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
136 -re "During symbol reading...serial line 1...$gdb_prompt $" {
54951bd7
AC
137 pass "serial line 1"
138 }
54951bd7
AC
139 }
140
141 # Add a second complaint, expect it
a127f7b4 142 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
54951bd7
AC
143 -re "serial line 2...$gdb_prompt " {
144 pass "serial line 2"
145 }
54951bd7
AC
146 }
147
a127f7b4 148 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
54951bd7
AC
149 -re "\r\n\r\n$gdb_prompt " {
150 pass "serial end"
151 }
54951bd7
AC
152 }
153
154 return 0
155}
156
157# For short complaints, all are the same
158
159proc 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
a127f7b4 166 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
54951bd7
AC
167 -re "short line 1...$gdb_prompt " {
168 pass "short line 1"
169 }
54951bd7
AC
170 }
171
172 # Add a second complaint, expect it
a127f7b4 173 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
54951bd7
AC
174 -re "short line 2...$gdb_prompt " {
175 pass "short line 2"
176 }
54951bd7
AC
177 }
178
a127f7b4 179 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
54951bd7
AC
180 -re "\r\n\r\n$gdb_prompt " {
181 pass "short end"
182 }
54951bd7
AC
183 }
184
185 return 0
186}
187
9dd34b2b
AC
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
192proc test_empty_complaint { cmd msg } {
193 global gdb_prompt
a127f7b4
MS
194 gdb_test_multiple $cmd $msg {
195 -re "\r\n\r\n$gdb_prompt $" {
9dd34b2b
AC
196 fail $msg
197 }
a127f7b4 198 "\r\n$gdb_prompt $" {
9dd34b2b
AC
199 pass $msg
200 }
9dd34b2b 201 }
9dd34b2b
AC
202}
203
204proc test_empty_complaints { } {
205
38979823 206 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
9dd34b2b 207 "empty non-verbose non-noisy clear"
38979823 208 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
9dd34b2b 209 "empty verbose non-noisy clear"
38979823 210 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
9dd34b2b 211 "empty verbose noisy clear"
38979823 212 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
9dd34b2b
AC
213 "empty non-verbose noisy clear"
214
215 return 0
216}
217
54951bd7
AC
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
221proc 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
245set GDB_FULLPATH [find_gdb $GDB]
246
247# Remove any old copy lying around.
248remote_file host delete x$tool
249
250gdb_start
251
252set file [remote_download host $GDB_FULLPATH x$tool]
253
254set setup_result [setup_test $file ]
255if {$setup_result <0} then {
256 return -1
257}
258
9dd34b2b 259test_initial_complaints
54951bd7
AC
260test_serial_complaints
261test_short_complaints
9dd34b2b 262test_empty_complaints
54951bd7
AC
263
264gdb_exit;
265catch "remote_file host delete $file";
This page took 1.409399 seconds and 4 git commands to generate.