]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/corefile.exp
6f0810c5c096ed1d3cc967e0a1957e835b92c4c2
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / corefile.exp
1 # Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
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
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Fred Fish. (fnf@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 # are we on a target board
30 if ![isnative] then {
31 return
32 }
33
34
35 set binfile "coremaker"
36 set srcfile $binfile.c
37
38 if ![file exists $objdir/$subdir/$binfile] then {
39 perror "$objdir/$subdir/$binfile does not exist."
40 return 0
41 }
42
43 if ![file exists $objdir/$subdir/corefile] then {
44 # Create a core file named "corefile" rather than just "core", to
45 # avoid problems with sys admin types that like to regularly prune all
46 # files named "core" from the system.
47 #
48 # Some systems append "core" to the name of the program; others append
49 # the name of the program to "core".
50
51 catch "system \"cd $objdir/$subdir; ./$binfile\""
52 if [file exists $objdir/$subdir/core] then {
53 catch "exec mv $objdir/$subdir/core $objdir/$subdir/corefile"
54 } elseif [file exists $objdir/$subdir/core.$binfile] {
55 catch "exec mv $objdir/$subdir/core.$binfile $objdir/$subdir/corefile"
56 } elseif [file exists $objdir/$subdir/$binfile.core] {
57 catch "exec mv $objdir/$subdir/$binfile.core $objdir/$subdir/corefile"
58 } else {
59 warning "can't generate a core file - core tests suppressed - check ulimit -c"
60 return 0
61 }
62 }
63
64 #
65 # Test that we can simply startup with a "-core=corefile" command line arg
66 # and recognize that the core file is a valid, usable core file.
67 # To do this, we must shutdown the currently running gdb and restart
68 # with the -core args. We can't use gdb_start because it looks for
69 # the first gdb prompt, and the message we are looking for occurs
70 # before the first prompt. Also, we can't include GDBFLAGS because
71 # if it is empty, this confuses gdb with an empty argument that it
72 # grumbles about (said grumbling currently being ignored in gdb_start).
73 # **FIXME**
74 #
75
76 gdb_exit
77 if $verbose>1 then {
78 send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
79 }
80
81 # The RS/6000 gdb doesn't know how to extract the file name and
82 # terminating signal from the core file, so all these tests are
83 # expected to fail.
84
85 setup_xfail "rs6000-*-*"
86 set oldtimeout $timeout
87 set timeout [expr "$timeout + 60"]
88 eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
89 expect {
90 -re "Core was generated by .*coremaker.*\r
91 \#0 .*\(\).*\r
92 $prompt $" { pass "args: -core=corefile" }
93 -re ".*$prompt $" { fail "args: -core=corefile" }
94 timeout { fail "(timeout) starting with -core" }
95 }
96
97
98 #
99 # Test that startup with both an executable file and -core argument.
100 # See previous comments above, they are still applicable.
101 #
102
103 gdb_exit
104 if $verbose>1 then {
105 send_user "Spawning $GDB -nw $GDBFLAGS $objdir/$subdir/$binfile -core=$objdir/$subdir/corefile\n"
106 }
107
108
109 setup_xfail "rs6000-*-*"
110 # This fails in p3, but not in devo.
111 spawn $GDB -nw $GDBFLAGS $objdir/$subdir/$binfile -core=$objdir/$subdir/corefile
112 expect {
113 -re "Core was generated by .*coremaker.*\r
114 \#0 .*\(\).*\r
115 $prompt $" { pass "args: execfile -core=corefile" }
116 -re ".*$prompt $" { fail "args: execfile -core=corefile" }
117 timeout { fail "(timeout) starting with -core" }
118 }
119 set timeout $oldtimeout
120
121
122 # Now restart normally.
123
124 gdb_exit
125 gdb_start
126 gdb_reinitialize_dir $srcdir/$subdir
127 gdb_load $objdir/$subdir/$binfile
128
129 # Test basic corefile recognition via core-file command.
130
131 setup_xfail "rs6000-*-*"
132 send "core-file $objdir/$subdir/corefile\n"
133 expect {
134 -re "Core was generated by .*coremaker.*\r
135 \#0 .*\(\).*\r
136 $prompt $" { pass "core-file command" }
137 -re ".*$prompt $" { fail "core-file command" }
138 timeout { fail "(timeout) core-file command" }
139 }
140
141 # Somehow we better test the ability to read the registers out of the core
142 # file correctly. I don't think the other tests do this.
143
144 # Haven't investigated this xfail
145 setup_xfail "m68k-*-hpux*" "i*86-*-linux*" "i*86-*-sysv4*"
146 gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
147
148 # test reinit_frame_cache
149
150 gdb_load $objdir/$subdir/$binfile
151 setup_xfail "*-*-*"
152 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\)" "up in corefile.exp"
153
154 gdb_test "core" "No core file now."