This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] MIPS/Linux MD_FALLBACK_FRAME_STATE_FOR (final version)


The only change from previously authorized but uncommited version:

http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00808.html

is changing "__u_int32_t" to "u_int32_t". It is unclear to me why the previous version worked.

crosscompiler tested for mipsisa32el-linux target.

=== gcc Summary ===

# of expected passes		24080
# of unexpected failures	38
# of unexpected successes	3
# of expected failures		78
# of unresolved testcases	40
# of untested testcases		7
# of unsupported tests		261


None of the failures seem related to unwinding which is what this patch is all about.


O.K. to commit?

David Daney
Index: gcc/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.1427
diff -u -3 -p -r2.1427 ChangeLog
--- gcc/ChangeLog	15 Oct 2003 17:24:38 -0000	2.1427
+++ gcc/ChangeLog	15 Oct 2003 21:55:07 -0000
@@ -1,3 +1,13 @@
+2003-10-15  David Daney  <ddaney@avtrex.com>
+
+	* config/mips/linux.h (MD_FALLBACK_FRAME_STATE_FOR): New
+	* gcc/config/mips/mips.h (DWARF_FRAME_REGNUM): Fixed to allow unwind
+	from leaf functions.
+	(DWARF_FRAME_RETURN_COLUMN): Ditto.
+	(SIGNAL_UNWIND_RETURN_COLUMN): New, used
+	by MD_FALLBACK_FRAME_STATE_FOR.
+	* gcc/testsuite/gcc.dg/cleanup-9.c: Added mips*-*-linux* target.
+
 2003-10-15  Olivier Hainque  <hainque@act-europe.fr>
 
 	* genmodes.c (calc_wider_mode): Allocate enough room for all the
Index: gcc/config/mips/linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/linux.h,v
retrieving revision 1.67
diff -u -3 -p -r1.67 linux.h
--- gcc/config/mips/linux.h	27 Sep 2003 04:48:25 -0000	1.67
+++ gcc/config/mips/linux.h	15 Oct 2003 21:55:08 -0000
@@ -190,3 +190,73 @@ Boston, MA 02111-1307, USA.  */
 %{!static:-rpath-link %R/lib:%R/usr/lib} \
 %{!shared: %{pthread:-lpthread} \
   %{profile:-lc_p} %{!profile: -lc}}"
