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