On systems that support it, raise SIGTRAP to drop into the debugger

Clang was being clever and giving a warning for this line so it prompted me
to fix it. I believe that SIGTRAP is the correct way to get the debugger to
work here.

It does a compile-time check for the platform when not using MSVC.

Discussed at http://www.volumesoffun.com/phpBB3/viewtopic.php?p=3766#p3766
This commit is contained in:
Matt Williams 2013-07-04 19:34:49 +01:00
parent 9f7f893b68
commit 8027f9904d

View File

@ -31,6 +31,7 @@ freely, subject to the following restrictions:
#include <stdexcept> #include <stdexcept>
#include <sstream> #include <sstream>
#include <string.h> // Exception constuctors take strings. #include <string.h> // Exception constuctors take strings.
#include <csignal>
#if defined(_MSC_VER) #if defined(_MSC_VER)
// In Visual Studio we can use this function to go into the debugger. // In Visual Studio we can use this function to go into the debugger.
@ -38,7 +39,11 @@ freely, subject to the following restrictions:
#else #else
// On other platforms we just halt by forcing a crash. // On other platforms we just halt by forcing a crash.
// Hopefully this puts us in the debugger if one is running // Hopefully this puts us in the debugger if one is running
#define POLYVOX_HALT() *((unsigned int*)0) = 0xDEAD #if defined(__linux__) || defined(__APPLE__)
#define POLYVOX_HALT() raise(SIGTRAP)
#else
#define POLYVOX_HALT() *((unsigned int*)0) = 0xDEAD
#endif
#endif #endif
// Macros cannot contain #ifdefs, but some of our macros need to disable warnings and such warning supression is // Macros cannot contain #ifdefs, but some of our macros need to disable warnings and such warning supression is