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