]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
* next try to get a working new tokenizer. this seems to be working
[citadel.git] / citadel / citserver.c
index d74c3a0ab74c3a80003cb8c260b34ff896f2b18e..46f3834f026aeab172d34bea83930b13de0da542 100644 (file)
 # endif
 #endif
 
+#if HAVE_BACKTRACE
+#include <execinfo.h>
+#endif
+
 #include <ctype.h>
 #include <string.h>
 #include <dirent.h>
@@ -66,6 +70,28 @@ int ScheduledShutdown = 0;
 int do_defrag = 0;
 time_t server_startup_time;
 
+/**
+ * \brief print the actual stack frame.
+ */
+void cit_backtrace(void)
+{
+#ifdef HAVE_BACKTRACE
+       void *stack_frames[50];
+       size_t size, i;
+       char **strings;
+
+
+       size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
+       strings = backtrace_symbols(stack_frames, size);
+       for (i = 0; i < size; i++) {
+               if (strings != NULL)
+                       lprintf(1, "%s\n", strings[i]);
+               else
+                       lprintf(1, "%p\n", stack_frames[i]);
+       }
+       free(strings);
+#endif
+}
 /*
  * Various things that need to be initialized at startup
  */