+
+/* Do code reading to identify a signal frame, and set the frame
+   state data appropriately.  See unwind-dw2.c for the structs.  */
+#ifdef IN_LIBGCC2
+#include <signal.h>
+
+/* The third parameter to the signal handler points to something with
+ * this structure defined in asm/ucontext.h, but the name clashes with
+ * struct ucontext from sys/ucontext.h so this private copy is used. */
+typedef struct _sig_ucontext {
+    unsigned long         uc_flags;
+    struct _sig_ucontext  *uc_link;
+    stack_t               uc_stack;
+    struct sigcontext uc_mcontext;
+    sigset_t      uc_sigmask;
+} _sig_ucontext_t;
+
+#endif /* IN_LIBGCC2  */
+
+#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)            \
+  do {                                                               \
+    u_int32_t *pc_ = (u_int32_t *) (CONTEXT)->ra;                \
+    struct sigcontext *sc_;                                          \
+    _Unwind_Ptr new_cfa_;                                            \
+    int i_;                                                          \
+                                                                     \
+    /* 24021061 li v0, 0x1061 (rt_sigreturn)*/                       \
+    /* 0000000c syscall    */                                        \
+    /*    or */                                                      \
+    /* 24021017 li v0, 0x1017 (sigreturn) */                         \
+    /* 0000000c syscall  */                                          \
+    if (*(pc_ + 1) != 0x0000000c)                                    \
+      break;                                                         \
+    if (*(pc_ + 0) == 0x24021017)                                    \
+      {                                                              \
+        struct sigframe {                                            \
+          u_int32_t  trampoline[2];                                \
+          struct sigcontext sigctx;                                  \
+        } *rt_ = (CONTEXT)->ra;                                      \
+        sc_ = &rt_->sigctx;                                          \
+      }                                                              \
+    else if (*(pc_ + 0) == 0x24021061)                               \
+      {                                                              \
+        struct rt_sigframe {                                         \
+          u_int32_t  trampoline[2];                                \
+          struct siginfo info;                                       \
+          _sig_ucontext_t uc;                                        \
+        } *rt_ = (CONTEXT)->ra;                                      \
+        sc_ = &rt_->uc.uc_mcontext;                                  \
+      }                                                              \
+    else                                                             \
+      break;                                                         \
+                                                                     \
+    new_cfa_ = (_Unwind_Ptr)sc_;                                     \
+    (FS)->cfa_how = CFA_REG_OFFSET;                                  \
+    (FS)->cfa_reg = STACK_POINTER_REGNUM;                            \
+    (FS)->cfa_offset = new_cfa_ - (_Unwind_Ptr) (CONTEXT)->cfa;      \
+                                                                     \
+    for (i_ = 0; i_ < 32; i_++) {                                    \
+      (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                     \
+      (FS)->regs.reg[i_].loc.offset                                  \
+        = (_Unwind_Ptr)&(sc_->sc_regs[i_]) - new_cfa_;               \
+    }                                                                \
+    (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].how = REG_SAVED_OFFSET; \
+    (FS)->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].loc.offset           \
+        = (_Unwind_Ptr)&(sc_->sc_pc) - new_cfa_;                     \
+    (FS)->retaddr_column = SIGNAL_UNWIND_RETURN_COLUMN;              \
+                                                                     \
+    goto SUCCESS;                                                    \
+  } while (0)
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.298
diff -u -3 -p -r1.298 mips.h
--- gcc/config/mips/mips.h	13 Oct 2003 21:16:29 -0000	1.298
+++ gcc/config/mips/mips.h	15 Oct 2003 21:55:11 -0000
@@ -1216,11 +1216,14 @@ extern const struct mips_cpu_info *mips_
 #define DBX_REGISTER_NUMBER(REGNO) mips_dbx_regno[ (REGNO) ]
 
 /* The mapping from gcc register number to DWARF 2 CFA column number.  */
-#define DWARF_FRAME_REGNUM(REG)				\
-  (REG == GP_REG_FIRST + 31 ? DWARF_FRAME_RETURN_COLUMN : REG)
+#define DWARF_FRAME_REGNUM(REG)	(REG)
 
 /* The DWARF 2 CFA column which tracks the return address.  */
-#define DWARF_FRAME_RETURN_COLUMN (FP_REG_LAST + 1)
+#define DWARF_FRAME_RETURN_COLUMN (GP_REG_FIRST + 31)
+
+/* The DWARF 2 CFA column which tracks the return address from a
+   signal handler context.  */
+#define SIGNAL_UNWIND_RETURN_COLUMN (FP_REG_LAST + 1)
 
 /* Before the prologue, RA lives in r31.  */
 #define INCOMING_RETURN_ADDR_RTX  gen_rtx_REG (VOIDmode, GP_REG_FIRST + 31)
Index: gcc/testsuite/gcc.dg/cleanup-9.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/cleanup-9.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 cleanup-9.c
--- gcc/testsuite/gcc.dg/cleanup-9.c	16 Jul 2003 11:52:55 -0000	1.2
+++ gcc/testsuite/gcc.dg/cleanup-9.c	15 Oct 2003 21:55:13 -0000
@@ -1,4 +1,4 @@
-/* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* alpha*-*-linux* powerpc*-*-linux* s390*-*-linux* sparc*-*-linux* } } */
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* alpha*-*-linux* powerpc*-*-linux* s390*-*-linux* sparc*-*-linux* mips*-*-linux* } } */
 /* { dg-options "-fasynchronous-unwind-tables -fexceptions -O2" } */
 /* Verify that cleanups work with exception handling through realtime
    signal frames.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]