]> git.proxmox.com Git - mirror_ovs.git/blobdiff - lib/backtrace.h
fatal-signal: Catch SIGSEGV and print backtrace.
[mirror_ovs.git] / lib / backtrace.h
index 384f2700d94cd1b057ddee905dbe2d298a7d8a35..5708bf9c68317244b738d149de9ad306aca2ce24 100644 (file)
 #include <stdint.h>
 #include "openvswitch/dynamic-string.h"
 
+#ifdef HAVE_UNWIND
+#define UNW_LOCAL_ONLY
+#include <libunwind.h>
+#endif
+
 /* log_backtrace() will save the backtrace of a running program
  * into the log at the DEBUG level.
  *
@@ -68,7 +73,21 @@ struct backtrace {
     uintptr_t frames[BACKTRACE_MAX_FRAMES];
 };
 
+#ifdef HAVE_UNWIND
+#define UNW_MAX_DEPTH 32
+#define UNW_MAX_FUNCN 32
+#define UNW_MAX_BUF \
+    (UNW_MAX_DEPTH * sizeof(struct unw_backtrace))
+
+struct unw_backtrace {
+    char func[UNW_MAX_FUNCN];
+    unw_word_t ip;
+    unw_word_t offset;
+};
+#endif
+
 void backtrace_capture(struct backtrace *);
 void log_backtrace_at(const char *msg, const char *where);
+void log_received_backtrace(int fd);
 
 #endif /* backtrace.h */