ffae904abdffcca1309d1fa3a90ff12646410d59
tdreszer
  Fri Dec 2 11:08:21 2011 -0800
Had to check in code change that is ifdef'd out.  This code is primarily used by me and fails in some compilers.  Changes are being checked in because git doesn't let me change branches otherwise.
diff --git src/lib/errabort.c src/lib/errabort.c
index 45ba1e8..9698b4c 100644
--- src/lib/errabort.c
+++ src/lib/errabort.c
@@ -2,31 +2,30 @@
  *
  * This maintains two stacks - a warning message printer
  * stack, and a "abort handler" stack.
  *
  * By default the warnings will go to stderr, and
  * aborts will exit the program.  You can push a
  * function on to the appropriate stack to change
  * this behavior.  The top function on the stack
  * gets called.
  *
  * This file is copyright 2002 Jim Kent, but license is hereby
  * granted for all use - public, private or commercial. */
 
 // developer: this include is for an occasionally useful means of getting stack info without crashing
 // however, it is not supported on cygwin.  Conditionally compile this in when desired.
-
 //#define BACKTRACE_EXISTS
 #ifdef BACKTRACE_EXISTS
 #include <execinfo.h>
 #endif///def BACKTRACE_EXISTS
 #include <pthread.h>
 #include "common.h"
 #include "hash.h"
 #include "dystring.h"
 #include "errabort.h"
 
 
 
 #define maxWarnHandlers 20
 #define maxAbortHandlers 12
 struct perThreadAbortVars
@@ -91,34 +90,44 @@
 int count = 0;
 
 // developer: this is an occasionally useful means of getting stack info without crashing
 // however, it is not supported on cygwin.  Conditionally compile this in when desired.
 // The define is at top to include execinfo.h
 #ifdef BACKTRACE_EXISTS
 void *buffer[STACK_LIMIT];
 count = backtrace(buffer, STACK_LIMIT);
 strings = backtrace_symbols(buffer, count);
 #endif///def BACKTRACE_EXISTS
 
 if (strings == NULL)
     dyStringAppend(dy,"\nno backtrace_symbols available in errabort::warnWithBackTrace().");
 else
     {
-    dyStringAppend(dy,"\nBACKTRACE [can use 'addr2line -Cfise {exe} addr addr ...']:");
-    int ix;
-    for (ix = 1; ix < count && strings[ix] != NULL; ix++)
-        dyStringPrintf(dy,"\n%s", strings[ix]);
+    int ix = 1;
+    dyStringAppend(dy,"\nBACKTRACE (use on cmdLine):");
+    if (strings[1] != NULL)
+        {
+        strSwapChar(strings[1],' ','\0');
+        dyStringPrintf(dy,"\naddr2line -Cfise %s",strings[1]);
+        strings[1] += strlen(strings[1]) + 1;
+        }
+    for (; ix < count && strings[ix] != NULL; ix++)
+        {
+        strings[ix] = skipBeyondDelimit(strings[ix],'[');
+        strSwapChar(strings[ix],']','\0');
+        dyStringPrintf(dy," %s",strings[ix]);
+        }
 
     free(strings);
     }
 vaWarn(dyStringCannibalize(&dy), args);
 va_end(args);
 }
 
 
 void errnoWarn(char *format, ...)
 /* Prints error message from UNIX errno first, then does rest of warning. */
 {
 char fbuf[512];
 va_list args;
 va_start(args, format);
 sprintf(fbuf, "%s\n%s", strerror(errno), format);