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]

Re: RFA: Use _Unwind_Ptr (Was: Re: RFC / RFA: dwarf2 unwinding for targets with call-part-clobbered registers)


> On Wed, Jul 09, 2003 at 01:34:20PM +0100, Joern Rennecke wrote:
> > Do we have any targets besides sh64-elf -mb -m5-32media which are
> > big endian, use dwarf2 unwinding, and have a wider _Unwind_Word than
> > _Unwind_Ptr ?
> 
> MIPS n32.
> 
> But in that case we always save registers on the stack in word_mode,
> so reading word_mode produces correct results.  Indeed, your change
> will most certainly *break* MIPS.  I think we need something a bit
> more complex than what you're currently proposing.

I have amended my patch to use a new macro, _Unwind_SavedPtr, for the
type that is being read by _Unwind_GetPtr.  It defaults to _Unwind_Word
for backwards compatibility, and is set in TARGET_LIBGCC2_CFLAGS in sh
Makefile fragments.

2003-07-10  J"orn Rennecke <joern.rennecke@superh.com>

	* unwind.h (_Unwind_GetPtr): Declare.
        * unwind-dw2.c (_Unwind_SavedPtr): Provide default definition.
	(_Unwind_GetPtr): New function.
        (uw_update_context_1): Use it.  Use _Unwind_SavedPtr for type of
	tmp_sp.
        (uw_update_context, uw_install_context_1): Use _Unwind_GetPtr.
        (uw_init_context_1): Likewise.  Use _Unwind_SavedPtr for type of
	sp_slot.

	* config/sh/t-elf (TARGET_LIBGCC2_CFLAGS):
	Add -D_Unwind_SavedPtr=_Unwind_Ptr .
	* config/sh/t-linux (TARGET_LIBGCC2_CFLAGS): Likewise.
	* config/sh/t-netbsd-sh5 (TARGET_LIBGCC2_CFLAGS): Likewise.

Index: unwind.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/unwind.h,v
retrieving revision 1.12
diff -p -r1.12 unwind.h
*** unwind.h	7 May 2003 22:11:34 -0000	1.12
--- unwind.h	10 Jul 2003 16:09:33 -0000
*************** extern _Unwind_Reason_Code _Unwind_Backt
*** 145,150 ****
--- 145,151 ----
     selected registers maybe manipulated.  */
  
  extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
+ extern _Unwind_Ptr _Unwind_GetPtr (struct _Unwind_Context *, int);
  extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
  
  extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
