diff options
Diffstat (limited to 'editors/openoffice.org-2.0-devel/files/patch-backtrace')
-rw-r--r-- | editors/openoffice.org-2.0-devel/files/patch-backtrace | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/editors/openoffice.org-2.0-devel/files/patch-backtrace b/editors/openoffice.org-2.0-devel/files/patch-backtrace new file mode 100644 index 000000000000..523bba02d5e4 --- /dev/null +++ b/editors/openoffice.org-2.0-devel/files/patch-backtrace @@ -0,0 +1,95 @@ +Issuetracker : #i56946# +CWS : N/A +Author : <maho@openoffice.org> (JCA) +Description : FreeBSD porting : An implementation of backtrace at sal/osl/unx +To pass the compilation, we had been preparing dummy function at sal. +We implemented this. + +--- sal/osl/unx/backtrace.c Thu Sep 8 23:52:44 2005 ++++ sal/osl/unx/backtrace.c Sun Oct 23 09:19:04 2005 +@@ -129,6 +129,7 @@ + #include <pthread.h> + #include <setjmp.h> + #include <stdio.h> ++#include <stddef.h> + #include "backtrace.h" + + #define FRAME_PTR_OFFSET 1 +@@ -136,11 +137,55 @@ + + int backtrace( void **buffer, int max_frames ) + { +- return 1; ++ struct frame *fp; ++ jmp_buf ctx; ++ int i; ++ /* get stack- and framepointer */ ++ setjmp(ctx); ++ fp = (struct frame*)(((size_t*)(ctx))[FRAME_PTR_OFFSET]); ++ for ( i=0; (i<FRAME_OFFSET) && (fp!=0); i++) ++ fp = fp->fr_savfp; ++ /* iterate through backtrace */ ++ for (i=0; fp && fp->fr_savpc && i<max_frames; i++) ++ { ++ /* store frame */ ++ *(buffer++) = (void *)fp->fr_savpc; ++ /* next frame */ ++ fp=fp->fr_savfp; ++ } ++ return i; + } + + void backtrace_symbols_fd( void **buffer, int size, int fd ) + { ++ FILE *fp = fdopen( fd, "w" ); ++ ++ if ( fp ) ++ { ++ void **pFramePtr; ++ for ( pFramePtr = buffer; size > 0 && pFramePtr && *pFramePtr; pFramePtr++, size-- ) ++ { ++ Dl_info dli; ++ ptrdiff_t offset; ++ ++ if ( 0 != dladdr( *pFramePtr, &dli ) ) ++ { ++ if ( dli.dli_fname && dli.dli_fbase ) ++ { ++ offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_fbase; ++ fprintf( fp, "%s+0x%x", dli.dli_fname, offset ); ++ } ++ if ( dli.dli_sname && dli.dli_saddr ) ++ { ++ offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_saddr; ++ fprintf( fp, "(%s+0x%x)", dli.dli_sname, offset ); ++ } ++ } ++ fprintf( fp, "[0x%x]\n", *pFramePtr ); ++ } ++ fflush( fp ); ++ fclose( fp ); ++ } + + } + #endif /* defined FREEBSD */ + +--- sal/osl/unx/backtrace.h Thu Sep 8 23:52:59 2005 ++++ sal/osl/unx/backtrace.h Sun Oct 23 09:19:40 2005 +@@ -46,6 +46,16 @@ + + void backtrace_symbols_fd( void **buffer, int size, int fd ); + ++/* no frame.h on FreeBSD */ ++#if defined FREEBSD ++struct frame { ++ long arg0[8]; ++ long arg1[6]; ++ struct frame *fr_savfp; ++ long fr_savpc; ++}; ++#endif ++ + #ifdef __cplusplus + } /* extern "C" */ + #endif + |