1 /* { dg-do run { target *-*-linux* } } */
2 /* { dg-require-effective-target lp64 } */
3 /* { dg-options "-fexceptions -fnon-call-exceptions -fasynchronous-unwind-tables -O2" } */
4 /* Test complex CFA value expressions. */
12 static _Unwind_Reason_Code
13 force_unwind_stop (int version, _Unwind_Action actions,
14 _Unwind_Exception_Class exc_class,
15 struct _Unwind_Exception *exc_obj,
16 struct _Unwind_Context *context,
19 if (actions & _UA_END_OF_STACK)
21 return _URC_NO_REASON;
27 struct _Unwind_Exception *exc = malloc (sizeof (*exc));
28 memset (&exc->exception_class, 0, sizeof (exc->exception_class));
29 exc->exception_cleanup = 0;
31 _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
38 counter (void *p __attribute__((unused)))
44 handler (void *p __attribute__((unused)))
51 static int __attribute__((noinline))
54 char dummy __attribute__((cleanup (counter)));
62 char dummy __attribute__((cleanup (counter)));
66 void __attribute__((noinline))
75 ".type _L_mutex_lock_%=, @function\n"
77 "1:\t" "leaq %1, %%rdi\n"
78 "2:\t" "subq $128, %%rsp\n"
80 "4:\t" "addq $128, %%rsp\n"
82 "6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
84 ".section .eh_frame,\"a\",@progbits\n"
85 "7:\t" ".long 9f-8f # Length of Common Information Entry\n"
86 "8:\t" ".long 0x0 # CIE Identifier Tag\n\t"
87 ".byte 0x1 # CIE Version\n\t"
88 ".ascii \"zR\\0\" # CIE Augmentation\n\t"
89 ".uleb128 0x1 # CIE Code Alignment Factor\n\t"
90 ".sleb128 -8 # CIE Data Alignment Factor\n\t"
91 ".byte 0x10 # CIE RA Column\n\t"
92 ".uleb128 0x1 # Augmentation size\n\t"
93 ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t"
94 ".byte 0xc # DW_CFA_def_cfa\n\t"
98 "9:\t" ".long 20f-10f # FDE Length\n"
99 "10:\t" ".long 10b-7b # FDE CIE offset\n\t"
100 ".long 1b-. # FDE initial location\n\t"
101 ".long 6b-1b # FDE address range\n\t"
102 ".uleb128 0x0 # Augmentation size\n\t"
103 /* This CFA expression computes the address right
104 past the jnz instruction above, from %rip somewhere
105 within the _L_mutex_lock_%= subsection. */
106 ".byte 0x16 # DW_CFA_val_expression\n\t"
109 "11:\t" ".byte 0x80 # DW_OP_breg16\n\t"
111 "12:\t" ".byte 0x12 # DW_OP_dup\n\t"
112 ".byte 0x94 # DW_OP_deref_size\n\t"
114 ".byte 0x12 # DW_OP_dup\n\t"
115 ".byte 0x08 # DW_OP_const1u\n\t"
117 ".byte 0x2e # DW_OP_ne\n\t"
118 ".byte 0x28 # DW_OP_bra\n\t"
120 "13:\t" ".byte 0x13 # DW_OP_drop\n\t"
121 ".byte 0x23 # DW_OP_plus_uconst\n\t"
123 ".byte 0x12 # DW_OP_dup\n\t"
124 ".byte 0x94 # DW_OP_deref_size\n\t"
126 ".byte 0x08 # DW_OP_const1u\n\t"
128 ".byte 0x2e # DW_OP_ne\n\t"
129 ".byte 0x28 # DW_OP_bra\n\t"
131 "14:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
132 ".uleb128 3b-2b-1\n\t"
133 ".byte 0x2f # DW_OP_skip\n\t"
135 "15:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
136 ".uleb128 2b-1b-1\n\t"
137 ".byte 0x2f # DW_OP_skip\n\t"
139 "16:\t" ".byte 0x08 # DW_OP_const1u\n\t"
141 ".byte 0x2e # DW_OP_ne\n\t"
142 ".byte 0x28 # DW_OP_bra\n\t"
144 "17:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
146 ".byte 0x2f # DW_OP_skip\n\t"
148 "18:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
150 ".byte 0x12 # DW_OP_dup\n\t"
151 ".byte 0x94 # DW_OP_deref_size\n\t"
153 ".byte 0x08 # DW_OP_const1u\n\t"
154 ".byte 72 - (6b-5b) * 8 # (6b-5b) == 5 ? 32 : 56\n\t"
155 ".byte 0x24 # DW_OP_shl\n\t"
156 ".byte 0x08 # DW_OP_const1u\n\t"
157 ".byte 72 - (6b-5b) * 8 # (6b-5b) == 5 ? 32 : 56\n\t"
158 ".byte 0x26 # DW_OP_shra\n\t"
159 ".byte 0x22 # DW_OP_plus\n\t"
160 ".byte 0x23 # DW_OP_plus_uconst\n\t"
162 "19:\t" ".byte 0x40 + (3b-1b) # DW_CFA_advance_loc\n\t"
163 ".byte 0xe # DW_CFA_def_cfa_offset\n\t"
165 ".byte 0x40 + (5b-3b) # DW_CFA_advance_loc\n\t"
166 ".byte 0xe # DW_CFA_def_cfa_offset\n\t"
169 "20:\t" ".previous\n"
171 : : "r" (x), "m" (x), "r" (buf)
172 : "memory", "rax", "rdx", "rcx", "rsi", "rdi",
173 "r8", "r9", "r10", "r11");
175 # error Unsupported test architecture
179 static int __attribute__((noinline))
186 static int __attribute__((noinline))
196 char dummy __attribute__((cleanup (handler)));