summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-08-20 14:40:59 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-08-20 14:40:59 +0200
commitbf6a2883d4d31a013546dc64b31a7f3a109a9659 (patch)
tree0336f0fc8c5e1e9442b338735fe7e7dcab00deb0
parentab47a2a87da6969877e0cde5f1eea51b30ed59a3 (diff)
downloadconnman-bf6a2883d4d31a013546dc64b31a7f3a109a9659.tar.gz
connman-bf6a2883d4d31a013546dc64b31a7f3a109a9659.tar.bz2
connman-bf6a2883d4d31a013546dc64b31a7f3a109a9659.zip
Move the backtrace functions to a different place
-rw-r--r--src/log.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/log.c b/src/log.c
index 4dee0031..eb480b40 100644
--- a/src/log.c
+++ b/src/log.c
@@ -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);
}