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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.base/] [corefile.exp] - Blame information for rev 330

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2007, 2008,
2
# 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 was written by Fred Fish. (fnf@cygnus.com)
18
 
19
if $tracelevel then {
20
        strace $tracelevel
21
}
22
 
23
 
24
# are we on a target board
25
if ![isnative] then {
26
    return
27
}
28
 
29
set testfile "coremaker"
30
set srcfile ${testfile}.c
31
set binfile ${objdir}/${subdir}/${testfile}
32
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33
     untested corefile.exp
34
     return -1
35
}
36
 
37
# Create and source the file that provides information about the compiler
38
# used to compile the test case.
39
if [get_compiler_info ${binfile}] {
40
    return -1;
41
}
42
 
43
set corefile [core_find $binfile {coremmap.data}]
44
if {$corefile == ""} {
45
    return 0
46
}
47
 
48
# Test that we can simply startup with a "-core=$corefile" command line arg
49
# and recognize that the core file is a valid, usable core file.
50
# To do this, we must shutdown the currently running gdb and restart
51
# with the -core args.  We can't use gdb_start because it looks for
52
# the first gdb prompt, and the message we are looking for occurs
53
# before the first prompt.
54
#
55
# Another problem is that on some systems (solaris for example), there
56
# is apparently a limit on the length of a fully specified path to
57
# the coremaker executable, at about 80 chars.  For this case, consider
58
# it a pass, but note that the program name is bad.
59
 
60
gdb_exit
61
if $verbose>1 then {
62
    send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile\n"
63
}
64
 
65
set oldtimeout $timeout
66
set timeout [expr "$timeout + 60"]
67
verbose "Timeout is now $timeout seconds" 2
68
eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile"
69
expect {
70
    -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
71
        fail "args: -core=[file tail $corefile] (couldn't find regs)"
72
    }
73
    -re "Core was generated by .*coremaker.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
74
        pass "args: -core=[file tail $corefile]"
75
    }
76
    -re "Core was generated by .*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
77
        pass "args: -core=[file tail $corefile] (with bad program name)"
78
    }
79
    -re ".*registers from core file: File in wrong format.* $" {
80
        fail "args: -core=[file tail $corefile] (could not read registers from core file)"
81
    }
82
    -re ".*$gdb_prompt $"       { fail "args: -core=[file tail $corefile]" }
83
    timeout             { fail "(timeout) starting with -core" }
84
}
85
 
86
 
87
#
88
# Test that startup with both an executable file and -core argument.
89
# See previous comments above, they are still applicable.
90
#
91
 
92
close;
93
 
94
if $verbose>1 then {
95
    send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile\n"
96
}
97
 
98
 
99
eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile";
100
expect {
101
    -re "Core was generated by .*coremaker.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
102
        pass "args: execfile -core=[file tail $corefile]"
103
    }
104
    -re "Core was generated by .*\r\n\#0  .*\(\).*\r\n$gdb_prompt $"     {
105
        pass "args: execfile -core=[file tail $corefile] (with bad program name)"
106
    }
107
    -re ".*registers from core file: File in wrong format.* $" {
108
        fail "args: execfile -core=[file tail $corefile] (could not read registers from core file)"
109
    }
110
    -re ".*$gdb_prompt $"       { fail "args: execfile -core=[file tail $corefile]" }
111
    timeout             { fail "(timeout) starting with -core" }
112
}
113
set timeout $oldtimeout
114
verbose "Timeout is now $timeout seconds" 2
115
 
116
close;
117
 
118
# Now restart normally.
119
 
120
gdb_start
121
gdb_reinitialize_dir $srcdir/$subdir
122
gdb_load ${binfile}
123
 
124
# Test basic corefile recognition via core-file command.
125
 
126
gdb_test_multiple "core-file $corefile" "core-file command" {
127
    -re ".* program is being debugged already.*y or n. $" {
128
        # gdb_load may connect us to a gdbserver.
129
        send_gdb "y\n"
130
        exp_continue;
131
    }
132
    -re "Core was generated by .*coremaker.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
133
        pass "core-file command"
134
    }
135
    -re "Core was generated by .*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
136
        pass "core-file command (with bad program name)"
137
    }
138
    -re ".*registers from core file: File in wrong format.* $" {
139
        fail "core-file command (could not read registers from core file)"
140
    }
141
}
142
 
143
# Test correct mapping of corefile sections by printing some variables.
144
 
145
gdb_test "print coremaker_data" "\\\$$decimal = 202"
146
gdb_test "print coremaker_bss" "\\\$$decimal = 10"
147
gdb_test "print coremaker_ro" "\\\$$decimal = 201"
148
 
149
gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
150
 
151
# Somehow we better test the ability to read the registers out of the core
152
# file correctly.  I don't think the other tests do this.
153
 
154
gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
155
gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp"
156
 
157
# Test ability to read mmap'd data
158
 
159
gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file"
160
setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*"
161
set test "accessing mmapped data in core file"
162
gdb_test_multiple "x/8bd buf2" "$test" {
163
    -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" {
164
        pass "$test"
165
    }
166
    -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" {
167
        fail "$test (mapping failed at runtime)"
168
    }
169
    -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" {
170
        fail "$test (mapping address not found in core file)"
171
    }
172
}
173
 
174
# test reinit_frame_cache
175
 
176
gdb_load ${binfile}
177
gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
178
 
179
gdb_test "core" "No core file now."

powered by: WebSVN 2.1.0

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