1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */ 2 /* { dg-options "-g -mgeneral-regs-only" } */ 3 4 extern void exit (int); 5 6 typedef unsigned int uword_t __attribute__ ((mode (__word__))); 7 8 #define ERROR 0x12345670 9 #define IP 0x12345671 10 #define CS 0x12345672 11 #define FLAGS 0x12345673 12 #define SP 0x12345674 13 #define SS 0x12345675 14 15 #define STRING(x) XSTRING(x) 16 #define XSTRING(x) #x 17 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) 18 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname 19 20 struct interrupt_frame 21 { 22 uword_t ip; 23 uword_t cs; 24 uword_t flags; 25 uword_t sp; 26 uword_t ss; 27 }; 28 29 __attribute__((naked, used)) 30 void fn(void)31fn (void) 32 { 33 register uword_t *sp __asm__("sp"); 34 uword_t error = *sp; 35 struct interrupt_frame *frame = (struct interrupt_frame *) (sp + 1); 36 if (ERROR != error) /* BREAK */ 37 __builtin_abort (); 38 if (IP != frame->ip) 39 __builtin_abort (); 40 if (CS != frame->cs) 41 __builtin_abort (); 42 if (FLAGS != frame->flags) 43 __builtin_abort (); 44 if (SP != frame->sp) 45 __builtin_abort (); 46 if (SS != frame->ss) 47 __builtin_abort (); 48 49 exit (0); 50 } 51 52 int main()53main () 54 { 55 asm ("push $" STRING (SS) "; \ 56 push $" STRING (SP) "; \ 57 push $" STRING (FLAGS) "; \ 58 push $" STRING (CS) "; \ 59 push $" STRING (IP) "; \ 60 push $" STRING (ERROR) "; \ 61 jmp " ASMNAME ("fn")); 62 return 0; 63 } 64 65 /* { dg-final { gdb-test 36 "error" "0x12345670" } } */ 66 /* { dg-final { gdb-test 36 "frame->ip" "0x12345671" } } */ 67 /* { dg-final { gdb-test 36 "frame->cs" "0x12345672" } } */ 68 /* { dg-final { gdb-test 36 "frame->flags" "0x12345673" } } */ 69 /* { dg-final { gdb-test 36 "frame->sp" "0x12345674" } } */ 70 /* { dg-final { gdb-test 36 "frame->ss" "0x12345675" } } */ 71