OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [bigcore.exp] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004, 2005,
2
# 2007, 2008, 2009, 2010 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 3 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, see .
16
 
17
# This file is based on corefile.exp which was written by Fred
18
# Fish. (fnf@cygnus.com)
19
 
20
if $tracelevel then {
21
        strace $tracelevel
22
}
23
 
24
set prms_id 0
25
set bug_id 0
26
 
27
# Are we on a target board?  As of 2004-02-12, GDB didn't have a
28
# mechanism that would let it efficiently access a remote corefile.
29
 
30
if ![isnative] then {
31
    untested "Remote system"
32
    return
33
}
34
 
35
# Can the system run this test (in particular support sparse
36
# corefiles)?  On systems that lack sparse corefile support this test
37
# consumes too many resources - gigabytes worth of disk space and and
38
# I/O bandwith.
39
 
40
if { [istarget "*-*-*bsd*"]
41
     || [istarget "*-*-hpux*"]
42
     || [istarget "*-*-solaris*"]
43
     || [istarget "*-*-darwin*"]
44
     || [istarget "*-*-cygwin*"] } {
45
    untested "Kernel lacks sparse corefile support (PR gdb/1551)"
46
    return
47
}
48
 
49
# This testcase causes too much stress (in terms of memory usage)
50
# on certain systems...
51
if { [istarget "*-*-*irix*"] } {
52
    untested "Testcase too stressful for this system"
53
    return
54
}
55
 
56
set testfile "bigcore"
57
set srcfile ${testfile}.c
58
set binfile ${objdir}/${subdir}/${testfile}
59
set corefile ${objdir}/${subdir}/${testfile}.corefile
60
 
61
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
62
     untested bigcore.exp
63
     return -1
64
}
65
 
66
# Run GDB on the bigcore program up-to where it will dump core.
67
 
68
gdb_exit
69
gdb_start
70
gdb_reinitialize_dir $srcdir/$subdir
71
gdb_load ${binfile}
72
gdb_test "set print sevenbit-strings" "" \
73
        "set print sevenbit-strings; ${testfile}"
74
gdb_test "set width 0" "" \
75
        "set width 0; ${testfile}"
76
if { ![runto_main] } then {
77
    gdb_suppress_tests;
78
}
79
set print_core_line [gdb_get_line_number "Dump core"]
80
gdb_test "tbreak $print_core_line"
81
gdb_test continue ".*print_string.*"
82
gdb_test next ".*0 = 0.*"
83
 
84
# Traverse part of bigcore's linked list of memory chunks (forward or
85
# backward), saving each chunk's address.
86
 
87
proc extract_heap { dir } {
88
    global gdb_prompt
89
    global expect_out
90
    set heap ""
91
    set test "extract ${dir} heap"
92
    set lim 0
93
    gdb_test_multiple "print heap.${dir}" "$test" {
94
        -re " = \\(struct list \\*\\) 0x0.*$gdb_prompt $" {
95
            pass "$test"
96
        }
97
        -re " = \\(struct list \\*\\) (0x\[0-9a-f\]*).*$gdb_prompt $" {
98
            set heap [concat $heap $expect_out(1,string)]
99
            if { $lim >= 200 } {
100
                pass "$test (stop at $lim)"
101
            } else {
102
                incr lim
103
                send_gdb "print \$.${dir}\n"
104
                exp_continue
105
            }
106
        }
107
        -re ".*$gdb_prompt $" {
108
            fail "$test (entry $lim)"
109
        }
110
        timeout {
111
            fail "$test (timeout)"
112
        }
113
    }
114
    return $heap;
115
}
116
set next_heap [extract_heap next]
117
set prev_heap [extract_heap prev]
118
 
119
# Save the total allocated size within GDB so that we can check
120
# the core size later.
121
gdb_test "set \$bytes_allocated = bytes_allocated" "" "save heap size"
122
 
123
# Now create a core dump
124
 
125
# Rename the core file to "TESTFILE.corefile" rather than just "core",
126
# to avoid problems with sys admin types that like to regularly prune
127
# all files named "core" from the system.
128
 
129
# Some systems append "core" to the name of the program; others append
130
# the name of the program to "core"; still others (like Linux, as of
131
# May 2003) create cores named "core.PID".
132
 
