On 30 December 2011 21:45, Abdoulaye Walsimou Gaye <[email protected]> wrote: > Trying to wrap _Unwind_GetIP with function pointer makes libubacktrace > not working for ARM, as it is defined as a preprocessor macro like this > in gcc-4.6.2: > #define _Unwind_GetIP(context) \ > (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1) > > This patch can be safely backported to 0.9.32 branch > > Signed-off-by: Abdoulaye Walsimou Gaye <[email protected]> > --- > libubacktrace/backtrace.c | 8 ++------ > 1 files changed, 2 insertions(+), 6 deletions(-) > > diff --git a/libubacktrace/backtrace.c b/libubacktrace/backtrace.c > index e5f5130..fb049bf 100644 > --- a/libubacktrace/backtrace.c > +++ b/libubacktrace/backtrace.c > @@ -34,15 +34,13 @@ struct trace_arg > }; > > static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); > -static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); > > static void backtrace_init (void) > { > void *handle = dlopen ("libgcc_s.so.1", RTLD_LAZY); > > if (handle == NULL > - || ((unwind_backtrace = dlsym (handle, "_Unwind_Backtrace")) > == NULL) > - || ((unwind_getip = dlsym (handle, "_Unwind_GetIP")) == > NULL)) { > + || ((unwind_backtrace = dlsym (handle, "_Unwind_Backtrace")) > == NULL)) { > printf("libgcc_s.so.1 must be installed for backtrace to > work\n"); > abort(); > } > @@ -53,11 +51,9 @@ backtrace_helper (struct _Unwind_Context *ctx, void *a) > { > struct trace_arg *arg = a; > > - assert (unwind_getip != NULL); > - > /* We are first called with address in the __backtrace function. Skip > it. */ > if (arg->cnt != -1) > - arg->array[arg->cnt] = (void *) unwind_getip (ctx); > + arg->array[arg->cnt] = (void *) _Unwind_GetIP(ctx); > if (++arg->cnt == arg->size) > return _URC_END_OF_STACK; > return _URC_NO_REASON; > -- > 1.7.1 >
If ARM will start differring with newer gcc, let's provide an arch specific implementation, but this has to be backward compatible with older libgcc. carmelo > _______________________________________________ > uClibc mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/uclibc _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
