From 9457e315a8b87211250eed0503a8ef2ae6fca6a8 Mon Sep 17 00:00:00 2001 From: 0xfedfedfe <70035962+0xfedfedfe@users.noreply.github.com> Date: Mon, 22 May 2023 15:38:20 +0100 Subject: [PATCH] Name is_debug_panic and fix ASSERT/PANIC macros (#1061) * Name is_debug_panic and revamp ASSERT/PANIC macros * Update src/is_debug.c Co-authored-by: Alex Bates <16batesa@gmail.com> --- include/functions.h | 1 + include/macros.h | 16 +++++++--------- src/is_debug.c | 4 ++-- ver/us/symbol_addrs.txt | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6c36fc4432..f77133bfc5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -17,6 +17,7 @@ void boot_idle(void* data); void boot_main(void* data); void is_debug_init(void); +void is_debug_panic(const char* message, char* file, s32 line); f32 signF(f32 val); diff --git a/include/macros.h b/include/macros.h index bd57c9727c..ac30f1988a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -57,18 +57,16 @@ #define VIRTUAL_TO_PHYSICAL(addr) (u32)((u8*)(addr) - 0x80000000) #ifdef DEBUG +#define IS_DEBUG_PANIC(statement, file, line) is_debug_panic(statement, file, line) +#else +#define IS_DEBUG_PANIC(statement, file, line) do {} while(TRUE) +#endif + +#define PANIC() IS_DEBUG_PANIC("Panic", __FILE__, __LINE__) #define ASSERT(condition) \ if (!(condition)) { \ - func_80025F44("Assertion failed: " #condition, __FILE__, __LINE__); \ - while (TRUE) {} \ + IS_DEBUG_PANIC("Assertion failed: " #condition, __FILE__, __LINE__); \ } -#define PANIC() \ - func_80025F44("Panic!", __FILE__, __LINE__); \ - while (TRUE) {} -#else -#define ASSERT(condition) if (!(condition)) { while (TRUE) {} } -#define PANIC() while (TRUE) {} -#endif #define BADGE_MENU_PAGE(index) (&gPauseBadgesPages[index]) #define ITEM_MENU_PAGE(index) (&gPauseItemsPages[index]) diff --git a/src/is_debug.c b/src/is_debug.c index c1d5cf0713..e23e9bc3c8 100644 --- a/src/is_debug.c +++ b/src/is_debug.c @@ -89,7 +89,7 @@ char* is_debug_print(char* arg0, const char* str, size_t count) { return (char*) 1; } -void func_80025F44(const char* message, char* file, s32 line) { +void is_debug_panic(const char* message, char* file, s32 line) { osSyncPrintf("File:%s Line:%d %s \n", file, line, message); - PANIC(); + do {} while (TRUE); } diff --git a/ver/us/symbol_addrs.txt b/ver/us/symbol_addrs.txt index 2c875f0ea3..1bd6aef156 100644 --- a/ver/us/symbol_addrs.txt +++ b/ver/us/symbol_addrs.txt @@ -12,7 +12,7 @@ printf = 0x80025CC0; // type:func rom:0x10C0 osSyncPrintf = 0x80025CFC; // type:func rom:0x10FC rmonPrintf = 0x80025D38; // type:func rom:0x1138 is_debug_print = 0x80025D74; // type:func rom:0x1174 -func_80025F44 = 0x80025F44; // type:func rom:0x1344 +is_debug_panic = 0x80025F44; // type:func rom:0x1344 boot_main = 0x80025F70; // type:func rom:0x1370 gfxRetrace_Callback = 0x8002605C; // type:func rom:0x145C gfx_task_main = 0x80026164; // type:func rom:0x1564