]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Added a convenience function to dump backtraces for gdb-less debugging
authorMartin Willi <martin@revosec.ch>
Mon, 21 May 2012 10:18:49 +0000 (12:18 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 21 May 2012 10:18:49 +0000 (12:18 +0200)
src/libstrongswan/utils/backtrace.c
src/libstrongswan/utils/backtrace.h

index cb83d9830e3bb38dc7f4bc1f5773cce1d9e86b29..db10c7844f7aace80cc50ecb5fa9257a945d3e09 100644 (file)
@@ -248,3 +248,20 @@ backtrace_t *backtrace_create(int skip)
        return &this->public;
 }
 
+/**
+ * See header
+ */
+void backtrace_dump(char *label, FILE *file, bool detailed)
+{
+       backtrace_t *backtrace;
+
+       backtrace = backtrace_create(2);
+
+       if (label)
+       {
+               fprintf(file, "Debug backtrace: %s\n", label);
+       }
+       backtrace->log(backtrace, file, detailed);
+       backtrace->destroy(backtrace);
+}
+
index 9d59d25034a3ea0fe10d7a0d8218c7b660e01df7..32d09043febf107c68e7ec627ae4e6c9550cf9bd 100644 (file)
@@ -77,4 +77,13 @@ struct backtrace_t {
  */
 backtrace_t *backtrace_create(int skip);
 
+/**
+ * Create a backtrace, dump it and clean it up.
+ *
+ * @param label                description to print for this backtrace, or NULL
+ * @param file         FILE to log backtrace to
+ * @param detailed     TRUE to resolve line/file using addr2line (slow)
+ */
+void backtrace_dump(char *label, FILE *file, bool detailed);
+
 #endif /** BACKTRACE_H_ @}*/