* gdb.base/bigcore.exp: Deactivate on IRIX targets.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / bigcore.exp
1 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004
2 # Free Software Foundation, Inc.
3
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.
8 #
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.
13 #
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.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # This file is based on corefile.exp which was written by Fred
22 # Fish. (fnf@cygnus.com)
23
24 if $tracelevel then {
25 strace $tracelevel
26 }
27
28 set prms_id 0
29 set bug_id 0
30
31 # Are we on a target board? As of 2004-02-12, GDB didn't have a
32 # mechanism that would let it efficiently access a remote corefile.
33
34 if ![isnative] then {
35 untested "Remote system"
36 return
37 }
38
39 # Can the system run this test (in particular support sparse
40 # corefiles)? On systems that lack sparse corefile support this test
41 # consumes too many resources - gigabytes worth of disk space and and
42 # I/O bandwith.
43
44 if { [istarget "*-*-*bsd*"]
45 || [istarget "*-*-hpux*"]
46 || [istarget "*-*-solaris*"]
47 || [istarget "*-*-cygwin*"] } {
48 untested "Kernel lacks sparse corefile support (PR gdb/1551)"
49 return
50 }
51
52 # This testcase causes too much stress (in terms of memory usage)
53 # on certain systems...
54 if { [istarget "*-*-*irix*"] } {
55 untested "Testcase too stressful for this system"
56 return
57 }
58
59 set testfile "bigcore"
60 set srcfile ${testfile}.c
61 set binfile ${objdir}/${subdir}/${testfile}
62 set corefile ${objdir}/${subdir}/${testfile}.corefile
63
64 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
65 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
66 }
67
68 # Create a core file named "TESTFILE.corefile" rather than just
69 # "core", to avoid problems with sys admin types that like to
70 # regularly prune all files named "core" from the system.
71
72 # Some systems append "core" to the name of the program; others append
73 # the name of the program to "core"; still others (like Linux, as of
74 # May 2003) create cores named "core.PID". In the latter case, we
75 # could have many core files lying around, and it may be difficult to
76 # tell which one is ours, so let's run the program in a subdirectory.
77
78 set found 0
79 set coredir "${objdir}/${subdir}/coredir.[getpid]"
80 file mkdir $coredir
81 catch "system \"(cd ${coredir}; ${binfile}; true) >/dev/null 2>&1\""
82 set names [glob -nocomplain -directory $coredir *core*]
83 if {[llength $names] == 1} {
84 set file [file join $coredir [lindex $names 0]]
85 remote_exec build "mv $file $corefile"
86 set found 1
87 }
88
89 # Try to clean up after ourselves.
90 remote_file build delete [file join $coredir coremmap.data]
91 remote_exec build "rmdir $coredir"
92
93 if { $found == 0 } {
94 warning "can't generate a core file - core tests suppressed - check ulimit -c"
95 return 0
96 }
97
98 # Run GDB on the bigcore program up-to where it will dump core.
99
100 gdb_exit
101 gdb_start
102 gdb_reinitialize_dir $srcdir/$subdir
103 gdb_load ${binfile}
104 gdb_test "set print sevenbit-strings" "" \
105 "set print sevenbit-strings; ${testfile}"
106 gdb_test "set width 0" "" \
107 "set width 0; ${testfile}"
108 if { ![runto_main] } then {
109 gdb_suppress_tests;
110 }
111 set print_core_line [gdb_get_line_number "Dump core"]
112 gdb_test "tbreak $print_core_line"
113 gdb_test continue ".*print_string.*"
114 gdb_test next ".*0 = 0.*"
115
116 # Check that the corefile is plausibly large enough. We're trying to
117 # detect the case where the operating system has truncated the file
118 # just before signed wraparound. TCL, unfortunately, has a similar
119 # problem - so use catch. It can handle the "bad" size but not necessarily
120 # the "good" one. And we must use GDB for the comparison, similarly.
121
122 if {[catch {file size $corefile} core_size] == 0} {
123 set core_ok 0
124 gdb_test_multiple "print bytes_allocated < $core_size" "check core size" {
125 -re " = 1\r\n$gdb_prompt $" {
126 pass "check core size"
127 set core_ok 1
128 }
129 -re " = 0\r\n$gdb_prompt $" {
130 xfail "check core size (system does not support large corefiles)"
131 }
132 }
133 if {$core_ok == 0} {
134 return 0
135 }
136 }
137
138 # Traverse part of bigcore's linked list of memory chunks (forward or
139 # backward), saving each chunk's address.
140
141 proc extract_heap { dir } {
142 global gdb_prompt
143 global expect_out
144 set heap ""
145 set test "extract ${dir} heap"
146 set lim 0
147 gdb_test_multiple "print heap.${dir}" "$test" {
148 -re " = \\(struct list \\*\\) 0x0.*$gdb_prompt $" {
149 pass "$test"
150 }
151 -re " = \\(struct list \\*\\) (0x\[0-9a-f\]*).*$gdb_prompt $" {
152 set heap [concat $heap $expect_out(1,string)]
153 if { $lim >= 50 } {
154 pass "$test (stop at $lim)"
155 } else {
156 incr lim
157 send_gdb "print \$.${dir}\n"
158 exp_continue
159 }
160 }
161 -re ".*$gdb_prompt $" {
162 fail "$test (entry $lim)"
163 }
164 timeout {
165 fail "$test (timeout)"
166 }
167 }
168 return $heap;
169 }
170 set next_heap [extract_heap next]
171 set prev_heap [extract_heap prev]
172
173 # Now load up that core file
174
175 set test "load corefile"
176 gdb_test_multiple "core $corefile" "$test" {
177 -re "A program is being debugged already. Kill it. .y or n. " {
178 send_gdb "y\n"
179 exp_continue
180 }
181 -re "Core was generated by.*$gdb_prompt $" {
182 pass "$test"
183 }
184 }
185
186 # Finally, re-traverse bigcore's linked list, checking each chunk's
187 # address against the executable. Don't use gdb_test_multiple as want
188 # only one pass/fail. Don't use exp_continue as the regular
189 # expression involving $heap needs to be re-evaluated for each new
190 # response.
191
192 proc check_heap { dir heap } {
193 global gdb_prompt
194 set test "check ${dir} heap"
195 set ok 1
196 set lim 0
197 send_gdb "print heap.${dir}\n"
198 while { $ok } {
199 gdb_expect {
200 -re " = \\(struct list \\*\\) [lindex $heap $lim].*$gdb_prompt $" {
201 if { $lim >= [llength $heap] } {
202 pass "$test"
203 set ok 0
204 } else {
205 incr lim
206 send_gdb "print \$.${dir}\n"
207 }
208 }
209 -re ".*$gdb_prompt $" {
210 fail "$test (address [lindex $heap $lim])"
211 set ok 0
212 }
213 timeout {
214 fail "$test (timeout)"
215 set ok 0
216 }
217 }
218 }
219 }
220
221 check_heap next $next_heap
222 check_heap prev $prev_heap
This page took 0.05352 seconds and 4 git commands to generate.