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