Fix panic/stack trace

This commit is contained in:
2026-03-15 09:44:18 +01:00
parent af3a9e27fd
commit 5eaf193d42
3 changed files with 13 additions and 40 deletions

View File

@@ -19,10 +19,8 @@ extern struct init_status init;
*/
void debug_stack_trace(unsigned int max_frames)
{
DEBUG("*** begin stack trace ***");
if (init.terminal) {
printf("\r\n\x1b[48;5;232m\x1b[38;5;231m*** begin stack trace ***\r\n");
}
printf("\r\n\x1b[48;5;232m\x1b[38;5;231m*** begin stack trace ***\r\n");
// Thanks GCC :)
uintptr_t* rbp = (uintptr_t*)__builtin_frame_address(0);
@@ -31,11 +29,7 @@ void debug_stack_trace(unsigned int max_frames)
uintptr_t rip = rbp[1];
uintptr_t offset = 0;
const char* name = debug_find_symbol(rip, &offset);
DEBUG("[%u] <0x%p> (%s+0x%x)", frame, (void*)rip, name, offset);
if (init.terminal) {
printf("[%u] <0x%p> (%s+0x%x)\r\n", frame, (void*)rip, name, offset);
}
printf("[%u] <0x%p> (%s+0x%x)\r\n", frame, (void*)rip, name, offset);
uintptr_t* next_rbp = (uintptr_t*)rbp[0];
@@ -46,10 +40,8 @@ void debug_stack_trace(unsigned int max_frames)
rbp = next_rbp;
}
if (init.terminal) {
printf("*** end stack trace ***\r\nHalting system...\x1b[0m");
}
DEBUG("*** end stack trace ***");
printf("*** end stack trace ***\r\n[end Kernel panic]\r\nHalting system...\x1b[0m");
}
typedef struct {