aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2006-10-11 19:11:29 +0000
committerJoseph Myers <joseph@codesourcery.com>2006-10-11 19:11:29 +0000
commitfdc10739972aab7ae3a51323064f217f03b5cd85 (patch)
treeae367614e5825167196e550f460239fd915e745f /gcc/testsuite
parent75b2f34ad72f3ead5a8e8ab23a222c71e7049813 (diff)
Backport:
2005-11-23 Ben Elliston <bje@au.ibm.com> * dwarf2.h (enum dwarf_type): Add DW_ATE_decimal_float. 2006-03-01 Jakub Jelinek <jakub@redhat.com> * dwarf2.h (DW_TAG_condition, DW_TAG_shared_type): New constants from DWARF 3. (DW_AT_description, DW_AT_binary_scale, DW_AT_decimal_scale, DW_AT_small, DW_AT_decimal_sign, DW_AT_digit_count, DW_AT_picture_string, DW_AT_mutable, DW_AT_threads_scaled, DW_AT_explicit, DW_AT_object_pointer, DW_AT_endianity, DW_AT_elemental, DW_AT_pure, DW_AT_recursive): New. (DW_OP_form_tls_address, DW_OP_call_frame_cfa, DW_OP_bit_piece): New. (DW_ATE_packed_decimal, DW_ATE_numeric_string, DW_ATE_edited, DW_ATE_signed_fixed, DW_ATE_unsigned_fixed): New. (DW_DS_unsigned, DW_DS_leading_overpunch, DW_DS_trailing_overpunch, DW_DS_leading_separate, DW_DS_trailing_separate): New. (DW_END_default, DW_END_big, DW_END_little): New. (DW_END_lo_user, DW_END_hi_user): Define. (DW_LNE_lo_user, DW_LNE_hi_user): Define. (DW_CFA_val_offset, DW_CFA_val_offset_sf, DW_CFA_val_expression): New. (DW_LANG_PLI, DW_LANG_ObjC, DW_LANG_ObjC_plus_plus, DW_LANG_UPC, DW_LANG_D): New. 2006-03-04 Jakub Jelinek <jakub@redhat.com> * unwind-dw2.h (_Unwind_FrameState): Add REG_SAVED_VAL_OFFSET and REG_SAVED_VAL_EXP constants. * unwind-dw2.c (struct _Unwind_Context): Add by_value array. (_Unwind_GetGR, _Unwind_SetGR, _Unwind_GetGRPtr, _Unwind_SetGRPtr): Handle regs stored by value. (_Unwind_SetGRValue, _Unwind_GRByValue): New functions. (execute_cfa_program): Handle DW_CFA_val_offset, DW_CFA_val_offset_sf and DW_CFA_val_expression. (uw_update_context_1): Handle REG_SAVED_REG with regs stored by value specially. Handle REG_SAVED_VAL_OFFSET and REG_SAVED_VAL_EXP. (uw_install_context_1): Handle target regs stored by value. 2006-03-04 Jakub Jelinek <jakub@redhat.com> * gcc.target/i386/cleanup-1.c: New test. * gcc.target/i386/cleanup-2.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/csl/sourcerygxx-4_1@117640 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.target/i386/cleanup-1.c240
-rw-r--r--gcc/testsuite/gcc.target/i386/cleanup-2.c205
2 files changed, 445 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/cleanup-1.c b/gcc/testsuite/gcc.target/i386/cleanup-1.c
new file mode 100644
index 00000000000..afc1e0ae85f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cleanup-1.c
@@ -0,0 +1,240 @@
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-fexceptions -fnon-call-exceptions -fasynchronous-unwind-tables -O2" } */
+/* Test complex CFA value expressions. */
+
+#include <unwind.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static _Unwind_Reason_Code
+force_unwind_stop (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exc_class,
+ struct _Unwind_Exception *exc_obj,
+ struct _Unwind_Context *context,
+ void *stop_parameter)
+{
+ if (actions & _UA_END_OF_STACK)
+ abort ();
+ return _URC_NO_REASON;
+}
+
+static void
+force_unwind ()
+{
+ struct _Unwind_Exception *exc = malloc (sizeof (*exc));
+ memset (&exc->exception_class, 0, sizeof (exc->exception_class));
+ exc->exception_cleanup = 0;
+
+ _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
+ abort ();
+}
+
+int count;
+
+static void
+counter (void *p __attribute__((unused)))
+{
+ ++count;
+}
+
+static void
+handler (void *p __attribute__((unused)))
+{
+ if (count != 2)
+ abort ();
+ _exit (0);
+}
+
+static int __attribute__((noinline))
+fn5 (void)
+{
+ char dummy __attribute__((cleanup (counter)));
+ force_unwind ();
+ return 0;
+}
+
+void
+bar (void)
+{
+ char dummy __attribute__((cleanup (counter)));
+ fn5 ();
+}
+
+void __attribute__((noinline))
+foo (int x)
+{
+ char buf[256];
+#ifdef __i386__
+ __asm (
+ "testl %0, %0\n\t"
+ "jnz 1f\n\t"
+ ".subsection 1\n\t"
+ ".type _L_mutex_lock_%=, @function\n"
+"_L_mutex_lock_%=:\n"
+"1:\t" "leal %1, %%ecx\n"
+"2:\t" "call bar\n"
+"3:\t" "jmp 18f\n"
+"4:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
+ ".previous\n\t"
+ ".section .eh_frame,\"a\",@progbits\n"
+"5:\t" ".long 7f-6f # Length of Common Information Entry\n"
+"6:\t" ".long 0x0 # CIE Identifier Tag\n\t"
+ ".byte 0x1 # CIE Version\n\t"
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t"
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t"
+ ".sleb128 -4 # CIE Data Alignment Factor\n\t"
+ ".byte 0x8 # CIE RA Column\n\t"
+ ".uleb128 0x1 # Augmentation size\n\t"
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t"
+ ".byte 0xc # DW_CFA_def_cfa\n\t"
+ ".uleb128 0x4\n\t"
+ ".uleb128 0x0\n\t"
+ ".align 4\n"
+"7:\t" ".long 17f-8f # FDE Length\n"
+"8:\t" ".long 8b-5b # FDE CIE offset\n\t"
+ ".long 1b-. # FDE initial location\n\t"
+ ".long 4b-1b # FDE address range\n\t"
+ ".uleb128 0x0 # Augmentation size\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x8\n\t"
+ ".uleb128 10f-9f\n"
+"9:\t" ".byte 0x78 # DW_OP_breg8\n\t"
+ ".sleb128 3b-1b\n"
+"10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x8\n\t"
+ ".uleb128 12f-11f\n"
+"11:\t" ".byte 0x78 # DW_OP_breg8\n\t"
+ ".sleb128 3b-2b\n"
+"12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x8\n\t"
+ ".uleb128 16f-13f\n"
+"13:\t" ".byte 0x78 # DW_OP_breg8\n\t"
+ ".sleb128 15f-14f\n\t"
+ ".byte 0x0d # DW_OP_const4s\n"
+"14:\t" ".4byte 3b-.\n\t"
+ ".byte 0x1c # DW_OP_minus\n\t"
+ ".byte 0x0d # DW_OP_const4s\n"
+"15:\t" ".4byte 18f-.\n\t"
+ ".byte 0x22 # DW_OP_plus\n"
+"16:\t" ".align 4\n"
+"17:\t" ".previous\n"
+"18:"
+ : : "r" (x), "m" (x), "r" (buf)
+ : "memory", "eax", "edx", "ecx");
+#elif defined __x86_64__
+ __asm (
+ "testl %0, %0\n\t"
+ "jnz 1f\n\t"
+ ".subsection 1\n\t"
+ ".type _L_mutex_lock_%=, @function\n"
+"_L_mutex_lock_%=:\n"
+"1:\t" "leaq %1, %%rdi\n"
+"2:\t" "subq $128, %%rsp\n"
+"3:\t" "call bar\n"
+"4:\t" "addq $128, %%rsp\n"
+"5:\t" "jmp 24f\n"
+"6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
+ ".previous\n\t"
+ ".section .eh_frame,\"a\",@progbits\n"
+"7:\t" ".long 9f-8f # Length of Common Information Entry\n"
+"8:\t" ".long 0x0 # CIE Identifier Tag\n\t"
+ ".byte 0x1 # CIE Version\n\t"
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t"
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t"
+ ".sleb128 -8 # CIE Data Alignment Factor\n\t"
+ ".byte 0x10 # CIE RA Column\n\t"
+ ".uleb128 0x1 # Augmentation size\n\t"
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t"
+ ".byte 0x12 # DW_CFA_def_cfa_sf\n\t"
+ ".uleb128 0x7\n\t"
+ ".sleb128 16\n\t"
+ ".align 8\n"
+"9:\t" ".long 23f-10f # FDE Length\n"
+"10:\t" ".long 10b-7b # FDE CIE offset\n\t"
+ ".long 1b-. # FDE initial location\n\t"
+ ".long 6b-1b # FDE address range\n\t"
+ ".uleb128 0x0 # Augmentation size\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x10\n\t"
+ ".uleb128 12f-11f\n"
+"11:\t" ".byte 0x80 # DW_OP_breg16\n\t"
+ ".sleb128 4b-1b\n"
+"12:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x10\n\t"
+ ".uleb128 14f-13f\n"
+"13:\t" ".byte 0x80 # DW_OP_breg16\n\t"
+ ".sleb128 4b-2b\n"
+"14:\t" ".byte 0x40 + (3b-2b) # DW_CFA_advance_loc\n\t"
+ ".byte 0x0e # DW_CFA_def_cfa_offset\n\t"
+ ".uleb128 0\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x10\n\t"
+ ".uleb128 16f-15f\n"
+"15:\t" ".byte 0x80 # DW_OP_breg16\n\t"
+ ".sleb128 4b-3b\n"
+"16:\t" ".byte 0x40 + (4b-3b-1) # DW_CFA_advance_loc\n\t"
+ ".byte 0x0e # DW_CFA_def_cfa_offset\n\t"
+ ".uleb128 128\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x10\n\t"
+ ".uleb128 20f-17f\n"
+"17:\t" ".byte 0x80 # DW_OP_breg16\n\t"
+ ".sleb128 19f-18f\n\t"
+ ".byte 0x0d # DW_OP_const4s\n"
+"18:\t" ".4byte 4b-.\n\t"
+ ".byte 0x1c # DW_OP_minus\n\t"
+ ".byte 0x0d # DW_OP_const4s\n"
+"19:\t" ".4byte 24f-.\n\t"
+ ".byte 0x22 # DW_OP_plus\n"
+"20:\t" ".byte 0x40 + (5b-4b+1) # DW_CFA_advance_loc\n\t"
+ ".byte 0x13 # DW_CFA_def_cfa_offset_sf\n\t"
+ ".sleb128 16\n\t"
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x10\n\t"
+ ".uleb128 22f-21f\n"
+"21:\t" ".byte 0x80 # DW_OP_breg16\n\t"
+ ".sleb128 4b-5b\n"
+"22:\t" ".align 8\n"
+"23:\t" ".previous\n"
+"24:"
+ : : "r" (x), "m" (x), "r" (buf)
+ : "memory", "rax", "rdx", "rcx", "rsi", "rdi",
+ "r8", "r9", "r10", "r11");
+#else
+# error Unsupported test architecture
+#endif
+}
+
+static int __attribute__((noinline))
+fn2 (void)
+{
+ foo (3);
+ return 0;
+}
+
+static int __attribute__((noinline))
+fn1 (void)
+{
+ fn2 ();
+ return 0;
+}
+
+static void *
+fn0 (void)
+{
+ char dummy __attribute__((cleanup (handler)));
+ fn1 ();
+ return 0;
+}
+
+int
+main (void)
+{
+ fn0 ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/cleanup-2.c b/gcc/testsuite/gcc.target/i386/cleanup-2.c
new file mode 100644
index 00000000000..a171077f79a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cleanup-2.c
@@ -0,0 +1,205 @@
+/* { dg-do run { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */
+/* { dg-options "-fexceptions -fnon-call-exceptions -fasynchronous-unwind-tables -O2" } */
+/* Test complex CFA value expressions. */
+
+#include <unwind.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static _Unwind_Reason_Code
+force_unwind_stop (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exc_class,
+ struct _Unwind_Exception *exc_obj,
+ struct _Unwind_Context *context,
+ void *stop_parameter)
+{
+ if (actions & _UA_END_OF_STACK)
+ abort ();
+ return _URC_NO_REASON;
+}
+
+static void
+force_unwind ()
+{
+ struct _Unwind_Exception *exc = malloc (sizeof (*exc));
+ memset (&exc->exception_class, 0, sizeof (exc->exception_class));
+ exc->exception_cleanup = 0;
+
+ _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
+ abort ();
+}
+
+int count;
+
+static void
+counter (void *p __attribute__((unused)))
+{
+ ++count;
+}
+
+static void
+handler (void *p __attribute__((unused)))
+{
+ if (count != 2)
+ abort ();
+ _exit (0);
+}
+
+static int __attribute__((noinline))
+fn5 (void)
+{
+ char dummy __attribute__((cleanup (counter)));
+ force_unwind ();
+ return 0;
+}
+
+void
+bar (void)
+{
+ char dummy __attribute__((cleanup (counter)));
+ fn5 ();
+}
+
+void __attribute__((noinline))
+foo (int x)
+{
+ char buf[256];
+#ifdef __x86_64__
+ __asm (
+ "testl %0, %0\n\t"
+ "jnz 1f\n\t"
+ ".subsection 1\n\t"
+ ".type _L_mutex_lock_%=, @function\n"
+"_L_mutex_lock_%=:\n"
+"1:\t" "leaq %1, %%rdi\n"
+"2:\t" "subq $128, %%rsp\n"
+"3:\t" "call bar\n"
+"4:\t" "addq $128, %%rsp\n"
+"5:\t" "jmp 21f\n"
+"6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
+ ".previous\n\t"
+ ".section .eh_frame,\"a\",@progbits\n"
+"7:\t" ".long 9f-8f # Length of Common Information Entry\n"
+"8:\t" ".long 0x0 # CIE Identifier Tag\n\t"
+ ".byte 0x1 # CIE Version\n\t"
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t"
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t"
+ ".sleb128 -8 # CIE Data Alignment Factor\n\t"
+ ".byte 0x10 # CIE RA Column\n\t"
+ ".uleb128 0x1 # Augmentation size\n\t"
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t"
+ ".byte 0xc # DW_CFA_def_cfa\n\t"
+ ".uleb128 0x7\n\t"
+ ".uleb128 0x0\n\t"
+ ".align 8\n"
+"9:\t" ".long 20f-10f # FDE Length\n"
+"10:\t" ".long 10b-7b # FDE CIE offset\n\t"
+ ".long 1b-. # FDE initial location\n\t"
+ ".long 6b-1b # FDE address range\n\t"
+ ".uleb128 0x0 # Augmentation size\n\t"
+ /* This CFA expression computes the address right
+ past the jnz instruction above, from %rip somewhere
+ within the _L_mutex_lock_%= subsection. */
+ ".byte 0x16 # DW_CFA_val_expression\n\t"
+ ".uleb128 0x10\n\t"
+ ".uleb128 19f-11f\n"
+"11:\t" ".byte 0x80 # DW_OP_breg16\n\t"
+ ".sleb128 0\n"
+"12:\t" ".byte 0x12 # DW_OP_dup\n\t"
+ ".byte 0x94 # DW_OP_deref_size\n\t"
+ ".byte 1\n\t"
+ ".byte 0x12 # DW_OP_dup\n\t"
+ ".byte 0x08 # DW_OP_const1u\n\t"
+ ".byte 0x48\n\t"
+ ".byte 0x2e # DW_OP_ne\n\t"
+ ".byte 0x28 # DW_OP_bra\n\t"
+ ".2byte 16f-13f\n"
+"13:\t" ".byte 0x13 # DW_OP_drop\n\t"
+ ".byte 0x23 # DW_OP_plus_uconst\n\t"
+ ".uleb128 1\n\t"
+ ".byte 0x12 # DW_OP_dup\n\t"
+ ".byte 0x94 # DW_OP_deref_size\n\t"
+ ".byte 1\n\t"
+ ".byte 0x08 # DW_OP_const1u\n\t"
+ ".byte 0x81\n\t"
+ ".byte 0x2e # DW_OP_ne\n\t"
+ ".byte 0x28 # DW_OP_bra\n\t"
+ ".2byte 15f-14f\n"
+"14:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
+ ".uleb128 3b-2b-1\n\t"
+ ".byte 0x2f # DW_OP_skip\n\t"
+ ".2byte 12b-15f\n"
+"15:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
+ ".uleb128 2b-1b-1\n\t"
+ ".byte 0x2f # DW_OP_skip\n\t"
+ ".2byte 12b-16f\n"
+"16:\t" ".byte 0x08 # DW_OP_const1u\n\t"
+ ".byte 0xe8\n\t"
+ ".byte 0x2e # DW_OP_ne\n\t"
+ ".byte 0x28 # DW_OP_bra\n\t"
+ ".2byte 18f-17f\n"
+"17:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
+ ".uleb128 4b-3b\n\t"
+ ".byte 0x2f # DW_OP_skip\n\t"
+ ".2byte 12b-18f\n"
+"18:\t" ".byte 0x23 # DW_OP_plus_uconst\n\t"
+ ".uleb128 1\n\t"
+ ".byte 0x12 # DW_OP_dup\n\t"
+ ".byte 0x94 # DW_OP_deref_size\n\t"
+ ".byte 4\n\t"
+ ".byte 0x08 # DW_OP_const1u\n\t"
+ ".byte 72 - (6b-5b) * 8 # (6b-5b) == 5 ? 32 : 56\n\t"
+ ".byte 0x24 # DW_OP_shl\n\t"
+ ".byte 0x08 # DW_OP_const1u\n\t"
+ ".byte 72 - (6b-5b) * 8 # (6b-5b) == 5 ? 32 : 56\n\t"
+ ".byte 0x26 # DW_OP_shra\n\t"
+ ".byte 0x22 # DW_OP_plus\n\t"
+ ".byte 0x23 # DW_OP_plus_uconst\n\t"
+ ".uleb128 6b-5b-1\n"
+"19:\t" ".byte 0x40 + (3b-1b) # DW_CFA_advance_loc\n\t"
+ ".byte 0xe # DW_CFA_def_cfa_offset\n\t"
+ ".uleb128 128\n\t"
+ ".byte 0x40 + (5b-3b) # DW_CFA_advance_loc\n\t"
+ ".byte 0xe # DW_CFA_def_cfa_offset\n\t"
+ ".uleb128 0\n\t"
+ ".align 8\n"
+"20:\t" ".previous\n"
+"21:"
+ : : "r" (x), "m" (x), "r" (buf)
+ : "memory", "rax", "rdx", "rcx", "rsi", "rdi",
+ "r8", "r9", "r10", "r11");
+#else
+# error Unsupported test architecture
+#endif
+}
+
+static int __attribute__((noinline))
+fn2 (void)
+{
+ foo (3);
+ return 0;
+}
+
+static int __attribute__((noinline))
+fn1 (void)
+{
+ fn2 ();
+ return 0;
+}
+
+static void *
+fn0 (void)
+{
+ char dummy __attribute__((cleanup (handler)));
+ fn1 ();
+ return 0;
+}
+
+int
+main (void)
+{
+ fn0 ();
+ return 0;
+}