diff options
-rw-r--r-- | src/espik_debug.c | 22 | ||||
-rw-r--r-- | src/espik_debug.h | 7 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/espik_debug.c b/src/espik_debug.c index 9f4a121..601ef7c 100644 --- a/src/espik_debug.c +++ b/src/espik_debug.c @@ -1,15 +1,17 @@ -#if _ESPIK_DEBUG +#include "espik_debug.h" #ifdef __GLIBC__ -#include <execinfo.h> -#endif +# include <execinfo.h> +#endif /* __GLIBC__ */ -#include <stdio.h> -#include <signal.h> +#if _ESPIK_DEBUG +# include <stdio.h> +# include <signal.h> +#endif /* _ESPIK_DEBUG */ inline void espik_debug_bt (int num) { -#ifdef __GLIBC__ +#ifdef __GLIBC__ && _ESPIK_DEBUG void *array[128]; size_t size; char **strings; @@ -26,18 +28,20 @@ inline void espik_debug_bt (int num) if (strings) free(strings); #else +# ifdef __GLIBC__ fprintf(stderr, "Your system doesn't have glibc. Backtraces disabled. But program receive signal %d.\n", num); -#endif /* __GLIBC__ */ +# endif /* __GLIBC__ */ +#endif /* __GLIBC__ && _ESPIK_DEBUG */ } void espik_debug_init() { +#if _ESPIK_DEBUG struct sigaction sa; sa.sa_handler = espik_debug_bt; sigaction(SIGSEGV, &sa, (struct sigaction *)0); sigaction(SIGINT, &sa, (struct sigaction *)0); sigaction(SIGKILL, &sa, (struct sigaction *)0); +#endif } - -#endif /* _ESPIK_DEBUG */ diff --git a/src/espik_debug.h b/src/espik_debug.h index fec35e0..235c777 100644 --- a/src/espik_debug.h +++ b/src/espik_debug.h @@ -1,8 +1,7 @@ -#if _ESPIK_DEBUG -# ifndef _HAVE_ESPIK_DEBUG_H -# define _HAVE_ESPIK_DEBUG_H +#ifndef _HAVE_ESPIK_DEBUG_H +#define _HAVE_ESPIK_DEBUG_H inline void espik_bt (void); +void espik_debug_init(); # endif /* _HAVE_ESPIK_DEBUG_H */ -#endif /* _ESPIK_DEBUG */ |