Home | History | Annotate | Line # | Download | only in gdb.dwarf2
      1  1.1  christos /* This file comes from GCC.  If you are tempted to change it,
      2  1.1  christos    consider also changing the copy there.  */
      3  1.1  christos 
      4  1.1  christos /* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */
      5  1.1  christos /* { dg-do run } */
      6  1.1  christos /* { dg-options "-fexceptions" } */
      7  1.1  christos /* { dg-skip-if "" { "ia64-*-hpux11.*" }  { "*" } { "" } } */
      8  1.1  christos /* Verify DW_OP_* handling in the unwinder.  */
      9  1.1  christos 
     10  1.1  christos #include <unwind.h>
     11  1.1  christos #include <stdlib.h>
     12  1.1  christos #include <string.h>
     13  1.1  christos 
     14  1.1  christos /* #define OP_addr(x) 0x06, ... */
     15  1.1  christos #define OP_deref 0x06,
     16  1.1  christos #define SLEB128(x) (x)&0x7f	/* Assume here the value is -0x40 ... 0x3f.  */
     17  1.1  christos #define ULEB128(x) (x)&0x7f	/* Assume here the value is 0 ... 0x7f.  */
     18  1.1  christos #define VAL1(x) (x)&0xff
     19  1.1  christos #if defined (__BIG_ENDIAN__)
     20  1.1  christos #define VAL2(x) ((x)>>8)&0xff,(x)&0xff
     21  1.1  christos #define VAL4(x) ((x)>>24)&0xff,((x)>>16)&0xff,((x)>>8)&0xff,(x)&0xff
     22  1.1  christos #define VAL8(x) ((x)>>56)&0xff,((x)>>48)&0xff,((x)>>40)&0xff,((x)>>32)&0xff,((x)>>24)&0xff,((x)>>16)&0xff,((x)>>8)&0xff,(x)&0xff
     23  1.1  christos #elif defined(__LITTLE_ENDIAN__) || defined(__x86_64__) || defined(__i386__)
     24  1.1  christos #define VAL2(x) (x)&0xff,((x)>>8)&0xff
     25  1.1  christos #define VAL4(x) (x)&0xff,((x)>>8)&0xff,((x)>>16)&0xff,((x)>>24)&0xff
     26  1.1  christos #define VAL8(x) (x)&0xff,((x)>>8)&0xff,((x)>>16)&0xff,((x)>>24)&0xff,((x)>>32)&0xff,((x)>>40)&0xff,((x)>>48)&0xff,((x)>>56)&0xff
     27  1.1  christos #endif
     28  1.1  christos #define OP_const1u(x) 0x08,VAL1(x),
     29  1.1  christos #define OP_const1s(x) 0x09,VAL1(x),
     30  1.1  christos #define OP_const2u(x) 0x0a,VAL2(x),
     31  1.1  christos #define OP_const2s(x) 0x0b,VAL2(x),
     32  1.1  christos #define OP_const4u(x) 0x0c,VAL4(x),
     33  1.1  christos #define OP_const4s(x) 0x0d,VAL4(x),
     34  1.1  christos #define OP_const8u(x) 0x0e,VAL8(x),
     35  1.1  christos #define OP_const8s(x) 0x0f,VAL8(x),
     36  1.1  christos #define OP_constu(x) 0x10,ULEB128(x),
     37  1.1  christos #define OP_consts(x) 0x11,SLEB128(x),
     38  1.1  christos #define OP_dup 0x12,
     39  1.1  christos #define OP_drop 0x13,
     40  1.1  christos #define OP_over 0x14,
     41  1.1  christos #define OP_pick(x) 0x15,VAL1(x),
     42  1.1  christos #define OP_swap 0x16,
     43  1.1  christos #define OP_rot 0x17,
     44  1.1  christos #define OP_xderef 0x18,
     45  1.1  christos #define OP_abs 0x19,
     46  1.1  christos #define OP_and 0x1a,
     47  1.1  christos #define OP_div 0x1b,
     48  1.1  christos #define OP_minus 0x1c,
     49  1.1  christos #define OP_mod 0x1d,
     50  1.1  christos #define OP_mul 0x1e,
     51  1.1  christos #define OP_neg 0x1f,
     52  1.1  christos #define OP_not 0x20,
     53  1.1  christos #define OP_or 0x21,
     54  1.1  christos #define OP_plus 0x22,
     55  1.1  christos #define OP_plus_uconst(x) 0x23,ULEB128(x),
     56  1.1  christos #define OP_shl 0x24,
     57  1.1  christos #define OP_shr 0x25,
     58  1.1  christos #define OP_shra 0x26,
     59  1.1  christos #define OP_xor 0x27,
     60  1.1  christos #define OP_bra(x) 0x28,VAL2(x),
     61  1.1  christos #define OP_eq 0x29,
     62  1.1  christos #define OP_ge 0x2a,
     63  1.1  christos #define OP_gt 0x2b,
     64  1.1  christos #define OP_le 0x2c,
     65  1.1  christos #define OP_lt 0x2d,
     66  1.1  christos #define OP_ne 0x2e,
     67  1.1  christos #define OP_skip(x) 0x2f,VAL2(x),
     68  1.1  christos #define OP_lit0 0x30,
     69  1.1  christos #define OP_lit1 0x31,
     70  1.1  christos #define OP_lit2 0x32,
     71  1.1  christos #define OP_lit3 0x33,
     72  1.1  christos #define OP_lit4 0x34,
     73  1.1  christos #define OP_lit5 0x35,
     74  1.1  christos #define OP_lit6 0x36,
     75  1.1  christos #define OP_lit7 0x37,
     76  1.1  christos #define OP_lit8 0x38,
     77  1.1  christos #define OP_lit9 0x39,
     78  1.1  christos #define OP_lit10 0x3a,
     79  1.1  christos #define OP_lit11 0x3b,
     80  1.1  christos #define OP_lit12 0x3c,
     81  1.1  christos #define OP_lit13 0x3d,
     82  1.1  christos #define OP_lit14 0x3e,
     83  1.1  christos #define OP_lit15 0x3f,
     84  1.1  christos #define OP_lit16 0x40,
     85  1.1  christos #define OP_lit17 0x41,
     86  1.1  christos #define OP_lit18 0x42,
     87  1.1  christos #define OP_lit19 0x43,
     88  1.1  christos #define OP_lit20 0x44,
     89  1.1  christos #define OP_lit21 0x45,
     90  1.1  christos #define OP_lit22 0x46,
     91  1.1  christos #define OP_lit23 0x47,
     92  1.1  christos #define OP_lit24 0x48,
     93  1.1  christos #define OP_lit25 0x49,
     94  1.1  christos #define OP_lit26 0x4a,
     95  1.1  christos #define OP_lit27 0x4b,
     96  1.1  christos #define OP_lit28 0x4c,
     97  1.1  christos #define OP_lit29 0x4d,
     98  1.1  christos #define OP_lit30 0x4e,
     99  1.1  christos #define OP_lit31 0x4f,
    100  1.1  christos #define OP_reg0 0x50,
    101  1.1  christos #define OP_reg1 0x51,
    102  1.1  christos #define OP_reg2 0x52,
    103  1.1  christos #define OP_reg3 0x53,
    104  1.1  christos #define OP_reg4 0x54,
    105  1.1  christos #define OP_reg5 0x55,
    106  1.1  christos #define OP_reg6 0x56,
    107  1.1  christos #define OP_reg7 0x57,
    108  1.1  christos #define OP_reg8 0x58,
    109  1.1  christos #define OP_reg9 0x59,
    110  1.1  christos #define OP_reg10 0x5a,
    111  1.1  christos #define OP_reg11 0x5b,
    112  1.1  christos #define OP_reg12 0x5c,
    113  1.1  christos #define OP_reg13 0x5d,
    114  1.1  christos #define OP_reg14 0x5e,
    115  1.1  christos #define OP_reg15 0x5f,
    116  1.1  christos #define OP_reg16 0x60,
    117  1.1  christos #define OP_reg17 0x61,
    118  1.1  christos #define OP_reg18 0x62,
    119  1.1  christos #define OP_reg19 0x63,
    120  1.1  christos #define OP_reg20 0x64,
    121  1.1  christos #define OP_reg21 0x65,
    122  1.1  christos #define OP_reg22 0x66,
    123  1.1  christos #define OP_reg23 0x67,
    124  1.1  christos #define OP_reg24 0x68,
    125  1.1  christos #define OP_reg25 0x69,
    126  1.1  christos #define OP_reg26 0x6a,
    127  1.1  christos #define OP_reg27 0x6b,
    128  1.1  christos #define OP_reg28 0x6c,
    129  1.1  christos #define OP_reg29 0x6d,
    130  1.1  christos #define OP_reg30 0x6e,
    131  1.1  christos #define OP_reg31 0x6f,
    132  1.1  christos #define OP_breg0(x) 0x70,SLEB128(x),
    133  1.1  christos #define OP_breg1(x) 0x71,SLEB128(x),
    134  1.1  christos #define OP_breg2(x) 0x72,SLEB128(x),
    135  1.1  christos #define OP_breg3(x) 0x73,SLEB128(x),
    136  1.1  christos #define OP_breg4(x) 0x74,SLEB128(x),
    137  1.1  christos #define OP_breg5(x) 0x75,SLEB128(x),
    138  1.1  christos #define OP_breg6(x) 0x76,SLEB128(x),
    139  1.1  christos #define OP_breg7(x) 0x77,SLEB128(x),
    140  1.1  christos #define OP_breg8(x) 0x78,SLEB128(x),
    141  1.1  christos #define OP_breg9(x) 0x79,SLEB128(x),
    142  1.1  christos #define OP_breg10(x) 0x7a,SLEB128(x),
    143  1.1  christos #define OP_breg11(x) 0x7b,SLEB128(x),
    144  1.1  christos #define OP_breg12(x) 0x7c,SLEB128(x),
    145  1.1  christos #define OP_breg13(x) 0x7d,SLEB128(x),
    146  1.1  christos #define OP_breg14(x) 0x7e,SLEB128(x),
    147  1.1  christos #define OP_breg15(x) 0x7f,SLEB128(x),
    148  1.1  christos #define OP_breg16(x) 0x80,SLEB128(x),
    149  1.1  christos #define OP_breg17(x) 0x81,SLEB128(x),
    150  1.1  christos #define OP_breg18(x) 0x82,SLEB128(x),
    151  1.1  christos #define OP_breg19(x) 0x83,SLEB128(x),
    152  1.1  christos #define OP_breg20(x) 0x84,SLEB128(x),
    153  1.1  christos #define OP_breg21(x) 0x85,SLEB128(x),
    154  1.1  christos #define OP_breg22(x) 0x86,SLEB128(x),
    155  1.1  christos #define OP_breg23(x) 0x87,SLEB128(x),
    156  1.1  christos #define OP_breg24(x) 0x88,SLEB128(x),
    157  1.1  christos #define OP_breg25(x) 0x89,SLEB128(x),
    158  1.1  christos #define OP_breg26(x) 0x8a,SLEB128(x),
    159  1.1  christos #define OP_breg27(x) 0x8b,SLEB128(x),
    160  1.1  christos #define OP_breg28(x) 0x8c,SLEB128(x),
    161  1.1  christos #define OP_breg29(x) 0x8d,SLEB128(x),
    162  1.1  christos #define OP_breg30(x) 0x8e,SLEB128(x),
    163  1.1  christos #define OP_breg31(x) 0x8f,SLEB128(x),
    164  1.1  christos #define OP_regx(x) 0x90,SLEB128(x),
    165  1.1  christos #define OP_fbreg(x) 0x91,SLEB128(x),
    166  1.1  christos #define OP_bregx(x,y) 0x92,ULEB128(x),SLEB128(y),
    167  1.1  christos #define OP_piece(x) 0x93,ULEB128(x),
    168  1.1  christos #define OP_deref_size(x) 0x94,VAL1(x),
    169  1.1  christos #define OP_xderef_size(x) 0x95,VAL1(x),
    170  1.1  christos #define OP_nop 0x96,
    171  1.1  christos #define OP_nop_termination 0x96
    172  1.1  christos #define OP_push_object_address 0x97,
    173  1.1  christos #define OP_call2(x) 0x98,VAL2(x),
    174  1.1  christos #define OP_call4(x) 0x99,VAL4(x),
    175  1.1  christos /* #define OP_call_ref(x) 0x9a,... */
    176  1.1  christos #define OP_form_tls_address(x) 0x9b,
    177  1.1  christos #define OP_call_frame_cfa 0x9c,
    178  1.1  christos #define OP_bit_piece(x) 0x9d,ULEB128(x),
    179  1.1  christos /* #define OP_implicit_value(x...) 0x9e,... */
    180  1.1  christos #define OP_stack_value 0x9f,
    181  1.1  christos #define OP_GNU_push_tls_address 0xe0,
    182  1.1  christos /* #define OP_GNU_encoded_addr(x...) 0xf1, */
    183  1.1  christos 
    184  1.1  christos #define ASSERT_TOS_NON0 OP_bra(3) OP_skip(-3)
    185  1.1  christos #define ASSERT_TOS_0 OP_lit0 OP_eq ASSERT_TOS_NON0
    186  1.1  christos 
    187  1.1  christos /* Initially there is CFA value on the stack, we want to
    188  1.1  christos    keep it there at the end.  */
    189  1.1  christos #define CFI_PROGRAM \
    190  1.1  christos OP_lit0 OP_nop ASSERT_TOS_0						\
    191  1.1  christos OP_lit1 ASSERT_TOS_NON0							\
    192  1.1  christos OP_lit1 OP_const1u(1) OP_eq ASSERT_TOS_NON0				\
    193  1.1  christos OP_lit16 OP_const2u(16) OP_eq ASSERT_TOS_NON0				\
    194  1.1  christos OP_lit31 OP_const4u(31) OP_ne ASSERT_TOS_0				\
    195  1.1  christos OP_lit1 OP_neg OP_const1s(-1) OP_eq ASSERT_TOS_NON0			\
    196  1.1  christos OP_lit16 OP_neg OP_const2s(-16) OP_ne ASSERT_TOS_0			\
    197  1.1  christos OP_lit31 OP_const4s(-31) OP_neg OP_ne ASSERT_TOS_0			\
    198  1.1  christos OP_lit7 OP_dup OP_plus_uconst(2) OP_lit9 OP_eq ASSERT_TOS_NON0		\
    199  1.1  christos   OP_lit7 OP_eq ASSERT_TOS_NON0						\
    200  1.1  christos OP_lit20 OP_lit1 OP_drop OP_lit20 OP_eq ASSERT_TOS_NON0			\
    201  1.1  christos OP_lit17 OP_lit19 OP_over OP_lit17 OP_eq ASSERT_TOS_NON0		\
    202  1.1  christos   OP_lit19 OP_eq ASSERT_TOS_NON0 OP_lit17 OP_eq ASSERT_TOS_NON0		\
    203  1.1  christos OP_lit1 OP_lit2 OP_lit3 OP_lit4 OP_pick(2) OP_lit2 OP_eq ASSERT_TOS_NON0\
    204  1.1  christos   OP_lit4 OP_eq ASSERT_TOS_NON0 OP_lit3 OP_eq ASSERT_TOS_NON0		\
    205  1.1  christos   OP_pick(0) OP_lit2 OP_eq ASSERT_TOS_NON0				\
    206  1.1  christos   OP_lit2 OP_eq ASSERT_TOS_NON0 OP_lit1 OP_eq ASSERT_TOS_NON0		\
    207  1.1  christos OP_lit6 OP_lit12 OP_swap OP_lit6 OP_eq ASSERT_TOS_NON0			\
    208  1.1  christos   OP_lit12 OP_eq ASSERT_TOS_NON0					\
    209  1.1  christos OP_lit7 OP_lit8 OP_lit9 OP_rot OP_lit8 OP_eq ASSERT_TOS_NON0		\
    210  1.1  christos   OP_lit7 OP_eq ASSERT_TOS_NON0 OP_lit9 OP_eq ASSERT_TOS_NON0		\
    211  1.1  christos OP_lit7 OP_abs OP_lit7 OP_eq ASSERT_TOS_NON0				\
    212  1.1  christos OP_const1s(-123) OP_abs OP_const1u(123) OP_eq ASSERT_TOS_NON0		\
    213  1.1  christos OP_lit3 OP_lit6 OP_and OP_lit2 OP_eq ASSERT_TOS_NON0			\
    214  1.1  christos OP_lit3 OP_lit6 OP_or OP_lit7 OP_eq ASSERT_TOS_NON0			\
    215  1.1  christos OP_lit17 OP_lit2 OP_minus OP_lit15 OP_eq ASSERT_TOS_NON0		\
    216  1.1  christos /* Divide is signed truncating toward zero.  */				\
    217  1.1  christos OP_const1s(-6) OP_const1s(-2) OP_div OP_lit3 OP_eq ASSERT_TOS_NON0	\
    218  1.1  christos OP_const1s(-7) OP_const1s(3) OP_div OP_const1s(-2)			\
    219  1.1  christos   OP_eq ASSERT_TOS_NON0							\
    220  1.1  christos /* Modulo is unsigned.  */						\
    221  1.1  christos OP_const1s(-6) OP_const1s(-4) OP_mod OP_const1s(-6)			\
    222  1.1  christos   OP_eq ASSERT_TOS_NON0							\
    223  1.1  christos OP_const1s(-6) OP_lit4 OP_mod OP_lit2 OP_eq ASSERT_TOS_NON0		\
    224  1.1  christos OP_lit6 OP_const1s(-4) OP_mod OP_lit6 OP_eq ASSERT_TOS_NON0		\
    225  1.1  christos /* Signed modulo can be implemented using "over over div mul minus".  */\
    226  1.1  christos OP_const1s(-6) OP_const1s(-4) OP_over OP_over OP_div OP_mul OP_minus	\
    227  1.1  christos   OP_const1s(-2) OP_eq ASSERT_TOS_NON0					\
    228  1.1  christos OP_const1s(-7) OP_lit3 OP_over OP_over OP_div OP_mul OP_minus		\
    229  1.1  christos   OP_const1s(-1) OP_eq ASSERT_TOS_NON0					\
    230  1.1  christos OP_lit7 OP_const1s(-3) OP_over OP_over OP_div OP_mul OP_minus		\
    231  1.1  christos   OP_lit1 OP_eq ASSERT_TOS_NON0						\
    232  1.1  christos OP_lit16 OP_lit31 OP_plus_uconst(1) OP_mul OP_const2u(512)		\
    233  1.1  christos   OP_eq ASSERT_TOS_NON0							\
    234  1.1  christos OP_lit5 OP_not OP_lit31 OP_and OP_lit26 OP_eq ASSERT_TOS_NON0		\
    235  1.1  christos OP_lit12 OP_lit31 OP_plus OP_const1u(43) OP_eq ASSERT_TOS_NON0		\
    236  1.1  christos OP_const1s(-6) OP_lit2 OP_plus OP_const1s(-4) OP_eq ASSERT_TOS_NON0	\
    237  1.1  christos OP_const1s(-6) OP_plus_uconst(3) OP_const1s(-3) OP_eq ASSERT_TOS_NON0	\
    238  1.1  christos OP_lit16 OP_lit4 OP_shl OP_const2u(256) OP_eq ASSERT_TOS_NON0		\
    239  1.1  christos OP_lit16 OP_lit3 OP_shr OP_lit2 OP_eq ASSERT_TOS_NON0			\
    240  1.1  christos OP_const1s(-16) OP_lit3 OP_shra OP_const1s(-2) OP_eq ASSERT_TOS_NON0	\
    241  1.1  christos OP_lit3 OP_lit6 OP_xor OP_lit5 OP_eq ASSERT_TOS_NON0			\
    242  1.1  christos OP_lit3 OP_lit6 OP_le ASSERT_TOS_NON0					\
    243  1.1  christos OP_lit3 OP_lit3 OP_le ASSERT_TOS_NON0					\
    244  1.1  christos OP_lit6 OP_lit3 OP_le ASSERT_TOS_0					\
    245  1.1  christos OP_lit3 OP_lit6 OP_lt ASSERT_TOS_NON0					\
    246  1.1  christos OP_lit3 OP_lit3 OP_lt ASSERT_TOS_0					\
    247  1.1  christos OP_lit6 OP_lit3 OP_lt ASSERT_TOS_0					\
    248  1.1  christos OP_lit3 OP_lit6 OP_ge ASSERT_TOS_0					\
    249  1.1  christos OP_lit3 OP_lit3 OP_ge ASSERT_TOS_NON0					\
    250  1.1  christos OP_lit6 OP_lit3 OP_ge ASSERT_TOS_NON0					\
    251  1.1  christos OP_lit3 OP_lit6 OP_gt ASSERT_TOS_0					\
    252  1.1  christos OP_lit3 OP_lit3 OP_gt ASSERT_TOS_0					\
    253  1.1  christos OP_lit6 OP_lit3 OP_gt ASSERT_TOS_NON0					\
    254  1.1  christos OP_const1s(-6) OP_lit1 OP_shr OP_lit0 OP_gt ASSERT_TOS_NON0		\
    255  1.1  christos OP_const1s(-6) OP_lit1 OP_shra OP_lit0 OP_lt ASSERT_TOS_NON0
    256  1.1  christos 
    257  1.1  christos #define CFI_ESCAPE_VAL_2(VALUES...) #VALUES
    258  1.1  christos #define CFI_ESCAPE_VAL_1(VALUES...) CFI_ESCAPE_VAL_2(VALUES)
    259  1.1  christos #define CFI_ESCAPE_VAL(VALUES...) CFI_ESCAPE_VAL_1(VALUES)
    260  1.1  christos #define CFI_ESCAPE do { } while (0)
    261  1.1  christos #define CFI_ARCH_PROGRAM OP_nop_termination
    262  1.1  christos #ifdef __GCC_HAVE_DWARF2_CFI_ASM
    263  1.1  christos #if defined (__x86_64__)
    264  1.1  christos #undef CFI_ESCAPE
    265  1.1  christos #undef CFI_ARCH_PROGRAM
    266  1.1  christos #define CFI_ARCH_PROGRAM CFI_PROGRAM OP_lit8 OP_minus OP_nop_termination
    267  1.1  christos unsigned char cfi_arch_program[] = { CFI_ARCH_PROGRAM };
    268  1.1  christos extern char verify_it[sizeof (cfi_arch_program) - 0x80 < 0x3f80 ? 1 : -1];
    269  1.1  christos /* DW_CFA_expression %rip, uleb128(l2-l1), l1: program DW_OP_lit8 DW_OP_minus DW_OP_nop l2: */
    270  1.1  christos #define CFI_ESCAPE \
    271  1.1  christos   asm volatile (".cfi_escape 0x10, 0x10, (%P0&0x7f)+0x80, %P0>>7, " \
    272  1.1  christos 		CFI_ESCAPE_VAL (CFI_ARCH_PROGRAM) \
    273  1.1  christos 		: : "i" (sizeof (cfi_arch_program)))
    274  1.1  christos #elif defined (__i386__)
    275  1.1  christos #undef CFI_ESCAPE
    276  1.1  christos #undef CFI_ARCH_PROGRAM
    277  1.1  christos #define CFI_ARCH_PROGRAM CFI_PROGRAM OP_lit4 OP_minus OP_nop_termination
    278  1.1  christos unsigned char cfi_arch_program[] = { CFI_ARCH_PROGRAM };
    279  1.1  christos extern char verify_it[sizeof (cfi_arch_program) - 0x80 < 0x3f80 ? 1 : -1];
    280  1.1  christos /* DW_CFA_expression %eip, uleb128(l2-l1), l1: program DW_OP_lit4 DW_OP_minus DW_OP_nop l2: */
    281  1.1  christos #define CFI_ESCAPE \
    282  1.1  christos   asm volatile (".cfi_escape 0x10, 8, (%P0&0x7f)+0x80, %P0>>7, " \
    283  1.1  christos 		CFI_ESCAPE_VAL (CFI_ARCH_PROGRAM) \
    284  1.1  christos 		: : "i" (sizeof (cfi_arch_program)))
    285  1.1  christos #endif
    286  1.1  christos #endif
    287  1.1  christos static _Unwind_Reason_Code
    288  1.1  christos force_unwind_stop (int version, _Unwind_Action actions,
    289  1.1  christos 		   _Unwind_Exception_Class exc_class,
    290  1.1  christos 		   struct _Unwind_Exception *exc_obj,
    291  1.1  christos 		   struct _Unwind_Context *context,
    292  1.1  christos 		   void *stop_parameter)
    293  1.1  christos {
    294  1.1  christos   if (actions & _UA_END_OF_STACK)
    295  1.1  christos     abort ();
    296  1.1  christos   return _URC_NO_REASON;
    297  1.1  christos }
    298  1.1  christos 
    299  1.1  christos static void force_unwind ()
    300  1.1  christos {
    301  1.1  christos   struct _Unwind_Exception *exc = malloc (sizeof (*exc));
    302  1.1  christos   memset (&exc->exception_class, 0, sizeof (exc->exception_class));
    303  1.1  christos   exc->exception_cleanup = 0;
    304  1.1  christos 
    305  1.1  christos #ifndef __USING_SJLJ_EXCEPTIONS__
    306  1.1  christos   _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
    307  1.1  christos #else
    308  1.1  christos   _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
    309  1.1  christos #endif
    310  1.1  christos 
    311  1.1  christos   abort ();
    312  1.1  christos }
    313  1.1  christos 
    314  1.1  christos static void handler (void *p __attribute__((unused)))
    315  1.1  christos {
    316  1.1  christos   exit (0);
    317  1.1  christos }
    318  1.1  christos 
    319  1.1  christos __attribute__((noinline)) static void callme ()
    320  1.1  christos {
    321  1.1  christos   CFI_ESCAPE;
    322  1.1  christos   force_unwind ();
    323  1.1  christos }
    324  1.1  christos 
    325  1.1  christos __attribute__((noinline)) static void doit ()
    326  1.1  christos {
    327  1.1  christos   char dummy __attribute__((cleanup (handler)));
    328  1.1  christos   callme ();
    329  1.1  christos }
    330  1.1  christos 
    331  1.1  christos int main()
    332  1.1  christos {
    333  1.1  christos   doit ();
    334  1.1  christos   abort ();
    335  1.1  christos }
    336