133
# Save the process ID.  Some systems dump the core into core.PID.
134
set test "grab pid"
135
gdb_test_multiple "info program" $test {
136
    -re "child process (\[0-9\]+).*$gdb_prompt $" {
137
        set inferior_pid $expect_out(1,string)
138
        pass $test
139
    }
140
    -re "$gdb_prompt $" {
141
        set inferior_pid unknown
142
        pass $test
143
    }
144
}
145
 
146
# Dump core using SIGABRT
147
set oldtimeout $timeout
148
set timeout 600
149
gdb_test "signal SIGABRT" "Program terminated with signal SIGABRT, .*"
150
set timeout $oldtimeout
151
 
152
# Find the corefile
153
set file ""
154
foreach pat [list core.${inferior_pid} ${testfile}.core core] {
155
    set names [glob -nocomplain $pat]
156
    if {[llength $names] == 1} {
157
        set file [lindex $names 0]
158
        remote_exec build "mv $file $corefile"
159
        break
160
    }
161
}
162
 
163
if { $file == "" } {
164
    untested "Can't generate a core file"
165
    return 0
166
}
167
 
168
# Check that the corefile is plausibly large enough.  We're trying to
169
# detect the case where the operating system has truncated the file
170
# just before signed wraparound.  TCL, unfortunately, has a similar
171
# problem - so use catch.  It can handle the "bad" size but not
172
# necessarily the "good" one.  And we must use GDB for the comparison,
173
# similarly.
174
 
175
if {[catch {file size $corefile} core_size] == 0} {
176
    set core_ok 0
177
    gdb_test_multiple "print \$bytes_allocated < $core_size" "check core size" {
178
        -re " = 1\r\n$gdb_prompt $" {
179
            pass "check core size"
180
            set core_ok 1
181
        }
182
        -re " = 0\r\n$gdb_prompt $" {
183
            pass "check core size"
184
            set core_ok 0
185
        }
186
    }
187
} {
188
    # Probably failed due to the TCL build having problems with very
189
    # large values.  Since GDB uses a 64-bit off_t (when possible) it
190
    # shouldn't have this problem.  Assume that things are going to
191
    # work.  Without this assumption the test is skiped on systems
192
    # (such as i386 GNU/Linux with patched kernel) which do pass.
193
    pass "check core size"
194
    set core_ok 1
195
}
196
if {! $core_ok} {
197
    untested "check core size (system does not support large corefiles)"
198
    return 0
199
}
200
 
201
# Now load up that core file
202
 
203
set test "load corefile"
204
gdb_test_multiple "core $corefile" "$test" {
205
    -re "A program is being debugged already.  Kill it. .y or n. " {
206
        send_gdb "y\n"
207
        exp_continue
208
    }
209
    -re "Core was generated by.*$gdb_prompt $" {
210
        pass "$test"
211
    }
212
}
213
 
214
# Finally, re-traverse bigcore's linked list, checking each chunk's
215
# address against the executable.  Don't use gdb_test_multiple as want
216
# only one pass/fail.  Don't use exp_continue as the regular
217
# expression involving $heap needs to be re-evaluated for each new
218
# response.
219
 
220
proc check_heap { dir heap } {
221
    global gdb_prompt
222
    set test "check ${dir} heap"
223
    set ok 1
224
    set lim 0
225
    send_gdb "print heap.${dir}\n"
226
    while { $ok } {
227
        gdb_expect {
228
            -re " = \\(struct list \\*\\) [lindex $heap $lim].*$gdb_prompt $" {
229
                if { $lim >= [llength $heap] } {
230
                    pass "$test"
231
                    set ok 0
232
                } else {
233
                    incr lim
234
                    send_gdb "print \$.${dir}\n"
235
                }
236
            }
237
            -re ".*$gdb_prompt $" {
238
                fail "$test (address [lindex $heap $lim])"
239
                set ok 0
240
            }
241
            timeout {
242
                fail "$test (timeout)"
243
                set ok 0
244
            }
245
        }
246
    }
247
}
248
 
249
check_heap next $next_heap
250
check_heap prev $prev_heap

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.