From 4f2c48c733d71fa41ae8865d0fbbde5a57dd75cd Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Mon, 11 Dec 2023 01:58:30 -0500 Subject: [PATCH] Add DEBUG_ASSERTIONS define and enable it by default (#730) --- include/config/config_debug.h | 9 +++++++++ include/config/config_safeguards.h | 14 +++++++++++--- src/game/debug.h | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/config/config_debug.h b/include/config/config_debug.h index 86e27755..7ed67cac 100644 --- a/include/config/config_debug.h +++ b/include/config/config_debug.h @@ -14,6 +14,10 @@ */ // #define DISABLE_ALL + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** * Enables a comprehensive standalone profiler. Automatically enabled by PUPPYPRINT_DEBUG. * If not using PUPPYPRINT_DEBUG, press L + D-Pad Up to toggle the profiler. @@ -85,3 +89,8 @@ * Forces a crash when the game starts. Useful for debugging the crash screen. */ // #define DEBUG_FORCE_CRASH_ON_BOOT + +/** + * Intentionally crash the game whenever a runtime assertion fails (also invoked by the DEBUG define in the Makefile). + */ +#define DEBUG_ASSERTIONS diff --git a/include/config/config_safeguards.h b/include/config/config_safeguards.h index 3a7b9659..3ddc689b 100644 --- a/include/config/config_safeguards.h +++ b/include/config/config_safeguards.h @@ -75,21 +75,26 @@ #ifdef DISABLE_ALL #undef DEBUG_ALL + #undef USE_PROFILER #undef TEST_LEVEL #undef DEBUG_LEVEL_SELECT #undef ENABLE_DEBUG_FREE_MOVE - #undef VANILLA_DEBUG - #undef VANILLA_STYLE_CUSTOM_DEBUG #undef PUPPYPRINT_DEBUG #undef PUPPYPRINT_DEBUG_CYCLES + #undef VANILLA_STYLE_CUSTOM_DEBUG #undef VISUAL_DEBUG #undef UNLOCK_ALL #undef COMPLETE_SAVE_FILE + #undef UNLOCK_FPS + #undef VANILLA_DEBUG #undef DEBUG_FORCE_CRASH_ON_BOOT - #undef USE_PROFILER + #undef DEBUG_ASSERTIONS #endif // DISABLE_ALL #ifdef DEBUG_ALL + #undef USE_PROFILER + #define USE_PROFILER + #undef DEBUG_LEVEL_SELECT #define DEBUG_LEVEL_SELECT @@ -110,6 +115,9 @@ #undef COMPLETE_SAVE_FILE #define COMPLETE_SAVE_FILE + + #undef DEBUG_ASSERTIONS + #define DEBUG_ASSERTIONS #endif // DEBUG_ALL #ifdef PUPPYPRINT_DEBUG diff --git a/src/game/debug.h b/src/game/debug.h index 522ace2d..c8862f13 100644 --- a/src/game/debug.h +++ b/src/game/debug.h @@ -62,7 +62,7 @@ extern void __n64Assert(char *fileName, u32 lineNum, char *message); /** * Will cause a crash if cond is not true, and DEBUG is defined (allows for quick removal of littered asserts) */ -#ifdef DEBUG +#if defined(DEBUG) || defined(DEBUG_ASSERTIONS) #define assert(cond, message) do {\ if ((cond) == FALSE) { \ error(message); \