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