Logger does not handle SIGABRT anymore; use explode() instead of abort()
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2350 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "libs/tasklib.h"
|
||||
#include "libs/threadlib.h"
|
||||
#include "libs/log.h"
|
||||
#include "libs/misc.h"
|
||||
|
||||
// the running of the game-clock is based on game framerates
|
||||
// *not* on the system (or translated) timer
|
||||
@@ -228,7 +229,7 @@ SuspendGameClock (void)
|
||||
log_add (log_Always, "BUG: "
|
||||
"Attempted to suspend non-existent game clock");
|
||||
#ifdef DEBUG
|
||||
abort();
|
||||
explode ();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -249,7 +250,7 @@ ResumeGameClock (void)
|
||||
log_add (log_Always, "BUG: "
|
||||
"Attempted to resume non-existent game clock\n");
|
||||
#ifdef DEBUG
|
||||
abort();
|
||||
explode ();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,10 +53,7 @@ static FILE *streamOut;
|
||||
static volatile int qlock = 0;
|
||||
static Mutex qmutex;
|
||||
|
||||
static void (* prevAbortFunc)(int) = SIG_ERR;
|
||||
|
||||
static void exitCallback (void);
|
||||
static void abortHandler (int);
|
||||
static void displayLog (bool isError);
|
||||
static void displayBox (const char *title, bool isError, const char *msg);
|
||||
|
||||
@@ -141,14 +138,8 @@ log_init (int max_lines)
|
||||
msgBuf[sizeof (msgBuf) - 1] = '\0';
|
||||
msgNoThread[sizeof (msgNoThread) - 1] = '\0';
|
||||
|
||||
// install exit and abort handlers
|
||||
// install exit handlers
|
||||
atexit (exitCallback);
|
||||
prevAbortFunc = signal (SIGABRT, abortHandler);
|
||||
if (prevAbortFunc == SIG_ERR)
|
||||
{
|
||||
fprintf (stderr, "Warning: cannot install SIGABRT handler: %s\n",
|
||||
strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -169,9 +160,6 @@ log_exit (int code)
|
||||
DestroyMutex (qmutex);
|
||||
}
|
||||
|
||||
if (prevAbortFunc != SIG_ERR)
|
||||
signal (SIGABRT, prevAbortFunc);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -289,20 +277,6 @@ exitCallback (void)
|
||||
log_exit (0);
|
||||
}
|
||||
|
||||
static void
|
||||
abortHandler (int sig)
|
||||
{
|
||||
if (showBox)
|
||||
displayLog (true);
|
||||
|
||||
if (prevAbortFunc == SIG_ERR || prevAbortFunc == SIG_IGN)
|
||||
; // do nothing
|
||||
else if (prevAbortFunc == SIG_DFL)
|
||||
raise (SIGABRT); // forward to default
|
||||
else
|
||||
prevAbortFunc (sig); // forward directly
|
||||
}
|
||||
|
||||
static void
|
||||
displayLog (bool isError)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "libs/threadlib.h"
|
||||
#include "libs/memlib.h"
|
||||
#include "libs/log.h"
|
||||
#include "libs/misc.h"
|
||||
|
||||
#define GetToolFrame() 1
|
||||
|
||||
@@ -211,7 +212,7 @@ MallocWithRetry(int bytes, char *diagStr)
|
||||
|
||||
log_add (log_Always, "Malloc failed for %s. #Bytes %d.", diagStr, bytes);
|
||||
fflush (stderr);
|
||||
abort ();
|
||||
explode ();
|
||||
#if 0
|
||||
/* The user gets a chance to close other applications and try again. */
|
||||
if (!MessageWithRetry ("I'm out of memory! "
|
||||
@@ -587,7 +588,7 @@ HMalloc (int size)
|
||||
if ((p = _alloc_mem(size)) == NULL) {
|
||||
log_add (log_Always, "Fatal Error: HMalloc(): out of memory.");
|
||||
fflush (stderr);
|
||||
abort ();
|
||||
explode ();
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#define MISC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include "port.h"
|
||||
|
||||
|
||||
extern void *HMalloc (int size);
|
||||
@@ -32,5 +34,15 @@ extern void *HRealloc (void *p, int size);
|
||||
|
||||
extern int TFB_DEBUG_HALT;
|
||||
|
||||
static inline void explode (void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// give debugger a chance to hook
|
||||
abort ();
|
||||
#else
|
||||
exit (EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ loadResourceIndex (uio_Stream *stream, const char *fileName) {
|
||||
log_add (log_Always, "Fatal: resource index '%s' is not sorted "
|
||||
"on the resource number, or contains a double entry. "
|
||||
"Problem encountered on line %d.", fileName, lineNum);
|
||||
abort ();
|
||||
explode ();
|
||||
}
|
||||
lastResource = res;
|
||||
#endif
|
||||
|
||||
@@ -939,7 +939,7 @@ mixer_SourceStop_internal (mixer_Source *src)
|
||||
log_add (log_Debug, "mixer_SourceStop_internal(): "
|
||||
"desynced source state");
|
||||
#ifdef DEBUG
|
||||
abort ();
|
||||
explode ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ UnQueueThread (TrueThread thread)
|
||||
log_add (log_Debug, "Error: Trying to remove non-present thread "
|
||||
"from thread queue.");
|
||||
fflush (stderr);
|
||||
abort();
|
||||
explode ();
|
||||
}
|
||||
#endif /* DEBUG_THREADS */
|
||||
ptr = &(*ptr)->next;
|
||||
|
||||
Reference in New Issue
Block a user