From: Marcel Holtmann Date: Fri, 20 Aug 2010 12:40:59 +0000 (+0200) Subject: Move the backtrace functions to a different place X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~2476 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf6a2883d4d31a013546dc64b31a7f3a109a9659;p=profile%2Fivi%2Fconnman.git Move the backtrace functions to a different place --- diff --git a/src/log.c b/src/log.c index 4dee003..eb480b4 100644 --- a/src/log.c +++ b/src/log.c @@ -26,9 +26,9 @@ #define _GNU_SOURCE #include #include +#include #include #include -#include #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); }