Add backtrace debugging facility that doesn't add linebreaks
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 8 May 2011 11:58:27 +0000 (11:58 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 8 May 2011 11:58:27 +0000 (11:58 +0000)
citadel/citserver.c
citadel/citserver.h

index cfe5c1b1a13984a4df6bb0163051d476b663bcb7..71ec7e05e935dfcf5a1b945fdc9729ba367c61d8 100644 (file)
@@ -106,6 +106,32 @@ void cit_backtrace(void)
 #endif
 }
 
+void cit_oneline_backtrace(void)
+{
+#ifdef HAVE_BACKTRACE
+       void *stack_frames[50];
+       size_t size, i;
+       char **strings;
+       StrBuf *Buf;
+
+       size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
+       strings = backtrace_symbols(stack_frames, size);
+       if (size > 0)
+       {
+               Buf = NewStrBuf();
+               for (i = 1; i < size; i++) {
+                       if (strings != NULL)
+                               StrBufAppendPrintf(Buf, "%s : ", strings[i]);
+                       else
+                               StrBufAppendPrintf(Buf, "%p : ", stack_frames[i]);
+               }
+               free(strings);
+               CtdlLogPrintf(CTDL_ALERT, "%s\n", ChrPtr(Buf));
+               FreeStrBuf(&Buf);
+       }
+#endif
+}
+
 /*
  * print the actual stack frame.
  */
index c7cb29b0cddbdc073ffecf4e1dc5cc38d029bcb2..c294916e24dd07cb854dd82118ad6a79fea41158 100644 (file)
@@ -32,6 +32,7 @@ struct UserProcList {
 #define CTDLUSERIP      (IsEmptyStr(CC->cs_addr) ?  CC->cs_clientinfo: CC->cs_addr)
 
 void cit_backtrace(void);
+void cit_oneline_backtrace(void);
 void cit_panic_backtrace(int SigNum);
 void master_startup (void);
 void master_cleanup (int exitcode);