1 # Copyright
1988, 1990, 1991, 1992, 1994, 1997, 1999, 2000, 2002,
2 #
2003, 2004 Free Software Foundation
, Inc.
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
2 of the License
, or
7 #
(at your option
) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this
program; if not
, write to the Free Software
16 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
18 # This file was written by Rob Savoye.
(rob@cygnus.com
)
27 # are we
on a target board
28 if [is_remote target
] {
32 # Not all of the lines of code near the start of main are executed
for
33 #
every machine. Also
, optimization may reorder some of the lines.
34 # So all we
do is try to step or next over everything until we
get
35 # to a line that we know is always executed.
37 proc do_steps_and_nexts
{} {
41 gdb_reinitialize_dir $srcdir
/..
43 for {set count 0} {$
count < 32} {incr
count} {
45 # NOTE
: carlton
/2002-12-11: The
"initial brace" and
46 #
"current_directory initialization" possibilities happen to
47 # me with GCC
3.1 on i686
-pc
-linux
-gnu when I
compile with
50 -re
".*context = data.*$gdb_prompt $" {
51 set description
"step over context initialization"
54 -re
".*argc = context->argc.*$gdb_prompt $" {
55 set description
"step over argc initialization"
58 -re
".*argv = context->argv.*$gdb_prompt $" {
59 set description
"step over argv initialization"
62 -re
".*quiet = 0.*$gdb_prompt $" {
63 set description
"step over quiet initialization"
66 -re
".*batch = 0.*$gdb_prompt $" {
67 set description
"step over batch initialization"
70 -re
".*symarg = NULL.*$gdb_prompt $" {
71 set description
"step over symarg initialization"
74 -re
".*execarg = NULL.*$gdb_prompt $" {
75 set description
"step over execarg initialization"
78 -re
".*corearg = NULL.*$gdb_prompt $" {
79 set description
"step over corearg initialization"
82 -re
".*cdarg = NULL.*$gdb_prompt $" {
83 set description
"step over cdarg initialization"
86 -re
".*ttyarg = NULL.*$gdb_prompt $" {
87 set description
"step over ttyarg initialization"
90 -re
".*time_at_startup = get_run_time.*$gdb_prompt $" {
91 set description
"next over get_run_time and everything it calls"
94 -re
".*START_PROGRESS.*$gdb_prompt $" {
95 # Note
: ezannoni
/2004/02/17: This check should be
96 # removed
, since as of
today that source line is not
98 set description
"next over START_PROGRESS and everything it calls"
101 -re
".*mac_init.*$gdb_prompt $" {
102 set description
"next over mac_init and everything it calls"
105 -re
".*init_malloc.*$gdb_prompt $" {
106 # gdb
6.2.X is the last gdb which called init_malloc
107 set description
"next over init_malloc and everything it calls"
110 -re
".*lim_at_start.*$gdb_prompt $" {
111 set description
"next over lim_at_start initialization"
114 -re
".*count . 0x3.*$gdb_prompt $" {
115 set description
"next over conditional stack alignment code 1"
118 -re
".*if .i != 0.*$gdb_prompt $" {
119 set description
"next over conditional stack alignment code 2"
122 -re
".*alloca .i - 4.*$gdb_prompt $" {
123 set description
"next over conditional stack alignment alloca"
126 -re
".*cmdsize = 1.*$gdb_prompt $" {
127 set description
"step over cmdsize initialization"
130 -re
".*cmdarg = .* xmalloc.*$gdb_prompt $" {
131 set description
"next over cmdarg initialization via xmalloc"
134 -re
".*ncmd = 0.*$gdb_prompt $" {
135 set description
"next over ncmd initialization"
138 -re
".*dirsize = 1.*$gdb_prompt $" {
139 set description
"next over dirsize initialization"
142 -re
".*dirarg = .* xmalloc.*$gdb_prompt $" {
145 -re
".*setlocale .LC_MESSAGES,.*$gdb_prompt $" {
146 set description
"next over setlocale LC_MESSAGES"
149 -re
".*setlocale .LC_CTYPE,.*$gdb_prompt $" {
150 set description
"next over setlocale LC_CTYPE"
153 -re
".*bindtextdomain .PACKAGE, LOCALEDIR.;.*$gdb_prompt $" {
154 set description
"next over bindtextdomain"
157 -re
".*textdomain .PACKAGE.;.*$gdb_prompt $" {
158 set description
"next over textdomain PACKAGE"
161 -re
"\[0-9\]*\t\{\r\n$gdb_prompt $" {
162 set description
"step over initial brace"
165 -re
".*current_directory = gdb_dirbuf.*$gdb_prompt $" {
166 set description
"step over current_directory initialization"
169 -re
".*gdb_sysroot = .*$gdb_prompt $" {
170 # NOTE
: carlton
/2003-01-15: More optimization reordering
,
171 # observed
on GCC
3.1.
172 set description
"step over gdb_sysroot initialization"
175 -re
".*ndir = 0.*$gdb_prompt $" {
176 set description
"step over ndir initialization"
179 -re
".*instream = stdin.*$gdb_prompt $" {
180 set description
"step over instream initialization"
183 -re
".*getcwd .gdb_dirbuf, sizeof .gdb_dirbuf..;.*$gdb_prompt $" {
184 set description
"next over getcwd"
187 -re
"\[ \t\]+\{\r\n$gdb_prompt $" {
188 setup_xfail
"mips-*-irix5*"
189 fail
"$description ended up at odd location"
191 -re
".*main.c.*No such file or directory.*$gdb_prompt $" {
192 setup_xfail
"rs6000-*-aix3*"
193 fail
"must be able to list source lines"
196 -re
".*$gdb_prompt $" {
197 fail
"unknown source line after $description"
201 fail
"unknown source line near main"
205 send_gdb
"$command\n"
207 -re
".*No such file or directory.\r\n$gdb_prompt $" {
208 fail
"$description (no source available)"
210 -re
".*A file or directory .* does not exist..\r\n$gdb_prompt $" {
211 fail
"$description (no source available)"
213 -re
".*$gdb_prompt $" {
217 fail
"$description (timeout)"
223 proc test_with_self
{ executable
} {
230 #
load yourself into the debugger
231 # This can take a relatively long time
, particularly
for testing where
232 # the executable is being accessed over a network
, or where gdb does not
233 # support partial symbols
for a particular target and has to
load the
234 # entire symbol table.
Set the timeout to
10 minutes
, which should be
235 # adequate
for most environments
(it
*has
* timed out with
5 min on a
236 # SPARCstation SLC under moderate
load, so this isn
't unreasonable).
237 # After gdb is started, set the timeout to 30 seconds for the duration
238 # of this test, and then back to the original value.
240 set oldtimeout $timeout
242 verbose "Timeout is now $timeout seconds" 2
244 global gdb_file_cmd_debug_info
245 set gdb_file_cmd_debug_info "unset"
247 set result [gdb_load $executable]
248 set timeout $oldtimeout
249 verbose "Timeout is now $timeout seconds" 2
251 if { $result != 0 } then {
255 if { $gdb_file_cmd_debug_info != "debug" } then {
256 untested "No debug information, skipping testcase."
260 # disassemble yourself
261 gdb_test "x/10i main" \
262 "x/10i.*main.*main.$decimal.*main.$decimal.*" \
265 # Set a breakpoint at main
266 gdb_test "break captured_main" \
267 "Breakpoint.*at.* file.*, line.*" \
268 "breakpoint in captured_main"
270 # We'll need this when we send a ^C to GDB. Need to
do it before we
271 # run the
program and gdb starts saving and restoring tty states.
272 #
On Ultrix
, we don
't need it and it is really slow (because shell_escape
273 # doesn't use vfork
).
274 if ![istarget
"*-*-ultrix*"] then {
275 gdb_test
"shell stty intr '^C'" "" \
276 "set interrupt character in test_with_self"
279 # FIXME
: If we put this after the run to main
, the first list
280 # command doesn
't print the same line as the current line where
282 gdb_test "set listsize 1" "" "set listsize to 1"
285 # It may take a very long time for the inferior gdb to start (lynx),
286 # so we bump it back up for the duration of this command.
289 set description "run until breakpoint at captured_main"
292 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
295 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" {
296 xfail "$description (line numbers scrambled?)"
298 -re "vfork: No more processes.*$gdb_prompt $" {
299 fail "$description (out of virtual memory)"
300 set timeout $oldtimeout
301 verbose "Timeout is now $timeout seconds" 2
304 -re ".*$gdb_prompt $" {
306 set timeout $oldtimeout
307 verbose "Timeout is now $timeout seconds" 2
311 fail "$description (timeout)"
315 set timeout $oldtimeout
316 verbose "Timeout is now $timeout seconds" 2
318 # do we have a version number ?
319 send_gdb "print version\n"
321 -re ".\[0-9\]+ = .\[0-9.\]+.*$gdb_prompt $" {
322 pass "printed version as string"
324 -re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" {
325 pass "printed version as pointer"
327 -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" {
328 pass "printed version with cast"
330 -re ".*$gdb_prompt $" { fail "printed version" }
331 timeout { fail "(timeout) printed version" }
336 gdb_test "print \"foo\"" ".\[0-9\]+ = \"foo\"" "print a string"
338 # do_steps_and_nexts left us ready to execute an xmalloc call,
339 # so give that a try.
340 # If we don't actually enter the xmalloc
call when we give a
341 # step command that seems like a genuine bug. It seems to happen
342 #
on most RISC processors.
343 # NOTE drow
/2003-06-22: However
, if we step
back to the preceding two
344 # lines
, just keep stepping until we enter.
346 setup_xfail
"alpha-*-*" "mips-*-*"
347 set description
"step into xmalloc call"
350 -re
"ncmd = 0;.*$gdb_prompt $" {
355 -re
".*cmdarg = .* xmalloc.*$gdb_prompt $" {
360 -re
"dirsize = 1;.*$gdb_prompt $" {
365 -re
".*dirarg = .* xmalloc.*$gdb_prompt $" {
366 if { $stepped_back
== 1 } {
373 -re
"xmalloc.*size=.*at.*utils.c.*$gdb_prompt $" {
376 -re
".*No such file or directory.\r\n$gdb_prompt $" {
377 pass
"$description (no source available)"
379 -re
"A file or directory .* does not exist..\r\n$gdb_prompt $" {
380 pass
"$description (no source available)"
382 -re
".*$gdb_prompt $" {
386 fail
"$description (timeout)"
390 # start the
"xgdb" process
391 send_gdb
"continue\n"
393 -re
"GNU gdb \[0-9\.\]*.*
394 Copyright
\\(C
\\) \
[0-9\
]* Free Software Foundation
, Inc.
*
395 GDB is free software
, covered by the GNU General Public License
, and you are.
*
396 welcome to change it and
/or distribute copies of it under certain conditions.
*
397 Type
\"show copying
\" to see the conditions.
*
398 There is absolutely no warranty
for GDB. Type
\"show warranty
\" for details.
*
399 This GDB was configured as .
*$gdb_prompt $
"\
400 { pass
"xgdb is at prompt" }
401 -re
"GDB is free software and you are welcome to distribute copies of it.*
402 under certain conditions
; type
\"show copying
\" to see the conditions..
*
403 There is absolutely no warranty
for GDB
; type
\"show warranty
\" for details..
*
404 GDB.
*Copyright \
[0-9\
]+ Free Software Foundation
, Inc..
*$gdb_prompt $
"\
405 { pass
"xgdb is at prompt (obsolescent gdb)" }
406 -re
".*$gdb_prompt $" { fail "xgdb is at prompt" }
407 timeout
{ fail
"(timeout) xgdb is at prompt" }
410 #
set xgdb prompt so we can tell which is which
411 send_gdb
"set prompt (xgdb) \n"
413 -re
"\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" { pass "Set xgdb prompt" }
414 -re
".*$gdb_prompt $" { fail "Set xgdb prompt" }
415 default
{ fail
"(timeout) Set xgdb prompt" }
418 # kill the xgdb process
419 set description
"send ^C to child process"
422 -re
"Program received signal SIGINT.*$gdb_prompt $" {
425 -re
".*$gdb_prompt $" {
429 fail
"$description (timeout)"
433 set description
"send SIGINT signal to child process"
434 send_gdb
"signal SIGINT\n"
436 -re
"Continuing with signal SIGINT.*$gdb_prompt $" {
439 -re
".*$gdb_prompt $" {
443 fail
"$description (timeout)"
449 # This fails
on some linux systems
for unknown reasons.
On the
450 # systems where it fails
, sometimes it works fine when run manually.
451 # The testsuite failures may not be limited to just aout systems.
452 setup_xfail
"i*86-pc-linuxaout-gnu"
453 set description
"backtrace through signal handler"
454 send_gdb
"backtrace\n"
456 -re
"#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" {
459 -re
".*$gdb_prompt $" {
460 #
On the alpha
, we hit the infamous problem about gdb
461 # being unable to
get the frame pointer
(mentioned in
462 # gdb
/README
). As it is intermittent
, there is no way to
463 # XFAIL it which will give us an XPASS
if the problem goes
465 setup_xfail
"alpha*-*-osf*"
469 fail
"$description (timeout)"
474 #
Set the timeout
back to the value it had when we were called.
475 set timeout $oldtimeout
476 verbose
"Timeout is now $timeout seconds" 2
478 # Restart gdb in case next test expects it to be started already.
482 # Find a pathname to a file that we would
execute if the
shell was asked
483 # to run $
arg using the current PATH.
485 proc find_gdb
{ arg } {
487 #
If the
arg directly specifies an existing executable file
, then
490 if [file executable $
arg] then {
494 set result
[which $
arg]
495 if [string match
"/" [ string range $result 0 0 ]] then {
499 #
If everything fails
, just
return the unqualified pathname as default
505 # Run the test with self.
506 # Copy the file executable file in case this OS doesn
't like to edit its own
509 set GDB_FULLPATH [find_gdb $GDB]
511 # Remove any old copy lying around.
512 remote_file host delete x$tool
515 set file [remote_download host $GDB_FULLPATH x$tool]
516 set result [test_with_self $file];
518 catch "remote_file host delete $file";
520 if {$result <0} then {
521 warning "Couldn't test self
"