OSDN Git Service

Copyright updates for 2007.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / gdb.arch / i386-prologue.c
1 /* Unwinder test program.
2
3    Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
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
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
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.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.  */
21
22 #ifdef SYMBOL_PREFIX
23 #define SYMBOL(str)     SYMBOL_PREFIX #str
24 #else
25 #define SYMBOL(str)     #str
26 #endif
27
28 void gdb1253 (void);
29 void gdb1718 (void);
30 void gdb1338 (void);
31 void jump_at_beginning (void);
32
33 int
34 main (void)
35 {
36   standard ();
37   stack_align_ecx ();
38   stack_align_edx ();
39   stack_align_eax ();
40   gdb1253 ();
41   gdb1718 ();
42   gdb1338 ();
43   jump_at_beginning ();
44   return 0;
45 }
46
47 /* A normal prologue.  */
48
49 asm(".text\n"
50     "    .align 8\n"
51     SYMBOL (standard) ":\n"
52     "    pushl %ebp\n"
53     "    movl  %esp, %ebp\n"
54     "    pushl %edi\n"
55     "    int   $0x03\n"
56     "    leave\n"
57     "    ret\n");
58
59 /* Relevant part of the prologue from symtab/1253.  */
60
61 asm(".text\n"
62     "    .align 8\n"
63     SYMBOL (gdb1253) ":\n"
64     "    pushl %ebp\n"
65     "    xorl  %ecx, %ecx\n"
66     "    movl  %esp, %ebp\n"
67     "    pushl %edi\n"
68     "    int   $0x03\n"
69     "    leave\n"
70     "    ret\n");
71
72 /* Relevant part of the prologue from backtrace/1718.  */
73
74 asm(".text\n"
75     "    .align 8\n"
76     SYMBOL (gdb1718) ":\n"
77     "    pushl %ebp\n"
78     "    movl  $0x11111111, %eax\n"
79     "    movl  %esp, %ebp\n"
80     "    pushl %esi\n"
81     "    movl  $0x22222222, %esi\n"
82     "    pushl %ebx\n"
83     "    int   $0x03\n"
84     "    leave\n"
85     "    ret\n");
86
87 /* Relevant part of the prologue from backtrace/1338.  */
88
89 asm(".text\n"
90     "    .align 8\n"
91     SYMBOL (gdb1338) ":\n"
92     "    pushl %edi\n"
93     "    pushl %esi\n"
94     "    pushl %ebx\n"
95     "    int   $0x03\n"
96     "    popl  %ebx\n"
97     "    popl  %esi\n"
98     "    popl  %edi\n"
99     "    ret\n");
100
101 /* The purpose of this function is to verify that, during prologue
102    skip, GDB does not follow a jump at the beginnning of the "real"
103    code.  */
104
105 asm(".text\n"
106     "    .align 8\n"
107     SYMBOL (jump_at_beginning) ":\n"
108     "    pushl %ebp\n"
109     "    movl  %esp,%ebp\n"
110     "    jmp   .gdbjump\n"
111     "    nop\n"
112     ".gdbjump:\n"
113     "    movl  %ebp,%esp\n"
114     "    popl  %ebp\n"
115     "    ret\n");
116
117 asm(".text\n"
118     "    .align 8\n"
119     SYMBOL (stack_align_ecx) ":\n"
120     "    leal  4(%esp), %ecx\n"
121     "    andl  $-16, %esp\n"
122     "    pushl -4(%ecx)\n"
123     "    pushl %ebp\n"
124     "    movl  %esp, %ebp\n"
125     "    pushl %edi\n"
126     "    pushl %ecx\n"
127     "    int   $0x03\n"
128     "    popl  %ecx\n"
129     "    popl  %edi\n"
130     "    popl  %ebp\n"
131     "    leal  -4(%ecx), %esp\n"
132     "    ret\n");
133
134 asm(".text\n"
135     "    .align 8\n"
136     SYMBOL (stack_align_edx) ":\n"
137     "    leal  4(%esp), %edx\n"
138     "    andl  $-16, %esp\n"
139     "    pushl -4(%edx)\n"
140     "    pushl %ebp\n"
141     "    movl  %esp, %ebp\n"
142     "    pushl %edi\n"
143     "    pushl %ecx\n"
144     "    int   $0x03\n"
145     "    popl  %ecx\n"
146     "    popl  %edi\n"
147     "    popl  %ebp\n"
148     "    leal  -4(%edx), %esp\n"
149     "    ret\n");
150
151 asm(".text\n"
152     "    .align 8\n"
153     SYMBOL (stack_align_eax) ":\n"
154     "    leal  4(%esp), %eax\n"
155     "    andl  $-16, %esp\n"
156     "    pushl -4(%eax)\n"
157     "    pushl %ebp\n"
158     "    movl  %esp, %ebp\n"
159     "    pushl %edi\n"
160     "    pushl %ecx\n"
161     "    int   $0x03\n"
162     "    popl  %ecx\n"
163     "    popl  %edi\n"
164     "    popl  %ebp\n"
165     "    leal  -4(%eax), %esp\n"
166     "    ret\n");
167