Add an option to trap context errors in a debugger
This commit is contained in:
parent
7a0df8553f
commit
724ad0d893
@ -34,6 +34,7 @@
|
||||
#include "alSource.h"
|
||||
#include "alBuffer.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alError.h"
|
||||
#include "bs2b.h"
|
||||
#include "alu.h"
|
||||
|
||||
@ -498,6 +499,10 @@ static void alc_init(void)
|
||||
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
|
||||
ZScale = -1.0;
|
||||
|
||||
str = getenv("__ALSOFT_TRAP_AL_ERROR");
|
||||
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
|
||||
TrapALError = AL_TRUE;
|
||||
|
||||
pthread_key_create(&LocalContext, ReleaseThreadCtx);
|
||||
InitializeCriticalSection(&ListLock);
|
||||
ThunkInit();
|
||||
@ -569,6 +574,9 @@ static void alc_initconfig(void)
|
||||
if(DefaultResampler >= RESAMPLER_MAX || DefaultResampler <= RESAMPLER_MIN)
|
||||
DefaultResampler = RESAMPLER_DEFAULT;
|
||||
|
||||
if(!TrapALError)
|
||||
TrapALError = GetConfigValueBool(NULL, "trap-al-error", AL_FALSE);
|
||||
|
||||
ReverbBoost *= aluPow(10.0f, GetConfigValueFloat("reverb", "boost", 0.0f) /
|
||||
20.0f);
|
||||
EmulateEAXReverb = GetConfigValueBool("reverb", "emulate-eax", AL_FALSE);
|
||||
|
@ -8,6 +8,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ALboolean TrapALError;
|
||||
|
||||
ALvoid alSetError(ALCcontext *Context, ALenum errorCode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -20,10 +20,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
|
||||
ALboolean TrapALError = AL_FALSE;
|
||||
|
||||
AL_API ALenum AL_APIENTRY alGetError(void)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
@ -41,5 +45,18 @@ AL_API ALenum AL_APIENTRY alGetError(void)
|
||||
|
||||
ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
|
||||
{
|
||||
if(TrapALError)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* Safely catch a breakpoint exception that wasn't caught by a debugger */
|
||||
__try {
|
||||
DebugBreak();
|
||||
} __except((GetExceptionCode()==EXCEPTION_BREAKPOINT) ?
|
||||
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
|
||||
}
|
||||
#elif defined(SIGTRAP)
|
||||
kill(getpid(), SIGTRAP);
|
||||
#endif
|
||||
}
|
||||
CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode);
|
||||
}
|
||||
|
@ -150,6 +150,14 @@
|
||||
#layout_61CHN = fl=-30, fr=30, fc=0, sl=-90, sr=90, bc=180
|
||||
#layout_71CHN = fl=-30, fr=30, fc=0, sl=-90, sr=90, bl=-150, br=150
|
||||
|
||||
## trap-al-error:
|
||||
# Generates a SIGTRAP signal when an AL context error is generated, on systems
|
||||
# that support it. This helps when debugging, while trying to find the cause
|
||||
# of a context error. On Windows, a breakpoint exception is generated.
|
||||
# Optionally, the __ALSOFT_TRAP_AL_ERROR env var may be set before running the
|
||||
# app instead.
|
||||
#trap-al-error = false
|
||||
|
||||
##
|
||||
## Reverb effect stuff (includes EAX reverb)
|
||||
##
|
||||
|
Loading…
x
Reference in New Issue
Block a user