Add panic/stack trace display on fb for real hardware debug
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
#include <stdint.h>
|
||||
#include "kernel.h"
|
||||
|
||||
extern struct init_status init;
|
||||
|
||||
void debug_stack_trace(unsigned int max_frames)
|
||||
{
|
||||
DEBUG("*** begin stack trace ***");
|
||||
if (init.terminal)
|
||||
{
|
||||
printf("\r\n*** begin stack trace ***\r\n");
|
||||
}
|
||||
// Thanks GCC :)
|
||||
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);
|
||||
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];
|
||||
|
||||
// invalid rbp or we're at the end
|
||||
@@ -25,6 +36,10 @@ void debug_stack_trace(unsigned int max_frames)
|
||||
|
||||
rbp = next_rbp;
|
||||
}
|
||||
if (init.terminal)
|
||||
{
|
||||
printf("*** end stack trace ***");
|
||||
}
|
||||
DEBUG("*** end stack trace ***");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user