aura  0.1
 All Data Structures Functions Variables Modules Pages
panic.c
1 #include <aura/aura.h>
2 #include <aura/private.h>
3 #include <signal.h>
4 
5 #ifndef AURA_DISABLE_BACKTRACE
6 #include <execinfo.h>
7 #endif
8 
9 #define TRACE_LEN 36
10 
11 int BUG(struct aura_node *node, const char *msg, ...)
12 {
13  va_list ap;
14  va_start(ap, msg);
15  slogv(0, SLOG_FATAL, msg, ap);
16  va_end(ap);
17  aura_panic(node);
18 }
19 
20 
33 void __attribute__((noreturn)) aura_panic(struct aura_node *node)
34 {
35  void *array[TRACE_LEN];
36  size_t size;
37  char **strings;
38  size_t i;
39 
40  aura_transport_dump_usage();
41 
42 #ifndef AURA_DISABLE_BACKTRACE
43  size = backtrace (array, TRACE_LEN);
44  strings = backtrace_symbols (array, size);
45 
46  slog(0, SLOG_DEBUG, "--- Dumping aura stack (%d entries) ---", size);
47  for (i = 0; i < size; i++)
48  slog(0, SLOG_DEBUG, "%s", strings[i]);
49 #else
50  slog(0, SLOG_DEBUG, "Stackdump disabled. Perhaps your C library sucks");
51 #endif
52 
53  /* TODO: Dump interesting stuff from node var */
54 
55  free (strings);
56  exit(128);
57 }
58 
63 static void handler(int sig, siginfo_t *si, void *unused)
64 {
65  slog(0, SLOG_FATAL, "AURA got a segmentation fault, this is bad");
66  aura_panic(NULL);
67 }
68 
69 
70 void __attribute__((constructor (101))) reg_seg_handler() {
71  struct sigaction sa;
72  sa.sa_flags = SA_SIGINFO;
73  sigemptyset(&sa.sa_mask);
74  sa.sa_sigaction = handler;
75  sigaction(SIGSEGV, &sa, NULL);
76 }
int size
Definition: aura.h:337
void __attribute__((noreturn))
Definition: panic.c:33