Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-prologue.c
CommitLineData
daab1251
CV
1/* Unwinder test program.
2
88b9d363 3 Copyright (C) 2003-2022 Free Software Foundation, Inc.
daab1251
CV
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
daab1251 10 (at your option) any later version.
a9762ec7 11
daab1251
CV
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
a9762ec7 16
daab1251 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
daab1251
CV
19
20#ifdef SYMBOL_PREFIX
21#define SYMBOL(str) SYMBOL_PREFIX #str
22#else
23#define SYMBOL(str) #str
24#endif
25
55ed7501 26void gdb1253 (void);
62104619 27void gdb1718 (void);
c945b932 28void gdb1338 (void);
a8958849 29void jump_at_beginning (void);
a7a0a6a9
JK
30void standard (void);
31void stack_align_ecx (void);
32void stack_align_edx (void);
33void stack_align_eax (void);
55ed7501
MK
34
35int
36main (void)
37{
b6702b23 38 standard ();
5eefc2b7
JB
39 stack_align_ecx ();
40 stack_align_edx ();
41 stack_align_eax ();
55ed7501 42 gdb1253 ();
62104619 43 gdb1718 ();
c945b932 44 gdb1338 ();
a8958849 45 jump_at_beginning ();
55ed7501
MK
46 return 0;
47}
48
b6702b23
MK
49/* A normal prologue. */
50
51asm(".text\n"
52 " .align 8\n"
53 SYMBOL (standard) ":\n"
54 " pushl %ebp\n"
55 " movl %esp, %ebp\n"
56 " pushl %edi\n"
57 " int $0x03\n"
58 " leave\n"
59 " ret\n");
60
c945b932 61/* Relevant part of the prologue from symtab/1253. */
55ed7501
MK
62
63asm(".text\n"
64 " .align 8\n"
daab1251 65 SYMBOL (gdb1253) ":\n"
55ed7501
MK
66 " pushl %ebp\n"
67 " xorl %ecx, %ecx\n"
68 " movl %esp, %ebp\n"
69 " pushl %edi\n"
70 " int $0x03\n"
71 " leave\n"
72 " ret\n");
c945b932 73
62104619
MK
74/* Relevant part of the prologue from backtrace/1718. */
75
76asm(".text\n"
77 " .align 8\n"
78 SYMBOL (gdb1718) ":\n"
79 " pushl %ebp\n"
80 " movl $0x11111111, %eax\n"
81 " movl %esp, %ebp\n"
82 " pushl %esi\n"
83 " movl $0x22222222, %esi\n"
84 " pushl %ebx\n"
85 " int $0x03\n"
86 " leave\n"
87 " ret\n");
88
c945b932
MK
89/* Relevant part of the prologue from backtrace/1338. */
90
91asm(".text\n"
92 " .align 8\n"
daab1251 93 SYMBOL (gdb1338) ":\n"
c945b932
MK
94 " pushl %edi\n"
95 " pushl %esi\n"
96 " pushl %ebx\n"
97 " int $0x03\n"
98 " popl %ebx\n"
99 " popl %esi\n"
100 " popl %edi\n"
101 " ret\n");
a8958849
MK
102
103/* The purpose of this function is to verify that, during prologue
104 skip, GDB does not follow a jump at the beginnning of the "real"
105 code. */
106
107asm(".text\n"
108 " .align 8\n"
daab1251 109 SYMBOL (jump_at_beginning) ":\n"
a8958849
MK
110 " pushl %ebp\n"
111 " movl %esp,%ebp\n"
112 " jmp .gdbjump\n"
113 " nop\n"
114 ".gdbjump:\n"
115 " movl %ebp,%esp\n"
116 " popl %ebp\n"
117 " ret\n");
31d8bdd2
MK
118
119asm(".text\n"
120 " .align 8\n"
5eefc2b7 121 SYMBOL (stack_align_ecx) ":\n"
31d8bdd2
MK
122 " leal 4(%esp), %ecx\n"
123 " andl $-16, %esp\n"
124 " pushl -4(%ecx)\n"
125 " pushl %ebp\n"
126 " movl %esp, %ebp\n"
127 " pushl %edi\n"
128 " pushl %ecx\n"
129 " int $0x03\n"
130 " popl %ecx\n"
131 " popl %edi\n"
132 " popl %ebp\n"
133 " leal -4(%ecx), %esp\n"
134 " ret\n");
5eefc2b7
JB
135
136asm(".text\n"
137 " .align 8\n"
138 SYMBOL (stack_align_edx) ":\n"
139 " leal 4(%esp), %edx\n"
140 " andl $-16, %esp\n"
141 " pushl -4(%edx)\n"
142 " pushl %ebp\n"
143 " movl %esp, %ebp\n"
144 " pushl %edi\n"
145 " pushl %ecx\n"
146 " int $0x03\n"
147 " popl %ecx\n"
148 " popl %edi\n"
149 " popl %ebp\n"
150 " leal -4(%edx), %esp\n"
151 " ret\n");
152
153asm(".text\n"
154 " .align 8\n"
155 SYMBOL (stack_align_eax) ":\n"
156 " leal 4(%esp), %eax\n"
157 " andl $-16, %esp\n"
158 " pushl -4(%eax)\n"
159 " pushl %ebp\n"
160 " movl %esp, %ebp\n"
161 " pushl %edi\n"
162 " pushl %ecx\n"
163 " int $0x03\n"
164 " popl %ecx\n"
165 " popl %edi\n"
166 " popl %ebp\n"
167 " leal -4(%eax), %esp\n"
168 " ret\n");
169
This page took 2.597166 seconds and 4 git commands to generate.