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