diff options
-rw-r--r-- | src/log.c | 92 |
1 files changed, 46 insertions, 46 deletions
@@ -26,9 +26,9 @@ #define _GNU_SOURCE #include <stdarg.h> #include <syslog.h> +#include <stdlib.h> #include <execinfo.h> #include <dlfcn.h> -#include <stdlib.h> #include "connman.h" @@ -104,6 +104,49 @@ void connman_debug(const char *format, ...) va_end(ap); } +static void signal_handler(int signo) +{ + void *frames[64]; + char **symbols; + size_t n_ptrs; + unsigned int i; + + n_ptrs = backtrace(frames, G_N_ELEMENTS(frames)); + symbols = backtrace_symbols(frames, n_ptrs); + if (symbols == NULL) { + connman_error("No backtrace symbols"); + exit(1); + } + + connman_error("Aborting (signal %d)", signo); + connman_error("++++++++ backtrace ++++++++"); + + for (i = 1; i < n_ptrs; i++) + connman_error("[%d]: %s", i - 1, symbols[i]); + + connman_error("+++++++++++++++++++++++++++"); + + g_free(symbols); + exit(1); +} + +static void signal_setup(sighandler_t handler) +{ + struct sigaction sa; + sigset_t mask; + + sigemptyset(&mask); + sa.sa_handler = handler; + sa.sa_mask = mask; + sa.sa_flags = 0; + sigaction(SIGBUS, &sa, NULL); + sigaction(SIGILL, &sa, NULL); + sigaction(SIGFPE, &sa, NULL); + sigaction(SIGSEGV, &sa, NULL); + sigaction(SIGABRT, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); +} + extern struct connman_debug_desc __start___debug[]; extern struct connman_debug_desc __stop___debug[]; @@ -152,49 +195,6 @@ static connman_bool_t is_enabled(struct connman_debug_desc *desc) return FALSE; } -static void signal_handler(int signo) -{ - void *frames[64]; - char **symbols; - size_t n_ptrs; - unsigned int i; - - n_ptrs = backtrace(frames, G_N_ELEMENTS(frames)); - symbols = backtrace_symbols(frames, n_ptrs); - if (symbols == NULL) { - connman_error("No backtrace symbols"); - exit(1); - } - - connman_error("Aborting (signal %d)", signo); - connman_error("++++++++ ConnMan backtrace ++++++++"); - - for (i = 1; i < n_ptrs; i++) - connman_error("[%d]: %s", i - 1, symbols[i]); - - connman_error("++++++++++++++++++++++++++++++++++++"); - - g_free(symbols); - exit(1); -} - -static void signal_setup(sighandler_t handler) -{ - struct sigaction sa; - sigset_t mask; - - sigemptyset(&mask); - sa.sa_handler = handler; - sa.sa_mask = mask; - sa.sa_flags = 0; - sigaction(SIGBUS, &sa, NULL); - sigaction(SIGILL, &sa, NULL); - sigaction(SIGFPE, &sa, NULL); - sigaction(SIGSEGV, &sa, NULL); - sigaction(SIGABRT, &sa, NULL); - sigaction(SIGPIPE, &sa, NULL); -} - int __connman_log_init(const char *debug, connman_bool_t detach) { int option = LOG_NDELAY | LOG_PID; @@ -241,7 +241,7 @@ void __connman_log_cleanup(void) closelog(); - g_strfreev(enabled); - signal_setup(SIG_DFL); + + g_strfreev(enabled); } |