Clean up "Reading symbols" output
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dbx.exp
CommitLineData
e2882c85 1# Copyright 1998-2018 Free Software Foundation, Inc.
74cf1395
JM
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
74cf1395
JM
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
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
74cf1395 15
74cf1395 16
f76495c8 17standard_testfile average.c sum.c
74cf1395 18
f76495c8
TT
19if {[build_executable $testfile.exp $testfile \
20 [list $srcfile $srcfile2] debug] == -1} {
5b362f04 21 untested "failed to compile"
f76495c8 22 return -1
74cf1395
JM
23}
24
25#
26# start gdb -- start gdb running, default procedure
27#
28proc dbx_gdb_start { } {
29 global verbose
30 global GDB
6b8ce727 31 global INTERNAL_GDBFLAGS GDBFLAGS
74cf1395
JM
32 global prompt
33 global spawn_id
34 global timeout
6b8ce727 35 verbose "Spawning $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS"
74cf1395
JM
36
37 if { [which $GDB] == 0 } then {
38 perror "$GDB does not exist."
39 exit 1
40 }
41
42 set oldtimeout $timeout
43 set timeout [expr "$timeout + 60"]
6b8ce727 44 eval "spawn $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS"
74cf1395
JM
45 gdb_expect {
46 -re ".*\r\n$gdb_prompt $" {
47 verbose "GDB initialized."
48 }
49 -re "$prompt $" {
50 perror "GDB never initialized."
51 return -1
52 }
53 timeout {
54 perror "(timeout) GDB never initialized."
55 return -1
56 }
57 }
58 set timeout $oldtimeout
59 # force the height to "unlimited", so no pagers get used
60 send_gdb "set height 0\n"
61 gdb_expect {
62 -re ".*$prompt $" {
63 verbose "Setting height to 0." 2
64 }
65 timeout {
66 warning "Couldn't set the height to 0."
67 }
68 }
69 # force the width to "unlimited", so no wraparound occurs
70 send_gdb "set width 0\n"
71 gdb_expect {
72 -re ".*$prompt $" {
73 verbose "Setting width to 0." 2
74 }
75 timeout {
76 warning "Couldn't set the width to 0."
77 }
78 }
79}
80
81
82proc dbx_reinitialize_dir { subdir } {
83 global gdb_prompt
84
85 send_gdb "use\n"
86 gdb_expect {
87 -re "Reinitialize source path to empty.*y or n. " {
88 send_gdb "y\n"
89 gdb_expect {
90 -re "Source directories searched.*$gdb_prompt $" {
91 send_gdb "use $subdir\n"
92 gdb_expect {
93 -re "Source directories searched.*$gdb_prompt $" {
94 verbose "Dir set to $subdir"
95 }
96 -re ".*$gdb_prompt $" {
97 perror "Dir \"$subdir\" failed."
98 }
99 }
100 }
101 -re ".*$gdb_prompt $" {
102 perror "Dir \"$subdir\" failed."
103 }
104 }
105 }
106 -re ".*$gdb_prompt $" {
107 perror "Dir \"$subdir\" failed."
108 }
109 }
110}
111
112# In "testsuite/config/unix-gdb.exp", the routine "gdb_load"
113# is defined as "gdb_file_cmd". The binding of "gdb_file_cmd"
114# is done at invocation time. Before this file is processed,
115# it binds to the definition in "testsuite/lib/gdb.exp"; after
116# this file is processed, it binds to this definition.
117# TCL lets us overrides a previous routine definition without a
118# warning (isn't that special?).
119#
120# This means that tests before use "file" to load a target, and
121# tests afterwards use the pair "symbol-file" "exec-file".
122#
123# I'm leaving it as it is for now because at the moment it
124# is the only test we have of the use of the combination of
125# "symbol-file" and "exec-file" to load a debugging target (the
126# other definition uses "file".
127#
128# Symbol-file and exec-file should be tested explicitly, not
129# as a side effect of running a particular test (in this case,
130# "testsuite/gdb.compat/dbx.exp").
131#
132# CM: Renamed the procedure so it does not override the orginal file name.
133# Having the test suite change behavior depending on the tests run makes
134# it extremely difficult to reproduce errors. I've also added a
135# "dbx_gdb_load" procedure. This and only this test will call these
136# procedures now. I also added an "expect" to the "send exec-file" line.
137# The "expect" waits for a prompt to appear. Otherwise, if the tests run
138# too quickly, the caller could send another command before the prompt
139# of this command returns, causing the test to get out of sync and fail
140# seemingly randomly or only on a loaded system.
141#
7be570e7
JM
142# Problem is, though, that the testsuite config files can override the definition of
143# gdb_load (without notice, as was mentioned above). Unfortunately, the gdb_load proc
144# that was copied into this test was a copy of the unix native version.
145#
146# The real problem that we're attempting to solve is how to load an exec and symbol
147# file into gdb for a dbx session. So why not just override gdb_file_cmd with the
148# right sequence of events, allowing gdb_load to do its normal thing? This way
149# remotes and simulators will work, too.
1e50cda1
DJ
150#
151# [drow 2002-03-30]: We can restore the old gdb_file_cmd afterwards, though.
152set old_gdb_file_cmd_args [info args gdb_file_cmd]
153set old_gdb_file_cmd_body [info body gdb_file_cmd]
154
7be570e7 155proc gdb_file_cmd {arg} {
74cf1395
JM
156 global verbose
157 global loadpath
158 global loadfile
159 global GDB
160 global gdb_prompt
161 global spawn_id
162 upvar timeout timeout
b741e217
DJ
163 global last_loaded_file
164
165 set last_loaded_file $arg
74cf1395 166
7be570e7 167 if [is_remote host] {
4ec70201 168 set arg [remote_download host $arg]
7be570e7
JM
169 if { $arg == "" } {
170 error "download failed"
ae59b1da 171 return -1
7be570e7
JM
172 }
173 }
174
74cf1395
JM
175 send_gdb "symbol-file $arg\n"
176 gdb_expect {
3453e7e4 177 -re "Reading symbols from.*$gdb_prompt $" {
74cf1395
JM
178 verbose "\t\tLoaded $arg into the $GDB"
179 send_gdb "exec-file $arg\n"
180 gdb_expect {
1e50cda1
DJ
181 -re "A program is being debugged already.*Kill it.*y or n. $" {
182 send_gdb "y\n"
183 verbose "\t\tKilling previous program being debugged"
184 exp_continue
185 }
74cf1395
JM
186 -re ".*$gdb_prompt $" {
187 verbose "\t\tLoaded $arg with new symbol table into $GDB"
188 return 0
189 }
190 timeout {
191 perror "(timeout) Couldn't load $arg"
192 return -1
193 }
194 }
195 return 0
196 }
197 -re "has no symbol-table.*$gdb_prompt $" {
198 perror "$arg wasn't compiled with \"-g\""
199 return -1
200 }
74cf1395
JM
201 -re "Load new symbol table from \".*\".*y or n. $" {
202 send_gdb "y\n"
1e50cda1 203 exp_continue
74cf1395
JM
204 }
205 -re ".*No such file or directory.*$gdb_prompt $" {
206 perror "($arg) No such file or directory\n"
207 return -1
208 }
209 -re "$gdb_prompt $" {
210 perror "couldn't load $arg into $GDB."
211 return -1
212 }
213 timeout {
214 perror "couldn't load $arg into $GDB (timed out)."
215 return -1
216 }
217 eof {
218 # This is an attempt to detect a core dump, but seems not to
219 # work. Perhaps we need to match .* followed by eof, in which
220 # expect does not seem to have a way to do that.
221 perror "couldn't load $arg into $GDB (end of file)."
222 return -1
223 }
224 }
225}
226
74cf1395
JM
227#
228#test_breakpoints
229#
230proc test_breakpoints { } {
6acc2dde
AA
231 set stop_line [gdb_get_line_number "stop-in-main"]
232 gdb_test "stop in main" "Breakpoint.*at.*: file.*average\.c, line $stop_line\."
233 gdb_test "status" "Num.*Type.*Disp.*Enb.*Address.*What\r\n1\[ \r\]+breakpoint\[ \r\]+keep y.*in main at.*average\.c:$stop_line.*"
234 set stop_line [gdb_get_line_number "stop-at-call"]
235 gdb_test "stop at average.c:$stop_line" "Breakpoint.*at.*: file.*average\.c, line $stop_line.*"
236 gdb_test "stop in average.c:$stop_line" "Usage: stop in <function . address>"
65e65158 237 gdb_test "stop at main" "Usage: stop at LINE"
74cf1395
JM
238}
239
240#
241#test_assign
242#
243proc test_assign { } {
7be570e7
JM
244 global decimal
245 global gdb_prompt
246
247 gdb_run_cmd
fa43b1d7
PA
248 set test "running to main"
249 gdb_test_multiple "" $test {
250 -re "Break.* at .*:$decimal.*$gdb_prompt $" {
251 pass $test
252 }
253 -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" {
254 pass $test
255 }
7be570e7
JM
256 }
257 send_gdb "assign first=1\n"
258 gdb_expect {
259 -re "No symbol \"first\" in current context.*$" { fail "assign first" }
5e5ebfe6 260 -re "$gdb_prompt $" { pass "assign first" }
7be570e7
JM
261 timeout { fail "assign first (timeout)" }
262 }
74cf1395
JM
263 gdb_test "print first" ".1 = 1"
264}
265
266#
267#test_whereis
268#
269proc test_whereis { } {
e3a91079 270 gdb_test "whereis my_list" "All variables matching regular expression \"my_list\":\r\n\r\nFile.*average\.c:\r\n.*\tstatic int my_list\\\[10\\\];"
74cf1395
JM
271}
272
273#
274#test_func
275#
276proc test_func { } {
6acc2dde
AA
277 global decimal
278 global srcfile2
f6978de9
MS
279 gdb_test "cont" ".*" "cont 1"
280 gdb_test "step" ".*"
74cf1395 281 gdb_test "func sum" "'sum' not within current stack frame\."
6acc2dde
AA
282 set stop_line [gdb_get_line_number "stop-in-sum" $srcfile2]
283 gdb_test "stop in sum" "Breakpoint.*at.*: file.*sum\.c, line $stop_line\."
f6978de9 284 gdb_test "cont" ".*" "cont 2"
9d622bda 285 gdb_test "func print_average" ".*in print_average.*\\(list=.*, low=0, high=6\\).*at.*average\.c:${decimal}\r\n${decimal}\[ \t\]+total = sum\\(list, low, high\\);"
74cf1395
JM
286}
287
288# Start with a fresh gdb.
289
290gdb_exit
291global GDBFLAGS
292set saved_gdbflags $GDBFLAGS
293
294set GDBFLAGS "$GDBFLAGS --dbx"
295gdb_start
296dbx_reinitialize_dir $srcdir/$subdir
7be570e7 297gdb_load ${binfile}
74cf1395
JM
298
299test_breakpoints
300test_assign
301test_whereis
302gdb_test "file average.c:1" "1\[ \t\]+/. This is a sample program.*"
303test_func
304
305#exit and cleanup
306gdb_exit
307
308set GDBFLAGS $saved_gdbflags
1e50cda1
DJ
309eval proc gdb_file_cmd {$old_gdb_file_cmd_args} {$old_gdb_file_cmd_body}
310
74cf1395 311return 0
This page took 1.868431 seconds and 4 git commands to generate.