Add panic/stack trace display on fb for real hardware debug
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
#include "io/serial/serial.h"
|
#include "io/serial/serial.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
|
extern struct init_status init;
|
||||||
|
|
||||||
void panic(struct cpu_status_t* ctx, const char* str)
|
void panic(struct cpu_status_t* ctx, const char* str)
|
||||||
{
|
{
|
||||||
CLEAR_INTERRUPTS;
|
CLEAR_INTERRUPTS;
|
||||||
@@ -15,6 +17,13 @@ void panic(struct cpu_status_t* ctx, const char* str)
|
|||||||
skputc('\r');
|
skputc('\r');
|
||||||
skputc('\n');
|
skputc('\n');
|
||||||
DEBUG("\x1b[38;5;231m\x1b[48;5;196mend Kernel panic - halting...\x1b[0m");
|
DEBUG("\x1b[38;5;231m\x1b[48;5;196mend Kernel panic - halting...\x1b[0m");
|
||||||
|
|
||||||
|
if (init.terminal)
|
||||||
|
{
|
||||||
|
printf("\r\n\x1b[38;5;231m\x1b[48;5;196mKernel panic!!!\x1b[0m Something went horribly wrong! (no cpu ctx)");
|
||||||
|
printf("\r\n%s\r\n\x1b[38;5;231m\x1b[48;5;196mend Kernel panic - halting...\x1b[0m", str);
|
||||||
|
}
|
||||||
|
|
||||||
hcf();
|
hcf();
|
||||||
}
|
}
|
||||||
DEBUG("\x1b[38;5;231m\x1b[48;5;196mKernel panic!!!\x1b[0m at rip=%p\r\nSomething went horribly wrong! (%s) vect=0x%.2x errcode=0x%x\n\rrax=%p rbx=%p rcx=%p rdx=%p\n\rrsi=%p rdi=%p r8=%p r9=%p\n\rr10=%p r11=%p r12=%p r13=%p\n\rr14=%p r15=%p\n\n\rflags=%p\n\rHalting...",
|
DEBUG("\x1b[38;5;231m\x1b[48;5;196mKernel panic!!!\x1b[0m at rip=%p\r\nSomething went horribly wrong! (%s) vect=0x%.2x errcode=0x%x\n\rrax=%p rbx=%p rcx=%p rdx=%p\n\rrsi=%p rdi=%p r8=%p r9=%p\n\rr10=%p r11=%p r12=%p r13=%p\n\rr14=%p r15=%p\n\n\rflags=%p\n\rHalting...",
|
||||||
@@ -22,6 +31,17 @@ void panic(struct cpu_status_t* ctx, const char* str)
|
|||||||
str,
|
str,
|
||||||
ctx->vector_number, ctx->error_code, ctx->rax, ctx->rbx, ctx->rcx, ctx->rdx, ctx->rsi, ctx->rdi,
|
ctx->vector_number, ctx->error_code, ctx->rax, ctx->rbx, ctx->rcx, ctx->rdx, ctx->rsi, ctx->rdi,
|
||||||
ctx->r8, ctx->r9, ctx->r10, ctx->r11, ctx->r12, ctx->r13, ctx->r14, ctx->r15, ctx->iret_flags);
|
ctx->r8, ctx->r9, ctx->r10, ctx->r11, ctx->r12, ctx->r13, ctx->r14, ctx->r15, ctx->iret_flags);
|
||||||
|
|
||||||
|
if (init.terminal)
|
||||||
|
{
|
||||||
|
printf("\r\n\x1b[38;5;231m\x1b[48;5;196mKernel panic!!!\x1b[0m at rip=%p\r\nSomething went horribly wrong! (%s) vect=0x%.2x errcode=0x%x\n\rrax=%p rbx=%p rcx=%p rdx=%p\n\rrsi=%p rdi=%p r8=%p r9=%p\n\rr10=%p r11=%p r12=%p r13=%p\n\rr14=%p r15=%p\n\n\rflags=%p\n\rHalting...",
|
||||||
|
ctx->iret_rip,
|
||||||
|
str,
|
||||||
|
ctx->vector_number, ctx->error_code, ctx->rax, ctx->rbx, ctx->rcx, ctx->rdx, ctx->rsi, ctx->rdi,
|
||||||
|
ctx->r8, ctx->r9, ctx->r10, ctx->r11, ctx->r12, ctx->r13, ctx->r14, ctx->r15, ctx->iret_flags);
|
||||||
|
}
|
||||||
|
|
||||||
debug_stack_trace(100);
|
debug_stack_trace(100);
|
||||||
|
|
||||||
hcf();
|
hcf();
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
|
extern struct init_status init;
|
||||||
|
|
||||||
void debug_stack_trace(unsigned int max_frames)
|
void debug_stack_trace(unsigned int max_frames)
|
||||||
{
|
{
|
||||||
DEBUG("*** begin stack trace ***");
|
DEBUG("*** begin stack trace ***");
|
||||||
|
if (init.terminal)
|
||||||
|
{
|
||||||
|
printf("\r\n*** begin stack trace ***\r\n");
|
||||||
|
}
|
||||||
// Thanks GCC :)
|
// Thanks GCC :)
|
||||||
uintptr_t* rbp = (uintptr_t*)__builtin_frame_address(0);
|
uintptr_t* rbp = (uintptr_t*)__builtin_frame_address(0);
|
||||||
|
|
||||||
@@ -15,6 +21,11 @@ void debug_stack_trace(unsigned int max_frames)
|
|||||||
const char* name = debug_find_symbol(rip, &offset);
|
const char* name = debug_find_symbol(rip, &offset);
|
||||||
DEBUG("[%u] <0x%p> (%s+0x%x)", frame, (void*)rip, name, 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);
|
||||||
|
}
|
||||||
|
|
||||||
uintptr_t* next_rbp = (uintptr_t*)rbp[0];
|
uintptr_t* next_rbp = (uintptr_t*)rbp[0];
|
||||||
|
|
||||||
// invalid rbp or we're at the end
|
// invalid rbp or we're at the end
|
||||||
@@ -25,6 +36,10 @@ void debug_stack_trace(unsigned int max_frames)
|
|||||||
|
|
||||||
rbp = next_rbp;
|
rbp = next_rbp;
|
||||||
}
|
}
|
||||||
|
if (init.terminal)
|
||||||
|
{
|
||||||
|
printf("*** end stack trace ***");
|
||||||
|
}
|
||||||
DEBUG("*** end stack trace ***");
|
DEBUG("*** end stack trace ***");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ bool iran = false;
|
|||||||
// Never gets executed although pedicel is scheduled?
|
// Never gets executed although pedicel is scheduled?
|
||||||
void pedicel_main(void* arg)
|
void pedicel_main(void* arg)
|
||||||
{
|
{
|
||||||
|
//panic(NULL, "test");
|
||||||
bool iran = true;
|
bool iran = true;
|
||||||
// FROM THE NEXT LINE ONWARDS, CANNOT WRITE TO FRAMEBUFFER WITHOUT PAGE FAULT!
|
// FROM THE NEXT LINE ONWARDS, CANNOT WRITE TO FRAMEBUFFER WITHOUT PAGE FAULT!
|
||||||
//printf("\n\nWelcome to PepperOS! Pedicel speaking.\nNothing left to do, halting the system!");
|
//printf("\n\nWelcome to PepperOS! Pedicel speaking.\nNothing left to do, halting the system!");
|
||||||
|
|||||||
Reference in New Issue
Block a user