OLD | NEW |
1 # Copyright 1992-2000, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 1992-2013 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 4 # it under the terms of the GNU General Public License as published by |
5 # the Free Software Foundation; either version 3 of the License, or | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 # This file was written by Fred Fish. (fnf@cygnus.com) | 16 # This file was written by Fred Fish. (fnf@cygnus.com) |
17 | 17 |
18 | 18 |
19 # are we on a target board | 19 # are we on a target board |
20 if ![isnative] then { | 20 if ![isnative] then { |
21 return | 21 return |
22 } | 22 } |
23 | 23 |
24 set testfile "coremaker" | 24 standard_testfile coremaker.c |
25 set srcfile ${testfile}.c | |
26 set binfile ${objdir}/${subdir}/${testfile} | |
27 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug}] != "" } { | |
28 untested corefile.exp | |
29 return -1 | |
30 } | |
31 | 25 |
32 # Create and source the file that provides information about the compiler | 26 # Create and source the file that provides information about the compiler |
33 # used to compile the test case. | 27 # used to compile the test case. |
34 if [get_compiler_info] { | 28 if [get_compiler_info] { |
35 return -1; | 29 return -1 |
| 30 } |
| 31 |
| 32 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} { |
| 33 untested $testfile.exp |
| 34 return -1 |
36 } | 35 } |
37 | 36 |
38 set corefile [core_find $binfile {coremmap.data}] | 37 set corefile [core_find $binfile {coremmap.data}] |
39 if {$corefile == ""} { | 38 if {$corefile == ""} { |
40 return 0 | 39 return 0 |
41 } | 40 } |
42 | 41 |
43 # Test that we can simply startup with a "-core=$corefile" command line arg | 42 # Test that we can simply startup with a "-core=$corefile" command line arg |
44 # and recognize that the core file is a valid, usable core file. | 43 # and recognize that the core file is a valid, usable core file. |
45 # To do this, we must shutdown the currently running gdb and restart | 44 # To do this, we must shutdown the currently running gdb and restart |
46 # with the -core args. We can't use gdb_start because it looks for | 45 # with the -core args. We can't use gdb_start because it looks for |
47 # the first gdb prompt, and the message we are looking for occurs | 46 # the first gdb prompt, and the message we are looking for occurs |
48 # before the first prompt. | 47 # before the first prompt. |
49 # | 48 # |
50 # Another problem is that on some systems (solaris for example), there | 49 # Another problem is that on some systems (solaris for example), there |
51 # is apparently a limit on the length of a fully specified path to | 50 # is apparently a limit on the length of a fully specified path to |
52 # the coremaker executable, at about 80 chars. For this case, consider | 51 # the corefile executable, at about 80 chars. For this case, consider |
53 # it a pass, but note that the program name is bad. | 52 # it a pass, but note that the program name is bad. |
54 | 53 |
55 gdb_exit | 54 gdb_exit |
56 if $verbose>1 then { | 55 if $verbose>1 then { |
57 send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile\n" | 56 send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile\n" |
58 } | 57 } |
59 | 58 |
60 set oldtimeout $timeout | 59 set oldtimeout $timeout |
61 set timeout [expr "$timeout + 60"] | 60 set timeout [expr "$timeout + 60"] |
62 verbose "Timeout is now $timeout seconds" 2 | 61 verbose "Timeout is now $timeout seconds" 2 |
63 eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile" | 62 eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS -core=$corefile" |
64 expect { | 63 expect { |
65 -re "Couldn't find .* registers in core file.*$gdb_prompt $" { | 64 -re "Couldn't find .* registers in core file.*$gdb_prompt $" { |
66 fail "args: -core=[file tail $corefile] (couldn't find regs)" | 65 fail "args: -core=[file tail $corefile] (couldn't find regs)" |
67 } | 66 } |
68 -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $"
{ | 67 -re "Core was generated by .*corefile.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { |
69 pass "args: -core=[file tail $corefile]" | 68 pass "args: -core=[file tail $corefile]" |
70 } | 69 } |
71 -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { | 70 -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { |
72 pass "args: -core=[file tail $corefile] (with bad program name)" | 71 pass "args: -core=[file tail $corefile] (with bad program name)" |
73 } | 72 } |
74 -re ".*registers from core file: File in wrong format.* $" { | 73 -re ".*registers from core file: File in wrong format.* $" { |
75 fail "args: -core=[file tail $corefile] (could not read registers from c
ore file)" | 74 fail "args: -core=[file tail $corefile] (could not read registers from c
ore file)" |
76 } | 75 } |
77 -re ".*$gdb_prompt $" { fail "args: -core=[file tail $corefile]" } | 76 -re ".*$gdb_prompt $" { fail "args: -core=[file tail $corefile]" } |
78 timeout { fail "(timeout) starting with -core" } | 77 timeout { fail "(timeout) starting with -core" } |
79 } | 78 } |
80 | 79 |
81 | 80 |
82 # | 81 # |
83 # Test that startup with both an executable file and -core argument. | 82 # Test that startup with both an executable file and -core argument. |
84 # See previous comments above, they are still applicable. | 83 # See previous comments above, they are still applicable. |
85 # | 84 # |
86 | 85 |
87 close; | 86 close |
88 | 87 |
89 if $verbose>1 then { | 88 if $verbose>1 then { |
90 send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefi
le\n" | 89 send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefi
le\n" |
91 } | 90 } |
92 | 91 |
93 | 92 |
94 eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile"; | 93 eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile" |
95 expect { | 94 expect { |
96 -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $"
{ | 95 -re "Core was generated by .*corefile.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { |
97 pass "args: execfile -core=[file tail $corefile]" | 96 pass "args: execfile -core=[file tail $corefile]" |
98 } | 97 } |
99 -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { | 98 -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { |
100 pass "args: execfile -core=[file tail $corefile] (with bad program name)
" | 99 pass "args: execfile -core=[file tail $corefile] (with bad program name)
" |
101 } | 100 } |
102 -re ".*registers from core file: File in wrong format.* $" { | 101 -re ".*registers from core file: File in wrong format.* $" { |
103 fail "args: execfile -core=[file tail $corefile] (could not read registe
rs from core file)" | 102 fail "args: execfile -core=[file tail $corefile] (could not read registe
rs from core file)" |
104 } | 103 } |
105 -re ".*$gdb_prompt $" { fail "args: execfile -core=[file tail $corefil
e]" } | 104 -re ".*$gdb_prompt $" { fail "args: execfile -core=[file tail $corefil
e]" } |
106 timeout { fail "(timeout) starting with -core" } | 105 timeout { fail "(timeout) starting with -core" } |
107 } | 106 } |
108 set timeout $oldtimeout | 107 set timeout $oldtimeout |
109 verbose "Timeout is now $timeout seconds" 2 | 108 verbose "Timeout is now $timeout seconds" 2 |
110 | 109 |
111 close; | 110 close |
112 | 111 |
113 # Now restart normally. | 112 # Now restart normally. |
114 | 113 |
115 gdb_start | 114 gdb_start |
116 gdb_reinitialize_dir $srcdir/$subdir | 115 gdb_reinitialize_dir $srcdir/$subdir |
117 gdb_load ${binfile} | 116 gdb_load ${binfile} |
118 | 117 |
119 # Test basic corefile recognition via core-file command. | 118 # Test basic corefile recognition via core-file command. |
120 | 119 |
121 gdb_test_multiple "core-file $corefile" "core-file command" { | 120 gdb_test_multiple "core-file $corefile" "core-file command" { |
122 -re ".* program is being debugged already.*y or n. $" { | 121 -re ".* program is being debugged already.*y or n. $" { |
123 # gdb_load may connect us to a gdbserver. | 122 # gdb_load may connect us to a gdbserver. |
124 send_gdb "y\n" | 123 send_gdb "y\n" |
125 » exp_continue; | 124 » exp_continue |
126 } | 125 } |
127 -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $"
{ | 126 -re "Core was generated by .*corefile.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { |
128 pass "core-file command" | 127 pass "core-file command" |
129 } | 128 } |
130 -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { | 129 -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" { |
131 pass "core-file command (with bad program name)" | 130 pass "core-file command (with bad program name)" |
132 } | 131 } |
133 -re ".*registers from core file: File in wrong format.* $" { | 132 -re ".*registers from core file: File in wrong format.* $" { |
134 fail "core-file command (could not read registers from core file)" | 133 fail "core-file command (could not read registers from core file)" |
135 } | 134 } |
136 } | 135 } |
137 | 136 |
138 # Test correct mapping of corefile sections by printing some variables. | 137 # Test correct mapping of corefile sections by printing some variables. |
139 | 138 |
140 gdb_test "print coremaker_data" "\\\$$decimal = 202" | 139 gdb_test "print coremaker_data" "\\\$$decimal = 202" |
141 gdb_test "print coremaker_bss" "\\\$$decimal = 10" | 140 gdb_test "print coremaker_bss" "\\\$$decimal = 10" |
142 gdb_test "print coremaker_ro" "\\\$$decimal = 201" | 141 gdb_test "print coremaker_ro" "\\\$$decimal = 201" |
143 | 142 |
144 gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}" | 143 gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}" |
145 | 144 |
| 145 # Test the presence and the correct values of $_exitsignal and |
| 146 # $_exitcode variables. The corefile is generated with a SIGABRT, |
| 147 # which is "6" in the Linux kernel. |
| 148 |
| 149 gdb_test "print \$_exitsignal" " = 6" \ |
| 150 "\$_exitsignal prints SIGABRT (6)" |
| 151 |
| 152 gdb_test "print \$_exitcode" " = void" \ |
| 153 "\$_exitcode is void" |
| 154 |
146 # Somehow we better test the ability to read the registers out of the core | 155 # Somehow we better test the ability to read the registers out of the core |
147 # file correctly. I don't think the other tests do this. | 156 # file correctly. I don't think the other tests do this. |
148 | 157 |
149 gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp" | 158 gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp" |
150 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp" | 159 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp" |
151 | 160 |
152 # Test ability to read mmap'd data | 161 # Test ability to read mmap'd data |
153 | 162 |
154 gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap dat
a in core file" | 163 gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap dat
a in core file" |
155 setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*" | 164 setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 pass $test | 230 pass $test |
222 } | 231 } |
223 } | 232 } |
224 | 233 |
225 gdb_exit | 234 gdb_exit |
226 | 235 |
227 # Test an attach command will clear any loaded core file. | 236 # Test an attach command will clear any loaded core file. |
228 | 237 |
229 if ![is_remote target] { | 238 if ![is_remote target] { |
230 set test "attach: spawn sleep" | 239 set test "attach: spawn sleep" |
231 set res [remote_spawn host "$binfile sleep"]; | 240 set res [remote_spawn host "$binfile sleep"] |
232 if { $res < 0 || $res == "" } { | 241 if { $res < 0 || $res == "" } { |
233 fail $test | 242 fail $test |
234 return | 243 return |
235 } | 244 } |
236 set pid [exp_pid -i $res] | 245 set pid [exp_pid -i $res] |
237 # We don't care whether the program is still in the startup phase when we | 246 # We don't care whether the program is still in the startup phase when we |
238 # attach. | 247 # attach. |
239 | 248 |
240 gdb_start | 249 gdb_start |
241 | 250 |
242 gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core
again" | 251 gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core
again" |
243 gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity chec
k we see the core file" | 252 gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity chec
k we see the core file" |
244 | 253 |
245 gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core" | 254 gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core" |
246 | 255 |
247 set test "attach: core file is cleared" | 256 set test "attach: core file is cleared" |
248 gdb_test_multiple "info files" $test { | 257 gdb_test_multiple "info files" $test { |
249 -re "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" { | 258 -re "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" { |
250 fail $test | 259 fail $test |
251 } | 260 } |
252 -re "\r\n$gdb_prompt $" { | 261 -re "\r\n$gdb_prompt $" { |
253 pass $test | 262 pass $test |
254 } | 263 } |
255 } | 264 } |
256 | 265 |
257 gdb_exit | 266 gdb_exit |
258 } | 267 } |
| 268 |
| 269 # Test warning-free core file load. E.g., a Linux vDSO used to |
| 270 # trigger this warning: |
| 271 # warning: Can't read pathname for load map: Input/output error. |
| 272 |
| 273 clean_restart ${testfile} |
| 274 |
| 275 set test "core-file warning-free" |
| 276 gdb_test_multiple "core-file $corefile" $test { |
| 277 -re "warning: .*\r\n.*\r\n$gdb_prompt $" { |
| 278 fail $test |
| 279 } |
| 280 -re "\r\n$gdb_prompt $" { |
| 281 pass $test |
| 282 } |
| 283 } |
OLD | NEW |