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