1 # Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
29 # are we on a target board
31 warning "corefile test case can't run on a target system"
36 set binfile "coremaker"
37 set srcfile $binfile.c
39 if ![file exists $objdir/$subdir/$binfile] then {
40 perror "$objdir/$subdir/$binfile does not exist."
44 if ![file exists $objdir/$subdir/corefile] then {
45 # Create a core file named "corefile" rather than just "core", to
46 # avoid problems with sys admin types that like to regularly prune all
47 # files named "core" from the system.
49 # Some systems append "core" to the name of the program; others append
50 # the name of the program to "core".
52 catch "system \"cd $objdir/$subdir; ./$binfile\""
53 if [file exists $objdir/$subdir/core] then {
54 catch "exec mv $objdir/$subdir/core $objdir/$subdir/corefile"
55 } elseif [file exists $objdir/$subdir/core.$binfile] {
56 catch "exec mv $objdir/$subdir/core.$binfile $objdir/$subdir/corefile"
57 } elseif [file exists $objdir/$subdir/$binfile.core] {
58 catch "exec mv $objdir/$subdir/$binfile.core $objdir/$subdir/corefile"
63 # Test that we can simply startup with a "-core=corefile" command line arg
64 # and recognize that the core file is a valid, usable core file.
65 # To do this, we must shutdown the currently running gdb and restart
66 # with the -core args. We can't use gdb_start because it looks for
67 # the first gdb prompt, and the message we are looking for occurs
68 # before the first prompt. Also, we can't include GDBFLAGS because
69 # if it is empty, this confuses gdb with an empty argument that it
70 # grumbles about (said grumbling currently being ignored in gdb_start).
76 send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
79 # The RS/6000 gdb doesn't know how to extract the file name and
80 # terminating signal from the core file, so all these tests are
83 setup_xfail "rs6000-*-*"
84 set oldtimeout $timeout
85 set timeout [expr "$timeout + 60"]
86 eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
88 -re "Core was generated by .*coremaker.*\r
90 $prompt $" { pass "args: -core=corefile" }
91 -re ".*$prompt $" { fail "args: -core=corefile" }
92 timeout { fail "(timeout) starting with -core" }
97 # Test that startup with both an executable file and -core argument.
98 # See previous comments above, they are still applicable.
103 send_user "Spawning $GDB -nw $GDBFLAGS $objdir/$subdir/$binfile -core=$objdir/$subdir/corefile\n"
107 setup_xfail "rs6000-*-*"
108 # This fails in p3, but not in devo.
109 spawn $GDB -nw $GDBFLAGS $objdir/$subdir/$binfile -core=$objdir/$subdir/corefile
111 -re "Core was generated by .*coremaker.*\r
113 $prompt $" { pass "args: execfile -core=corefile" }
114 -re ".*$prompt $" { fail "args: execfile -core=corefile" }
115 timeout { fail "(timeout) starting with -core" }
117 set timeout $oldtimeout
120 # Now restart normally.
124 gdb_reinitialize_dir $srcdir/$subdir
125 gdb_load $objdir/$subdir/$binfile
127 # Test basic corefile recognition via core-file command.
129 setup_xfail "rs6000-*-*"
130 send "core-file $objdir/$subdir/corefile\n"
132 -re "Core was generated by .*coremaker.*\r
134 $prompt $" { pass "core-file command" }
135 -re ".*$prompt $" { fail "core-file command" }
136 timeout { fail "(timeout) core-file command" }
139 # test reinit_frame_cache
141 gdb_load $objdir/$subdir/$binfile
143 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\)"
145 gdb_test "core" "No core file now."