aboutsummaryrefslogtreecommitdiff
path: root/src/espik_debug.c
diff options
context:
space:
mode:
authorbeber <beber>2005-12-01 20:22:19 +0000
committerbeber <beber>2005-12-01 20:22:19 +0000
commit1d217fb1cf5b137fe0758015e90e4f38a5a0ba62 (patch)
treecf92fb109d6bc4cb81a66fa1d542efae34c1fc53 /src/espik_debug.c
parentmore debug infos (diff)
downloadespik-1d217fb1cf5b137fe0758015e90e4f38a5a0ba62.tar.xz
Add a macro for __attribute__
Check if valgrinf is here Indent More debug and do better use config.h del ^_ from header
Diffstat (limited to '')
-rw-r--r--src/espik_debug.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/espik_debug.c b/src/espik_debug.c
index 601ef7c..c6e8a26 100644
--- a/src/espik_debug.c
+++ b/src/espik_debug.c
@@ -1,23 +1,26 @@
#include "espik_debug.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#ifdef __GLIBC__
# include <execinfo.h>
-#endif /* __GLIBC__ */
+#endif /* __GLIBC__ */
#if _ESPIK_DEBUG
-# include <stdio.h>
# include <signal.h>
-#endif /* _ESPIK_DEBUG */
+#endif /* _ESPIK_DEBUG */
inline void espik_debug_bt (int num)
{
#ifdef __GLIBC__ && _ESPIK_DEBUG
- void *array[128];
- size_t size;
- char **strings;
- size_t i;
+ void* array[128];
+ size_t size;
+ char** strings;
+ size_t i;
- if (!debug_bt) return;
+/* if (!debug_bt) return; */
fprintf(stderr, "\n***** Backtrace (Signal %d) *****\n", num);
size = backtrace(array, 128);
@@ -28,9 +31,9 @@ inline void espik_debug_bt (int num)
if (strings)
free(strings);
#else
-# ifdef __GLIBC__
+# ifndef __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 */
}
@@ -41,7 +44,13 @@ void espik_debug_init()
sa.sa_handler = espik_debug_bt;
sigaction(SIGSEGV, &sa, (struct sigaction *)0);
- sigaction(SIGINT, &sa, (struct sigaction *)0);
+ sigaction(SIGINT, &sa, (struct sigaction *)0);
sigaction(SIGKILL, &sa, (struct sigaction *)0);
#endif
}
+
+void kill_me (short num)
+{
+ espik_debug_bt(num);
+ exit (num);
+}