]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - 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
1 # Copyright 2002-2023 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
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/>.
15
16 # This file was written by Michael Snyder (msnyder@redhat.com)
17 # This is a test for the gdb command "generate-core-file".
18
19
20 standard_testfile
21
22 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
23 return -1
24 }
25
26 if {![runto_main]} {
27 return -1
28 }
29
30 gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \
31 "set breakpoint at terminal_func"
32
33 gdb_test "continue" "Breakpoint .* terminal_func.*" \
34 "continue to terminal_func"
35
36 set print_prefix ".\[0123456789\]* = "
37
38 set pre_corefile_backtrace [capture_command_output "backtrace" ""]
39 set pre_corefile_regs [capture_command_output "info registers" ""]
40 set pre_corefile_allregs [capture_command_output "info all-reg" ""]
41 set pre_corefile_sysregs [capture_command_output "info reg system" ""]
42 set pre_corefile_static_array \
43 [capture_command_output "print static_array" "$print_prefix"]
44 set pre_corefile_uninit_array \
45 [capture_command_output "print un_initialized_array" "$print_prefix"]
46 set pre_corefile_heap_string \
47 [capture_command_output "print heap_string" "$print_prefix"]
48 set pre_corefile_local_array \
49 [capture_command_output "print array_func::local_array" "$print_prefix"]
50 set pre_corefile_extern_array \
51 [capture_command_output "print extern_array" "$print_prefix"]
52
53 set corefile [standard_output_file gcore.test]
54 set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
55 if {!$core_supported} {
56 return -1
57 }
58
59 # Now restart gdb and load the corefile.
60 gdb_exit
61 gdb_start
62 gdb_reinitialize_dir $srcdir/$subdir
63 gdb_load ${binfile}
64
65 set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
66 if { $core_loaded == -1 } {
67 # No use proceeding from here.
68 return
69 }
70
71 gdb_test_sequence "where" "where in corefile" {
72 "\[\r\n\]+#0 .* terminal_func \\(\\) at "
73 "\[\r\n\]+#1 .* array_func \\(\\) at "
74 "\[\r\n\]+#2 .* factorial_func \\(value=1\\) at "
75 "\[\r\n\]+#3 .* factorial_func \\(value=2\\) at "
76 "\[\r\n\]+#4 .* factorial_func \\(value=3\\) at "
77 "\[\r\n\]+#5 .* factorial_func \\(value=4\\) at "
78 "\[\r\n\]+#6 .* factorial_func \\(value=5\\) at "
79 "\[\r\n\]+#7 .* factorial_func \\(value=6\\) at "
80 "\[\r\n\]+#8 .* main \\(.*\\) at "
81 }
82
83 set post_corefile_regs [capture_command_output "info registers" ""]
84 if {![string compare $pre_corefile_regs $post_corefile_regs]} {
85 pass "corefile restored general registers"
86 } else {
87 fail "corefile restored general registers"
88 }
89
90 set post_corefile_allregs [capture_command_output "info all-reg" ""]
91 if {![string compare $pre_corefile_allregs $post_corefile_allregs]} {
92 pass "corefile restored all registers"
93 } else {
94 fail "corefile restored all registers"
95 }
96
97 set post_corefile_sysregs [capture_command_output "info reg system" ""]
98 if {![string compare $pre_corefile_sysregs $post_corefile_sysregs]} {
99 pass "corefile restored system registers"
100 } else {
101 fail "corefile restored system registers"
102 }
103
104 set post_corefile_extern_array \
105 [capture_command_output "print extern_array" "$print_prefix"]
106 if ![string compare $pre_corefile_extern_array $post_corefile_extern_array] {
107 pass "corefile restored extern array"
108 } else {
109 fail "corefile restored extern array"
110 }
111
112 set post_corefile_static_array \
113 [capture_command_output "print static_array" "$print_prefix"]
114 if ![string compare $pre_corefile_static_array $post_corefile_static_array] {
115 pass "corefile restored static array"
116 } else {
117 fail "corefile restored static array"
118 }
119
120 set post_corefile_uninit_array \
121 [capture_command_output "print un_initialized_array" "$print_prefix"]
122 if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array] {
123 pass "corefile restored un-initialized array"
124 } else {
125 fail "corefile restored un-initialized array"
126 }
127
128 set post_corefile_heap_string \
129 [capture_command_output "print heap_string" "$print_prefix"]
130 if ![string compare $pre_corefile_heap_string $post_corefile_heap_string] {
131 pass "corefile restored heap array"
132 } else {
133 fail "corefile restored heap array"
134 }
135
136 set post_corefile_local_array \
137 [capture_command_output "print array_func::local_array" "$print_prefix"]
138 if ![string compare $pre_corefile_local_array $post_corefile_local_array] {
139 pass "corefile restored stack array"
140 } else {
141 fail "corefile restored stack array"
142 }
143
144 set post_corefile_backtrace [capture_command_output "backtrace" ""]
145 if ![string compare $pre_corefile_backtrace $post_corefile_backtrace] {
146 pass "corefile restored backtrace"
147 } else {
148 fail "corefile restored backtrace"
149 }