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/hppa-hpux] MD_FALLBACK_FRAME_STATE_FOR definition


John David Anglin wrote:
> Sure, I would like to see it.

 Here it goes (changed the subject). This is the untouched version of what we
 experiment with for Ada against 3.2.

 Part of that is from exchanges we had something like a year ago :)
 I'm not clear what the NO_PROFILE_COUNTERS story was about in 3.2.

 I'll be glad to test/help/adjust further on more recent versions. I'm away
 from the office this week, though, and will only recover full access to my
 working environment by next monday.

 Olivier

*** gcc/config/pa/pa-hpux.h.ori	Tue Mar 30 11:37:24 2004
--- gcc/config/pa/pa-hpux.h	Tue Mar 30 12:03:25 2004
***************
*** 116,118 ****
--- 116,177 ----
     compatibility with the HP-UX unwind library.  */
  #undef TARGET_HPUX_UNWIND_LIBRARY
  #define TARGET_HPUX_UNWIND_LIBRARY 1
+ 
+ /* Define the necessary stuff for the DWARF2 CFI support.  */
+ 
+ #define NO_PROFILE_COUNTERS 1
+ #define DWARF2_UNWIND_INFO 1
+ 
+ /* This macro chooses the encoding of pointers embedded in the exception
+    handling sections.  If at all possible, this should be defined such
+    that the exception handling section will not require dynamic relocations,
+    and so may be read-only.
+ 
+    FIXME:  This should use an indirect data relative encoding for code
+    labels and function pointers.  We used DW_EH_PE_aligned to output
+    a PLABEL constructor.  */
+ #undef ASM_PREFERRED_EH_DATA_FORMAT
+ #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)                     \
+   (CODE == 2 && GLOBAL ? DW_EH_PE_aligned : DW_EH_PE_absptr)
+ 
+ /* Handle special EH pointer encodings.  Absolute, pc-relative, and
+    indirect are handled automatically.  Since pc-relative encodining is
+    not possible on the PA and we don't have the infrastructure for
+    data relative encoding, we use aligned plabels for code labels
+    and function pointers.  */
+ #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
+   do {                                                                       \
+     if (((ENCODING) & 0x0F) == DW_EH_PE_aligned)                      \
+       {                                                                      \
+       fputs (integer_asm_op ((SIZE), FALSE), FILE);                   \
+       fputs ("P%", FILE);                                             \
+       assemble_name (FILE, XSTR ((ADDR), 0));                         \
+       goto DONE;                                                      \
+       }                                                                      \
+     } while (0)
+ 
+ 
+ /* A C expression whose value is RTL representing the location of the incoming
+    return address at the beginning of any function, before the prologue. This
+    RTL is either a REG, indicating that the return value is saved in `REG', or
+    a MEM representing a location in the stack.
+ 
+    You only need to define this macro if you want to support call frame
+    debugging information like that provided by DWARF 2.
+ 
+    If this RTL is a REG, you should also define DWARF_FRAME_RETURN_COLUMN to
+    DWARF_FRAME_REGNUM (REGNO).  */
+ #define INCOMING_RETURN_ADDR_RTX  (gen_rtx_REG (word_mode, 2))
+ #define DWARF_FRAME_RETURN_COLUMN (DWARF_FRAME_REGNUM (2))
+ 
+ /* A C expression whose value is an integer giving the offset, in bytes, from
+    the value of the stack pointer register to the top of the stack frame at
+    the beginning of any function, before the prologue. The top of the frame is
+    defined to be the value of the stack pointer in the previous frame, just
+    before the call instruction.
+ 
+    You only need to define this macro if you want to support call frame
+    debugging information like that provided by DWARF 2.  */
+ #define INCOMING_FRAME_SP_OFFSET 0
+ 
+ #include "config/pa/hpux-ehfb.h"
*** gcc/config/pa/hpux-ehfb.h.ori	Thu Jun  6 18:35:18 2002
--- gcc/config/pa/hpux-ehfb.h	Thu Jun  6 17:37:06 2002
***************
*** 0 ****
--- 1,132 ----
+ /* This has been put in a separate file to avoid having to recompile the
+    world after each modification.  */
+    
+ /* Do code reading to identify a signal frame or a linker stub and set the
+    frame state data appropriately.  See unwind-dw2.c for the structs.  */
+ 
+ #ifdef IN_LIBGCC2
+ #include <stdlib.h>
+ #include <signal.h>
+ #include <sys/ucontext.h>
+ #endif
+ 
+ #define UPDATE_FS_FOR_GR(FS, GRN, GCCN) \
+ (FS)->regs.reg[GCCN].how = REG_SAVED_OFFSET;				\
+ (FS)->regs.reg[GCCN].loc.offset = \
+   ( (UseWideRegs(mc_)) \
+     ? (long) &( (mc_)->ss_wide.ss_32.ss_gr##GRN##_lo ) \
+     : (long) &( (mc_)->ss_narrow.ss_gr##GRN ) \
+   ) - new_cfa_;
+ 
+ #define UPDATE_FS_FOR_FR(FS, FRN, GCCN) \
+ (FS)->regs.reg[GCCN].how = REG_SAVED_OFFSET;				\
+ (FS)->regs.reg[GCCN].loc.offset =  \
+   ( (long) &( (mc_)->ss_fr##FRN ) \
+   ) - new_cfa_;
+ 
+ #define UPDATE_FS_FOR_PC(FS, N) \
+ (FS)->regs.reg[N].how = REG_SAVED_OFFSET;				\
+ (FS)->regs.reg[N].loc.offset = \
+   ( (UseWideRegs(mc_)) \
+     ? (long) &( (mc_)->ss_wide.ss_32.ss_pcoq_head_lo ) \
+     : (long) &( (mc_)->ss_narrow.ss_pcoq_head ) \
+   ) - new_cfa_;
+ 
+ #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)		\
+   do {									\
+   char * eh_debug_env = getenv ("EH_DEBUG");                            \
+   int  eh_debug = eh_debug_env ? atoi (eh_debug_env) : 0;               \
+   unsigned char * pc_ = (unsigned char *)(CONTEXT)->ra;                 \
+                                                                         \
+   if (eh_debug)                                                         \
+     printf ("FALLBACK called for ra @ 0x%p\n", pc_);                    \
+                                                                         \
+   if (pc_ == 0) break;                                                  \
+                                                                         \
+   if (eh_debug)                                                         \
+     printf ("FALLBACK : Checking for stub ...");                        \
+                                                                         \
+  /* Check if the return address we have is in an export stub : */       \
+                                                                         \
+   if (   *(unsigned int *)(pc_+0)  == 0x4bc23fd1                        \
+       && *(unsigned int *)(pc_+4)  == 0x004010a1                        \
+       && *(unsigned int *)(pc_+8)  == 0x00011820                        \
+       && *(unsigned int *)(pc_+12) == 0xe0400002)                       \
+     {                                                                   \
+       if (eh_debug)                                                     \
+         printf (" Got it !\n");                                         \
+                                                                         \
+       (FS)->cfa_how    = CFA_REG_OFFSET;                                \
+       (FS)->cfa_reg    = 30;                                            \
+       (FS)->cfa_offset = 0;                                             \
+                                                                         \
+       (FS)->retaddr_column = 2;                                         \
+       (FS)->regs.reg[2].how = REG_SAVED_OFFSET;                         \
+       (FS)->regs.reg[2].loc.offset = -24;                               \
+                                                                         \
+       goto SUCCESS;                                                     \
+     }                                                                   \
+                                                                         \
+   if (eh_debug)                                                         \
+     printf ("\nFALLBACK : Checking for signal handler ...");            \
+                                                                         \
+  /* Check if the return address is in a call to sig handler : */        \
+                                                                         \
+   if (   *(unsigned int *)(pc_-28) == 0x4bc23fd9                      \
+       && *(unsigned int *)(pc_-24) == 0x4bd33fc9                        \
+       && *(unsigned int *)(pc_-20) == 0x00014004                      \
+       && *(unsigned int *)(pc_-16) == 0x004010a1                       \
+       && *(unsigned int *)(pc_-12) == 0x00011820 )                       \
+     {                                                                   \
+       ucontext_t * sc_ = (CONTEXT)->cfa - 1352;                         \
+       mcontext_t * mc_ = & sc_->uc_mcontext;                            \
+                                                                         \
+       long new_cfa_ = GetSSReg (mc_, ss_sp);                            \
+       long new_ra_ = GetSSReg (mc_, ss_pcoq_head);                      \
+                                                                         \
+       if (eh_debug)                                                     \
+         printf (" Got it !\n");                                         \
+                                                                         \
+       (FS)->cfa_how = CFA_REG_OFFSET;                                   \
+       (FS)->cfa_reg = 30;                                               \
+       (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;              \
+                                                                         \
+       UPDATE_FS_FOR_GR((FS), 3, 3);                                     \
+       UPDATE_FS_FOR_GR((FS), 4, 4);                                     \
+       UPDATE_FS_FOR_GR((FS), 5, 5);                                     \
+       UPDATE_FS_FOR_GR((FS), 6, 6);                                     \
+       UPDATE_FS_FOR_GR((FS), 7, 7);                                     \
+       UPDATE_FS_FOR_GR((FS), 8, 8);                                     \
+       UPDATE_FS_FOR_GR((FS), 9, 9);                                     \
+       UPDATE_FS_FOR_GR((FS), 10, 10);                                   \
+       UPDATE_FS_FOR_GR((FS), 11, 11);                                   \
+       UPDATE_FS_FOR_GR((FS), 12, 12);                                   \
+       UPDATE_FS_FOR_GR((FS), 13, 13);                                   \
+       UPDATE_FS_FOR_GR((FS), 14, 14);                                   \
+       UPDATE_FS_FOR_GR((FS), 15, 15);                                   \
+       UPDATE_FS_FOR_GR((FS), 16, 16);                                   \
+       UPDATE_FS_FOR_GR((FS), 17, 17);                                   \
+       UPDATE_FS_FOR_GR((FS), 18, 18);                                   \
+                                                                         \
+       UPDATE_FS_FOR_FR((FS), 12, 48);                                   \
+       UPDATE_FS_FOR_FR((FS), 13, 50);                                   \
+       UPDATE_FS_FOR_FR((FS), 14, 52);                                   \
+       UPDATE_FS_FOR_FR((FS), 15, 54);                                   \
+       UPDATE_FS_FOR_FR((FS), 16, 56);                                   \
+       UPDATE_FS_FOR_FR((FS), 17, 58);                                   \
+       UPDATE_FS_FOR_FR((FS), 18, 60);                                   \
+       UPDATE_FS_FOR_FR((FS), 19, 62);                                   \
+       UPDATE_FS_FOR_FR((FS), 20, 64);                                   \
+       UPDATE_FS_FOR_FR((FS), 21, 66);                                   \
+                                                                         \
+       (FS)->retaddr_column = 2;                                         \
+       UPDATE_FS_FOR_PC((FS), 2);                                        \
+                                                                         \
+       goto SUCCESS;                                                     \
+     }                                                                   \
+                                                                         \
+     if (eh_debug)                                                       \
+       printf ("\nFALLBACK : Givin up :(\n");                            \
+                                                                         \
+     break;                                                              \
+   } while (0)



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