Kernel: Clenup stacktrace printing on exception
Start from current ip and bp. This removes kernel call stack to debug printing function from the stack trace
This commit is contained in:
parent
d3df00f0ba
commit
5d62fa3f10
|
|
@ -76,6 +76,7 @@
|
||||||
namespace Debug
|
namespace Debug
|
||||||
{
|
{
|
||||||
void dump_stack_trace();
|
void dump_stack_trace();
|
||||||
|
void dump_stack_trace(uintptr_t ip, uintptr_t bp);
|
||||||
void dump_qr_code();
|
void dump_qr_code();
|
||||||
|
|
||||||
void putchar(char);
|
void putchar(char);
|
||||||
|
|
|
||||||
|
|
@ -29,28 +29,33 @@ namespace Debug
|
||||||
static uint8_t s_debug_ansi_state { 0 };
|
static uint8_t s_debug_ansi_state { 0 };
|
||||||
|
|
||||||
void dump_stack_trace()
|
void dump_stack_trace()
|
||||||
|
{
|
||||||
|
dump_stack_trace(0, reinterpret_cast<uintptr_t>(__builtin_frame_address(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_stack_trace(uintptr_t ip, uintptr_t bp)
|
||||||
{
|
{
|
||||||
using namespace Kernel;
|
using namespace Kernel;
|
||||||
|
|
||||||
struct stackframe
|
struct stackframe
|
||||||
{
|
{
|
||||||
stackframe* bp;
|
stackframe* bp;
|
||||||
uintptr_t ip;
|
void* ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
SpinLockGuard _(s_debug_lock);
|
SpinLockGuard _(s_debug_lock);
|
||||||
|
|
||||||
stackframe* frame = (stackframe*)__builtin_frame_address(0);
|
const stackframe* frame = reinterpret_cast<const stackframe*>(bp);
|
||||||
if (!frame)
|
|
||||||
{
|
void* first_ip = frame->ip;
|
||||||
dprintln("Could not get frame address");
|
void* last_ip = 0;
|
||||||
return;
|
|
||||||
}
|
|
||||||
uintptr_t first_ip = frame->ip;
|
|
||||||
uintptr_t last_ip = 0;
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
BAN::Formatter::print(Debug::putchar, "\e[36mStack trace:\r\n");
|
BAN::Formatter::print(Debug::putchar, "\e[36mStack trace:\r\n");
|
||||||
|
|
||||||
|
if (ip != 0)
|
||||||
|
BAN::Formatter::print(Debug::putchar, " {}\r\n", reinterpret_cast<void*>(ip));
|
||||||
|
|
||||||
while (frame)
|
while (frame)
|
||||||
{
|
{
|
||||||
if (!PageTable::is_valid_pointer((vaddr_t)frame))
|
if (!PageTable::is_valid_pointer((vaddr_t)frame))
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,11 @@ namespace Kernel
|
||||||
#endif
|
#endif
|
||||||
if (isr == ISR::PageFault)
|
if (isr == ISR::PageFault)
|
||||||
PageTable::current().debug_dump();
|
PageTable::current().debug_dump();
|
||||||
Debug::dump_stack_trace();
|
#if ARCH(x86_64)
|
||||||
|
Debug::dump_stack_trace(interrupt_stack->ip, regs->rbp);
|
||||||
|
#elif ARCH(i686)
|
||||||
|
Debug::dump_stack_trace(interrupt_stack->ip, regs->ebp);
|
||||||
|
#endif
|
||||||
|
|
||||||
Debug::s_debug_lock.unlock(InterruptState::Disabled);
|
Debug::s_debug_lock.unlock(InterruptState::Disabled);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue