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 IP 0x12345671 9 #define CS 0x12345672 10 #define FLAGS 0x12345673 11 #define SP 0x12345674 12 #define SS 0x12345675 13 14 #define STRING(x) XSTRING(x) 15 #define XSTRING(x) #x 16 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) 17 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname 18 19 struct interrupt_frame 20 { 21 uword_t ip; 22 uword_t cs; 23 uword_t flags; 24 uword_t sp; 25 uword_t ss; 26 }; 27 28 __attribute__((interrupt, used)) 29 void fn(struct interrupt_frame * frame)30fn (struct interrupt_frame *frame) 31 { 32 if (IP != frame->ip) /* BREAK */ 33 __builtin_abort (); 34 if (CS != frame->cs) 35 __builtin_abort (); 36 if (FLAGS != frame->flags) 37 __builtin_abort (); 38 if (SP != frame->sp) 39 __builtin_abort (); 40 if (SS != frame->ss) 41 __builtin_abort (); 42 43 exit (0); 44 } 45 46 int main()47main () 48 { 49 asm ("push $" STRING (SS) "; \ 50 push $" STRING (SP) "; \ 51 push $" STRING (FLAGS) "; \ 52 push $" STRING (CS) "; \ 53 push $" STRING (IP) "; \ 54 jmp " ASMNAME ("fn")); 55 return 0; 56 } 57 58 /* { dg-final { gdb-test 30 "frame->ip" "0x12345671" } } */ 59 /* { dg-final { gdb-test 30 "frame->cs" "0x12345672" } } */ 60 /* { dg-final { gdb-test 30 "frame->flags" "0x12345673" } } */ 61 /* { dg-final { gdb-test 30 "frame->sp" "0x12345674" } } */ 62 /* { dg-final { gdb-test 30 "frame->ss" "0x12345675" } } */ 63