Message ID | 0fb38884-6de6-8d96-a606-b174effcd1d2@fgznet.ch |
---|---|
State | New |
Headers | show |
On 07.05.17 21:23, Andreas Tobler wrote: > Hi all, > > On FreeBSD we make use of the functions _Unwind_GetIP, _Unwind_GetIPInfo > and _Unwind_SetIP outside of GCC. All other FreeBSD targets have these > functions available except arm. > > Now since the GCC port for arm*-*-freebsd* is used more often (not only > by me ;), I was pointed out that these functions are not available. > > The below patch tries to fix this. > > Is the patch ok for trunk and after a while also for all active > branches? (7,6,5?) > > I am the FreeBSD maintainer, yes, but I prefer to have an ack since the > affected files are not only used by FreeBSD. And if somebody has better > idea, I welcome the input. Commit to trunk done. Branch commits will follow soon. Andreas > TIA, > Andreas > > 2017-05-07 Andreas Tobler <andreast@gcc.gnu.org> > > * config/arm/unwind-arm.h: Make _Unwind_GetIP, _Unwind_GetIPInfo and > _Unwind_SetIP available as functions for arm*-*-freebsd*. > * config/arm/unwind-arm.c: Implement the above. >
Index: libgcc/config/arm/unwind-arm.h =================================================================== --- libgcc/config/arm/unwind-arm.h (revision 247727) +++ libgcc/config/arm/unwind-arm.h (working copy) @@ -72,6 +72,7 @@ { return _URC_FAILURE; } +#ifndef __FreeBSD__ /* Return the address of the instruction, not the actual IP value. */ #define _Unwind_GetIP(context) \ (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1) @@ -78,6 +79,12 @@ #define _Unwind_SetIP(context, val) \ _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1)) +#else + #undef _Unwind_GetIPInfo + _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *); + _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *); + void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr); +#endif #ifdef __cplusplus } /* extern "C" */ Index: libgcc/config/arm/unwind-arm.c =================================================================== --- libgcc/config/arm/unwind-arm.c (revision 247727) +++ libgcc/config/arm/unwind-arm.c (working copy) @@ -509,3 +509,25 @@ { return __gnu_unwind_pr_common (state, ucbp, context, 2); } + +#ifdef __FreeBSD__ +/* FreeBSD expects these to be functions */ +inline _Unwind_Ptr +_Unwind_GetIP (struct _Unwind_Context *context) +{ + return _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1; +} + +inline _Unwind_Ptr +_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn) +{ + *ip_before_insn = 0; + return _Unwind_GetIP (context); +} + +inline void +_Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr val) +{ + _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1)); +} +#endif