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