]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/gcore.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / gcore.exp
CommitLineData
1d506c26 1# Copyright 2002-2024 Free Software Foundation, Inc.
a911c360
MS
2
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
a911c360 6# (at your option) any later version.
e22f8b7c 7#
a911c360
MS
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
e22f8b7c 12#
a911c360 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
a911c360 15
a911c360
MS
16# This file was written by Michael Snyder (msnyder@redhat.com)
17# This is a test for the gdb command "generate-core-file".
18
a911c360 19
289f9037 20standard_testfile
a911c360 21
5b362f04 22if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
289f9037 23 return -1
a911c360
MS
24}
25
65a33d75 26if {![runto_main]} {
b60f0898 27 return -1
a911c360
MS
28}
29
a911c360
MS
30gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \
31 "set breakpoint at terminal_func"
32
fda6ae12 33gdb_test "continue" "Breakpoint .* terminal_func.*" \
a911c360
MS
34 "continue to terminal_func"
35
36set print_prefix ".\[0123456789\]* = "
37
38set pre_corefile_backtrace [capture_command_output "backtrace" ""]
39set pre_corefile_regs [capture_command_output "info registers" ""]
40set pre_corefile_allregs [capture_command_output "info all-reg" ""]
1f031429 41set pre_corefile_sysregs [capture_command_output "info reg system" ""]
a911c360
MS
42set pre_corefile_static_array \
43 [capture_command_output "print static_array" "$print_prefix"]
44set pre_corefile_uninit_array \
45 [capture_command_output "print un_initialized_array" "$print_prefix"]
46set pre_corefile_heap_string \
47 [capture_command_output "print heap_string" "$print_prefix"]
48set pre_corefile_local_array \
49 [capture_command_output "print array_func::local_array" "$print_prefix"]
50set pre_corefile_extern_array \
51 [capture_command_output "print extern_array" "$print_prefix"]
52
289f9037 53set corefile [standard_output_file gcore.test]
fac51dd9 54set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
7d605576
DJ
55if {!$core_supported} {
56 return -1
57}
a911c360
MS
58
59# Now restart gdb and load the corefile.
c95d486d 60clean_restart $binfile
a911c360 61
fac51dd9
DE
62set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
63if { $core_loaded == -1 } {
64 # No use proceeding from here.
65 return
a911c360
MS
66}
67
5fa290c1
DE
68gdb_test_sequence "where" "where in corefile" {
69 "\[\r\n\]+#0 .* terminal_func \\(\\) at "
70 "\[\r\n\]+#1 .* array_func \\(\\) at "
71 "\[\r\n\]+#2 .* factorial_func \\(value=1\\) at "
72 "\[\r\n\]+#3 .* factorial_func \\(value=2\\) at "
73 "\[\r\n\]+#4 .* factorial_func \\(value=3\\) at "
74 "\[\r\n\]+#5 .* factorial_func \\(value=4\\) at "
75 "\[\r\n\]+#6 .* factorial_func \\(value=5\\) at "
76 "\[\r\n\]+#7 .* factorial_func \\(value=6\\) at "
77 "\[\r\n\]+#8 .* main \\(.*\\) at "
a911c360
MS
78}
79
80set post_corefile_regs [capture_command_output "info registers" ""]
65a33d75 81if {![string compare $pre_corefile_regs $post_corefile_regs]} {
a911c360
MS
82 pass "corefile restored general registers"
83} else {
b082f199 84 fail "corefile restored general registers"
a911c360
MS
85}
86
87set post_corefile_allregs [capture_command_output "info all-reg" ""]
65a33d75 88if {![string compare $pre_corefile_allregs $post_corefile_allregs]} {
a911c360
MS
89 pass "corefile restored all registers"
90} else {
b082f199 91 fail "corefile restored all registers"
a911c360
MS
92}
93
1f031429 94set post_corefile_sysregs [capture_command_output "info reg system" ""]
65a33d75 95if {![string compare $pre_corefile_sysregs $post_corefile_sysregs]} {
1f031429
PA
96 pass "corefile restored system registers"
97} else {
98 fail "corefile restored system registers"
99}
100
a911c360
MS
101set post_corefile_extern_array \
102 [capture_command_output "print extern_array" "$print_prefix"]
a911c360
MS
103if ![string compare $pre_corefile_extern_array $post_corefile_extern_array] {
104 pass "corefile restored extern array"
105} else {
106 fail "corefile restored extern array"
107}
108
109set post_corefile_static_array \
110 [capture_command_output "print static_array" "$print_prefix"]
a911c360
MS
111if ![string compare $pre_corefile_static_array $post_corefile_static_array] {
112 pass "corefile restored static array"
113} else {
114 fail "corefile restored static array"
115}
116
117set post_corefile_uninit_array \
118 [capture_command_output "print un_initialized_array" "$print_prefix"]
a911c360
MS
119if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array] {
120 pass "corefile restored un-initialized array"
121} else {
122 fail "corefile restored un-initialized array"
123}
124
125set post_corefile_heap_string \
126 [capture_command_output "print heap_string" "$print_prefix"]
a911c360
MS
127if ![string compare $pre_corefile_heap_string $post_corefile_heap_string] {
128 pass "corefile restored heap array"
129} else {
130 fail "corefile restored heap array"
131}
132
133set post_corefile_local_array \
134 [capture_command_output "print array_func::local_array" "$print_prefix"]
a911c360
MS
135if ![string compare $pre_corefile_local_array $post_corefile_local_array] {
136 pass "corefile restored stack array"
137} else {
138 fail "corefile restored stack array"
139}
140
141set post_corefile_backtrace [capture_command_output "backtrace" ""]
142if ![string compare $pre_corefile_backtrace $post_corefile_backtrace] {
143 pass "corefile restored backtrace"
144} else {
145 fail "corefile restored backtrace"
146}