diff --git a/nel/include/nel/misc/debug.h b/nel/include/nel/misc/debug.h index a8c23eced..1d533c149 100644 --- a/nel/include/nel/misc/debug.h +++ b/nel/include/nel/misc/debug.h @@ -89,6 +89,9 @@ void createDebug (const char *logPath = NULL, bool logInFile = true, bool eraseL /// Do not call this, unless you know what you're trying to do (it kills debug)! void destroyDebug(); +/// Attach exception handler, for new threads and fibers +void attachExceptionHandler(); + // call this if you want to change the dir of the log.log file void changeLogDirectory(const std::string &dir); @@ -352,7 +355,7 @@ void setCrashAlreadyReported(bool state); * Same as nlassertex(false,exp); */ -// removed because we always check assert (even in release mode) #if defined (NL_OS_WINDOWS) && defined (NL_DEBUG) +#if defined(NL_DEBUG) /* Debug break is only useful in debug builds */ #if defined(NL_OS_WINDOWS) #define NLMISC_BREAKPOINT __debugbreak() #elif defined(NL_OS_UNIX) && defined(NL_COMP_GCC) @@ -360,6 +363,9 @@ void setCrashAlreadyReported(bool state); #else #define NLMISC_BREAKPOINT abort() #endif +#else +#define NLMISC_BREAKPOINT do { } while (0) +#endif // Internal, don't use it (make smaller assert code) extern bool _assert_stop(bool &ignoreNextTime, sint line, const char *file, const char *funcName, const char *exp); diff --git a/nel/src/misc/co_task.cpp b/nel/src/misc/co_task.cpp index 524cc69c6..4548fbe86 100644 --- a/nel/src/misc/co_task.cpp +++ b/nel/src/misc/co_task.cpp @@ -143,6 +143,9 @@ namespace NLMISC NL_CT_DEBUG("CoTask : task %p start func called", task); + // Attach exception handler + attachExceptionHandler(); + try { // run the task @@ -151,6 +154,7 @@ namespace NLMISC catch(...) { nlwarning("CCoTask::startFunc : the task has generated an unhandled exeption and will terminate"); + NLMISC_BREAKPOINT; } task->_Finished = true; diff --git a/nel/src/misc/debug.cpp b/nel/src/misc/debug.cpp index cc3203a14..1f7cf38db 100644 --- a/nel/src/misc/debug.cpp +++ b/nel/src/misc/debug.cpp @@ -1157,6 +1157,15 @@ void destroyDebug() } } +void attachExceptionHandler() +{ +#ifndef NL_COMP_MINGW +# ifdef NL_OS_WINDOWS + _set_se_translator(exceptionTranslator); +# endif // NL_OS_WINDOWS +#endif //!NL_COMP_MINGW +} + void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) { // Do some basic compiler time check on type size diff --git a/nel/src/misc/win_thread.cpp b/nel/src/misc/win_thread.cpp index a75b2165f..0de191d55 100644 --- a/nel/src/misc/win_thread.cpp +++ b/nel/src/misc/win_thread.cpp @@ -67,6 +67,9 @@ static unsigned long __stdcall ProxyFunc (void *arg) // Set the thread pointer in TLS memory nlverify (TlsSetValue (TLSThreadPointer, (void*)parent) != 0); + // Attach exception handler + attachExceptionHandler(); + // Run the thread parent->Runnable->run();