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