diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-03-04 11:56:50 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-03-04 12:55:59 +0100 |
commit | 6b439e81a1916bcb42fb0fc24b1aea06e2da0d1e (patch) | |
tree | 76be824f586484ad633ff02d9120372fe4c39696 /sal | |
parent | 66ac8e60896f6306bed8fbb34606fd14474f19ce (diff) |
The backtrace() etc API is available on macOS and iOS, too
Change-Id: I9a62391c4d109cd2fd2ab60d92a9e3b631ee6773
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111951
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/backtrace.c | 69 |
1 files changed, 1 insertions, 68 deletions
diff --git a/sal/osl/unx/backtrace.c b/sal/osl/unx/backtrace.c index a3aeb3dae3f8..26005f7715af 100644 --- a/sal/osl/unx/backtrace.c +++ b/sal/osl/unx/backtrace.c @@ -212,74 +212,7 @@ void backtrace_symbols_fd( void **buffer, int size, int fd ) } } -#elif defined( MACOSX ) - -#include <dlfcn.h> -#include <stdio.h> -#include "backtrace.h" - -/* glib backtrace is only available on MacOsX 10.5 or higher - so we do it on our own */ - -int backtrace( void **buffer, int max_frames ) -{ - void **frame = (void **)__builtin_frame_address(0); - void **bp = ( void **)(*frame); - void *ip = frame[1]; - int i; - - for ( i = 0; bp && ip && i < max_frames; i++ ) - { - *(buffer++) = ip; - - ip = bp[1]; - bp = (void**)(bp[0]); - } - - return i; -} - -char ** backtrace_symbols(void * const * buffer, int size) -{ - (void)buffer; (void)size; - return NULL; /*TODO*/ -} - -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; - - if ( 0 != dladdr( *pFramePtr, &dli ) ) - { - ptrdiff_t offset; - - if ( dli.dli_fname && dli.dli_fbase ) - { - offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_fbase; - fprintf( fp, "%s+0x%tx", dli.dli_fname, offset ); - } - if ( dli.dli_sname && dli.dli_saddr ) - { - offset = (ptrdiff_t)*pFramePtr - (ptrdiff_t)dli.dli_saddr; - fprintf( fp, "(%s+0x%tx)", dli.dli_sname, offset ); - } - } - fprintf( fp, "[%p]\n", *pFramePtr ); - } - - fclose( fp ); - } -} - -#elif !defined LINUX +#elif !defined LINUX && !defined MACOSX && !defined IOS int backtrace( void **buffer, int max_frames ) { |