Files

55 lines
1.1 KiB
C
Raw Permalink Normal View History

2023-12-29 15:08:25 +00:00
#include <common.h>
#include <spm/debug.h>
#include <wii/base.h>
#include <wii/os.h>
2023-12-29 15:34:54 +00:00
#include <msl/stdarg.h>
2023-12-29 15:08:25 +00:00
#include <msl/stdio.h>
#include <msl/string.h>
2024-08-28 22:35:08 +01:00
extern "C" {
2023-12-29 15:08:25 +00:00
2024-08-28 22:35:08 +01:00
static DebugWork work;
static DebugWork * wp = &work;
2023-12-29 15:08:25 +00:00
2023-12-29 15:10:21 +00:00
void debugInit()
2023-12-29 15:08:25 +00:00
{
2023-12-29 15:10:21 +00:00
memset(wp, 0, sizeof(work));
2023-12-29 15:08:25 +00:00
}
2023-12-29 15:10:21 +00:00
void debugReInit()
2023-12-29 15:08:25 +00:00
{
2023-12-29 15:10:21 +00:00
2023-12-29 15:08:25 +00:00
}
2023-12-29 15:34:54 +00:00
void OSPanic(const char * filename, s32 line, const char * msg, ...)
2023-12-29 15:08:25 +00:00
{
2023-12-29 15:34:54 +00:00
va_list args;
char buf[2048];
u32 stackDepth;
u32 * stack;
int pos;
// Format header text
va_start(args, msg);
pos = vsprintf(buf, msg, args);
va_end(args);
pos += sprintf(buf + pos, "\n in \"%s\" on line %d.\n", filename, line);
pos += sprintf(buf + pos, "\nAddress: Back Chain LR Save\n");
// Traverse stack
stackDepth = 0;
stack = (u32 *) OSGetStackPointer();
while (stack != NULL && stack != (u32 *)0xffffffff && stackDepth++ < 16)
{
pos += sprintf(buf + pos, "0x%08x: 0x%08x 0x%08x\n", stack, stack[0], stack[1]);
stack = (u32 *) *stack;
}
// Halt execution
OSDisableInterrupts();
PPCHalt();
2024-01-01 21:48:12 +00:00
while (1) { }
2023-12-29 15:08:25 +00:00
}
2024-08-28 22:35:08 +01:00
}