Index: unwind-dw2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/unwind-dw2.c,v
retrieving revision 1.32
diff -p -r1.32 unwind-dw2.c
*** unwind-dw2.c	13 May 2003 06:49:46 -0000	1.32
--- unwind-dw2.c	10 Jul 2003 16:09:33 -0000
*************** _Unwind_GetGR (struct _Unwind_Context *c
*** 175,180 ****
--- 175,194 ----
  
  /* Get the value of the CFA as saved in CONTEXT.  */
  
+ #ifndef _Unwind_SavedPtr
+ #define _Unwind_SavedPtr _Unwind_Word
+ #endif
+ 
+ inline _Unwind_Ptr
+ _Unwind_GetPtr (struct _Unwind_Context *context, int index)
+ {
+   index = DWARF_REG_TO_UNWIND_COLUMN (index);
+   /* This will segfault if the register hasn't been saved.  */
+   return (_Unwind_Ptr) * (_Unwind_SavedPtr *) context->reg[index];
+ }
+ 
+ /* Get the value of the CFA as saved in CONTEXT.  */
+ 
  _Unwind_Word
  _Unwind_GetCFA (struct _Unwind_Context *context)
  {
*************** uw_update_context_1 (struct _Unwind_Cont
*** 1095,1101 ****
       Always zap the saved stack pointer value for the next frame; carrying
       the value over from one frame to another doesn't make sense.  */
  
!   _Unwind_Word tmp_sp;
  
    if (!_Unwind_GetGRPtr (&orig_context, __builtin_dwarf_sp_column ()))
      {
--- 1109,1115 ----
       Always zap the saved stack pointer value for the next frame; carrying
       the value over from one frame to another doesn't make sense.  */
  
!   _Unwind_SavedPtr tmp_sp;
  
    if (!_Unwind_GetGRPtr (&orig_context, __builtin_dwarf_sp_column ()))
      {
*************** uw_update_context_1 (struct _Unwind_Cont
*** 1109,1115 ****
    switch (fs->cfa_how)
      {
      case CFA_REG_OFFSET:
!       cfa = (void *) (_Unwind_Ptr) _Unwind_GetGR (&orig_context, fs->cfa_reg);
        cfa += fs->cfa_offset;
        break;
  
--- 1123,1129 ----
    switch (fs->cfa_how)
      {
      case CFA_REG_OFFSET:
!       cfa = (void *) _Unwind_GetPtr (&orig_context, fs->cfa_reg);
        cfa += fs->cfa_offset;
        break;
  
*************** uw_update_context (struct _Unwind_Contex
*** 1175,1181 ****
    /* Compute the return address now, since the return address column
       can change from frame to frame.  */
    context->ra = __builtin_extract_return_addr
!     ((void *) (_Unwind_Ptr) _Unwind_GetGR (context, fs->retaddr_column));
  }
  
  /* Fill in CONTEXT for top-of-stack.  The only valid registers at this
--- 1189,1195 ----
    /* Compute the return address now, since the return address column
       can change from frame to frame.  */
    context->ra = __builtin_extract_return_addr
!     ((void *) _Unwind_GetPtr (context, fs->retaddr_column));
  }
  
  /* Fill in CONTEXT for top-of-stack.  The only valid registers at this
*************** uw_init_context_1 (struct _Unwind_Contex
*** 1198,1204 ****
  {
    void *ra = __builtin_extract_return_addr (__builtin_return_address (0));
    _Unwind_FrameState fs;
!   _Unwind_Word sp_slot;
  
    memset (context, 0, sizeof (struct _Unwind_Context));
    context->ra = ra;
--- 1212,1218 ----
  {
    void *ra = __builtin_extract_return_addr (__builtin_return_address (0));
    _Unwind_FrameState fs;
!   _Unwind_SavedPtr sp_slot;
  
    memset (context, 0, sizeof (struct _Unwind_Context));
    context->ra = ra;
*************** uw_install_context_1 (struct _Unwind_Con
*** 1274,1281 ****
  
      /* If the last frame records a saved stack pointer, use it.  */
      if (_Unwind_GetGRPtr (target, __builtin_dwarf_sp_column ()))
!       target_cfa = (void *)(_Unwind_Ptr)
!         _Unwind_GetGR (target, __builtin_dwarf_sp_column ());
      else
        target_cfa = target->cfa;
  
--- 1288,1295 ----
  
      /* If the last frame records a saved stack pointer, use it.  */
      if (_Unwind_GetGRPtr (target, __builtin_dwarf_sp_column ()))
!       target_cfa = (void *)
!         _Unwind_GetPtr (target, __builtin_dwarf_sp_column ());
      else
        target_cfa = target->cfa;
  
Index: config/sh/t-elf
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/t-elf,v
retrieving revision 1.1
diff -p -r1.1 t-elf
*** config/sh/t-elf	2 Sep 2000 03:28:47 -0000	1.1
--- config/sh/t-elf	10 Jul 2003 16:09:33 -0000
*************** CRTSTUFF_T_CFLAGS_S = -fPIC
*** 6,9 ****
  
  # Don't compile libgcc with -fpic for now.  It's unlikely that we'll
  # build shared libraries for embedded SH.
! # TARGET_LIBGCC2_CFLAGS = -fpic
--- 6,10 ----
  
  # Don't compile libgcc with -fpic for now.  It's unlikely that we'll
  # build shared libraries for embedded SH.
! # TARGET_LIBGCC2_CFLAGS = -fpic -D_Unwind_SavedPtr=_Unwind_Ptr
! TARGET_LIBGCC2_CFLAGS = -D_Unwind_SavedPtr=_Unwind_Ptr
Index: config/sh/t-linux
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/t-linux,v
retrieving revision 1.8
diff -p -r1.8 t-linux
*** config/sh/t-linux	21 Dec 2002 23:26:16 -0000	1.8
--- config/sh/t-linux	10 Jul 2003 16:09:33 -0000
***************
*** 1,4 ****
! TARGET_LIBGCC2_CFLAGS = -fpic -DNO_FPSCR_VALUES
  LIB1ASMFUNCS_CACHE = _ic_invalidate
  
  LIB2FUNCS_EXTRA=
--- 1,4 ----
! TARGET_LIBGCC2_CFLAGS = -fpic -DNO_FPSCR_VALUES -D_Unwind_SavedPtr=_Unwind_Ptr
  LIB1ASMFUNCS_CACHE = _ic_invalidate
  
  LIB2FUNCS_EXTRA=
Index: config/sh/t-netbsd-sh5
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/t-netbsd-sh5,v
retrieving revision 1.2
diff -p -r1.2 t-netbsd-sh5
*** config/sh/t-netbsd-sh5	7 Jun 2002 00:58:44 -0000	1.2
--- config/sh/t-netbsd-sh5	10 Jul 2003 16:09:33 -0000
***************
*** 1,4 ****
! TARGET_LIBGCC2_CFLAGS = -fpic
  
  LIB2FUNCS_EXTRA=
  
--- 1,4 ----
! TARGET_LIBGCC2_CFLAGS = -fpic -D_Unwind_SavedPtr=_Unwind_Ptr
  
  LIB2FUNCS_EXTRA=
  


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