]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/i386-prologue.exp
[gdb/tdep] Fix gdb.base/watchpoint-running.exp on {arm,ppc64le}-linux
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-prologue.exp
1 # Copyright (C) 2003-2024 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 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@gnu.org
18
19 # This file is part of the gdb testsuite.
20
21 # Test i386 prologue analyzer.
22
23
24 require is_x86_like_target
25
26 set testfile "i386-prologue"
27 set srcfile ${testfile}.c
28 set binfile [standard_output_file ${testfile}]
29
30 # some targets have leading underscores on assembly symbols.
31 set additional_flags [gdb_target_symbol_prefix_flags]
32
33 # Don't use "debug", so that we don't have line information for the assembly
34 # fragments.
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list $additional_flags]] != "" } {
36 untested "failed to compile"
37 return -1
38 }
39
40
41 # The code used by the tests here encodes some breakpoints by using
42 # inline assembler. This will generate a SIGTRAP which will be caught
43 # by GDB. At that point the instruction pointer will point at the
44 # next instruction, and execution can continue without any problems.
45 # Some systems however (QNX Neutrino, Solaris) will adjust the
46 # instruction pointer to point at the breakpoint instruction instead.
47 # On these systems we cannot continue unless we skip it. This
48 # procedure takes care of that.
49
50 proc skip_breakpoint { msg } {
51 gdb_test "if (*(unsigned char *)\$pc == 0xcc)\nset \$pc = \$pc + 1\nend" \
52 "" "skip breakpoint in ${msg}"
53 }
54
55
56 clean_restart $binfile
57
58 #
59 # Run to `main' where we begin our tests.
60 #
61
62 if {![runto_main]} {
63 return 0
64 }
65
66 # Testcase for standard prologue.
67
68 gdb_test "continue" "Program received signal SIGTRAP.*" "continue to standard"
69
70 skip_breakpoint standard
71
72 gdb_test "backtrace 10" \
73 "#0\[ \t\]*$hex in standard.*\r\n#1\[ \t\]*$hex in main.*" \
74 "backtrace in standard"
75
76 gdb_test "info frame" \
77 ".*Saved registers:.*ebp at.*edi at.*eip at.*" \
78 "saved registers in standard"
79
80
81 # Testcase from breakpoints/2080 (when %ecx is used)
82
83 gdb_test "break *(stack_align_ecx + 7)" \
84 "Breakpoint \[0-9\]* at $hex"
85
86 gdb_test "continue" \
87 "Breakpoint \[0-9\]*.*stack_align_ecx.*" \
88 "continue to stack_align_ecx + 7"
89
90 gdb_test "backtrace 10" \
91 "#0\[ \t\]*$hex in stack_align_ecx.*\r\n#1\[ \t\]*$hex in main.*" \
92 "first backtrace in stack_align_ecx"
93
94 gdb_test "continue" \
95 "Program received signal SIGTRAP.*" \
96 "continue in stack_align_ecx"
97
98 skip_breakpoint stack_align_ecx
99
100 gdb_test "backtrace 10" \
101 "#0\[ \t\]*$hex in stack_align_ecx.*\r\n#1\[ \t\]*$hex in main.*" \
102 "second backtrace in stack_align_ecx"
103
104 gdb_test "info frame" \
105 ".*Saved registers:.*ecx at.*ebp at.*edi at.*eip at.*" \
106 "saved registers in stack_align_ecx"
107
108
109 # Testcase from breakpoints/2080 (when %edx is used)
110
111 gdb_test "break *(stack_align_edx + 7)" \
112 "Breakpoint \[0-9\]* at $hex"
113
114 gdb_test "continue" \
115 "Breakpoint \[0-9\]*.*stack_align_edx.*" \
116 "continue to stack_align_edx + 7"
117
118 gdb_test "backtrace 10" \
119 "#0\[ \t\]*$hex in stack_align_edx.*\r\n#1\[ \t\]*$hex in main.*" \
120 "first backtrace in stack_align_edx"
121
122 gdb_test "continue" \
123 "Program received signal SIGTRAP.*" \
124 "continue in stack_align_edx"
125
126 skip_breakpoint stack_align_edx
127
128 gdb_test "backtrace 10" \
129 "#0\[ \t\]*$hex in stack_align_edx.*\r\n#1\[ \t\]*$hex in main.*" \
130 "second backtrace in stack_align_edx"
131
132 gdb_test "info frame" \
133 ".*Saved registers:.*ecx at.*ebp at.*edi at.*eip at.*" \
134 "saved registers in stack_align_edx"
135
136
137 # Testcase from breakpoints/2080 (when %eax is used)
138
139 gdb_test "break *(stack_align_eax + 7)" \
140 "Breakpoint \[0-9\]* at $hex"
141
142 gdb_test "continue" \
143 "Breakpoint \[0-9\]*.*stack_align_eax.*" \
144 "continue to stack_align_eax + 7"
145
146 gdb_test "backtrace 10" \
147 "#0\[ \t\]*$hex in stack_align_eax.*\r\n#1\[ \t\]*$hex in main.*" \
148 "first backtrace in stack_align_eax"
149
150 gdb_test "continue" \
151 "Program received signal SIGTRAP.*" \
152 "continue in stack_align_eax"
153
154 skip_breakpoint stack_align_eax
155
156 gdb_test "backtrace 10" \
157 "#0\[ \t\]*$hex in stack_align_eax.*\r\n#1\[ \t\]*$hex in main.*" \
158 "second backtrace in stack_align_eax"
159
160 gdb_test "info frame" \
161 ".*Saved registers:.*ecx at.*ebp at.*edi at.*eip at.*" \
162 "saved registers in stack_align_eax"
163
164
165 # Testcase from symtab/1253.
166
167 gdb_test "continue" "Program received signal SIGTRAP.*" "continue to gdb1253"
168
169 skip_breakpoint gdb1253
170
171 gdb_test "backtrace 10" \
172 "#0\[ \t\]*$hex in gdb1253.*\r\n#1\[ \t\]*$hex in main.*" \
173 "backtrace in gdb1253"
174
175 gdb_test "info frame" \
176 ".*Saved registers:.*ebp at.*edi at.*eip at.*" \
177 "saved registers in gdb1253"
178
179
180 # Testcase from backtrace/1718.
181
182 gdb_test "continue" "Program received signal SIGTRAP.*" "continue to gdb1718"
183
184 skip_breakpoint gdb1718
185
186 gdb_test "backtrace 10" \
187 "#0\[ \t\]*$hex in gdb1718.*\r\n#1\[ \t\]*$hex in main.*" \
188 "backtrace in gdb1718"
189
190 setup_kfail gdb/1718 *-*-*
191 gdb_test "info frame" \
192 ".*Saved registers:.*esi at.*ebx at.*eip at.*" \
193 "saved registers in gdb1718"
194
195
196 # Testcase from backtrace/1338.
197
198 gdb_test "continue" "Program received signal SIGTRAP.*" "continue to gdb1338"
199
200 skip_breakpoint gdb1338
201
202 gdb_test "backtrace 10" \
203 "#0\[ \t\]*$hex in gdb1338.*\r\n#1\[ \t\]*$hex in main.*" \
204 "backtrace in gdb1338"
205
206 gdb_test "info frame" \
207 ".*Saved registers:.*ebx at.*esi at.*edi at.*eip at.*" \
208 "saved registers in gdb1338"
209
210 # Testcase jump_at_beginning.
211 gdb_test_multiple "break jump_at_beginning" \
212 "set breakpoint in jump_at_beginning" {
213 -re "Breakpoint \[0-9\]* at ($hex).*$gdb_prompt $" {
214 gdb_test "x/i $expect_out(1,string)" \
215 ".*<jump_at_beginning.*>:.*jmp.*" \
216 "check jump_at_beginning prologue end"
217 }
218 default {
219 fail "set breakpoint in jump_at_beginning"
220 }
221 }