Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2002-2020 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 | 20 | standard_testfile |
a911c360 | 21 | |
5b362f04 | 22 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
289f9037 | 23 | return -1 |
a911c360 MS |
24 | } |
25 | ||
3ad13771 | 26 | if { ! [ runto_main ] } then { |
84c93cd5 | 27 | untested "couldn't run to main" |
b60f0898 | 28 | return -1 |
a911c360 MS |
29 | } |
30 | ||
a911c360 MS |
31 | gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \ |
32 | "set breakpoint at terminal_func" | |
33 | ||
fda6ae12 | 34 | gdb_test "continue" "Breakpoint .* terminal_func.*" \ |
a911c360 MS |
35 | "continue to terminal_func" |
36 | ||
37 | set print_prefix ".\[0123456789\]* = " | |
38 | ||
39 | set pre_corefile_backtrace [capture_command_output "backtrace" ""] | |
40 | set pre_corefile_regs [capture_command_output "info registers" ""] | |
41 | set pre_corefile_allregs [capture_command_output "info all-reg" ""] | |
1f031429 | 42 | set pre_corefile_sysregs [capture_command_output "info reg system" ""] |
a911c360 MS |
43 | set pre_corefile_static_array \ |
44 | [capture_command_output "print static_array" "$print_prefix"] | |
45 | set pre_corefile_uninit_array \ | |
46 | [capture_command_output "print un_initialized_array" "$print_prefix"] | |
47 | set pre_corefile_heap_string \ | |
48 | [capture_command_output "print heap_string" "$print_prefix"] | |
49 | set pre_corefile_local_array \ | |
50 | [capture_command_output "print array_func::local_array" "$print_prefix"] | |
51 | set pre_corefile_extern_array \ | |
52 | [capture_command_output "print extern_array" "$print_prefix"] | |
53 | ||
289f9037 | 54 | set corefile [standard_output_file gcore.test] |
fac51dd9 | 55 | set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"] |
7d605576 DJ |
56 | if {!$core_supported} { |
57 | return -1 | |
58 | } | |
a911c360 MS |
59 | |
60 | # Now restart gdb and load the corefile. | |
61 | gdb_exit | |
62 | gdb_start | |
63 | gdb_reinitialize_dir $srcdir/$subdir | |
64 | gdb_load ${binfile} | |
65 | ||
fac51dd9 DE |
66 | set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"] |
67 | if { $core_loaded == -1 } { | |
68 | # No use proceeding from here. | |
69 | return | |
a911c360 MS |
70 | } |
71 | ||
5fa290c1 DE |
72 | gdb_test_sequence "where" "where in corefile" { |
73 | "\[\r\n\]+#0 .* terminal_func \\(\\) at " | |
74 | "\[\r\n\]+#1 .* array_func \\(\\) at " | |
75 | "\[\r\n\]+#2 .* factorial_func \\(value=1\\) at " | |
76 | "\[\r\n\]+#3 .* factorial_func \\(value=2\\) at " | |
77 | "\[\r\n\]+#4 .* factorial_func \\(value=3\\) at " | |
78 | "\[\r\n\]+#5 .* factorial_func \\(value=4\\) at " | |
79 | "\[\r\n\]+#6 .* factorial_func \\(value=5\\) at " | |
80 | "\[\r\n\]+#7 .* factorial_func \\(value=6\\) at " | |
81 | "\[\r\n\]+#8 .* main \\(.*\\) at " | |
a911c360 MS |
82 | } |
83 | ||
84 | set post_corefile_regs [capture_command_output "info registers" ""] | |
85 | if ![string compare $pre_corefile_regs $post_corefile_regs] then { | |
86 | pass "corefile restored general registers" | |
87 | } else { | |
b082f199 | 88 | fail "corefile restored general registers" |
a911c360 MS |
89 | } |
90 | ||
91 | set post_corefile_allregs [capture_command_output "info all-reg" ""] | |
92 | if ![string compare $pre_corefile_allregs $post_corefile_allregs] then { | |
93 | pass "corefile restored all registers" | |
94 | } else { | |
b082f199 | 95 | fail "corefile restored all registers" |
a911c360 MS |
96 | } |
97 | ||
1f031429 PA |
98 | set post_corefile_sysregs [capture_command_output "info reg system" ""] |
99 | if ![string compare $pre_corefile_sysregs $post_corefile_sysregs] then { | |
100 | pass "corefile restored system registers" | |
101 | } else { | |
102 | fail "corefile restored system registers" | |
103 | } | |
104 | ||
a911c360 MS |
105 | set post_corefile_extern_array \ |
106 | [capture_command_output "print extern_array" "$print_prefix"] | |
a911c360 MS |
107 | if ![string compare $pre_corefile_extern_array $post_corefile_extern_array] { |
108 | pass "corefile restored extern array" | |
109 | } else { | |
110 | fail "corefile restored extern array" | |
111 | } | |
112 | ||
113 | set post_corefile_static_array \ | |
114 | [capture_command_output "print static_array" "$print_prefix"] | |
a911c360 MS |
115 | if ![string compare $pre_corefile_static_array $post_corefile_static_array] { |
116 | pass "corefile restored static array" | |
117 | } else { | |
118 | fail "corefile restored static array" | |
119 | } | |
120 | ||
121 | set post_corefile_uninit_array \ | |
122 | [capture_command_output "print un_initialized_array" "$print_prefix"] | |
a911c360 MS |
123 | if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array] { |
124 | pass "corefile restored un-initialized array" | |
125 | } else { | |
126 | fail "corefile restored un-initialized array" | |
127 | } | |
128 | ||
129 | set post_corefile_heap_string \ | |
130 | [capture_command_output "print heap_string" "$print_prefix"] | |
a911c360 MS |
131 | if ![string compare $pre_corefile_heap_string $post_corefile_heap_string] { |
132 | pass "corefile restored heap array" | |
133 | } else { | |
134 | fail "corefile restored heap array" | |
135 | } | |
136 | ||
137 | set post_corefile_local_array \ | |
138 | [capture_command_output "print array_func::local_array" "$print_prefix"] | |
a911c360 MS |
139 | if ![string compare $pre_corefile_local_array $post_corefile_local_array] { |
140 | pass "corefile restored stack array" | |
141 | } else { | |
142 | fail "corefile restored stack array" | |
143 | } | |
144 | ||
145 | set post_corefile_backtrace [capture_command_output "backtrace" ""] | |
146 | if ![string compare $pre_corefile_backtrace $post_corefile_backtrace] { | |
147 | pass "corefile restored backtrace" | |
148 | } else { | |
149 | fail "corefile restored backtrace" | |
150 | } |