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
|
||||
{
|
||||
void dump_stack_trace();
|
||||
void dump_stack_trace(uintptr_t ip, uintptr_t bp);
|
||||
void dump_qr_code();
|
||||
|
||||
void putchar(char);
|
||||
|
|
|
|||
|
|
@ -29,28 +29,33 @@ namespace Debug
|
|||
static uint8_t s_debug_ansi_state { 0 };
|
||||
|
||||
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;
|
||||
|
||||
struct stackframe
|
||||
{
|
||||
stackframe* bp;
|
||||
uintptr_t ip;
|
||||
void* ip;
|
||||
};
|
||||
|
||||
SpinLockGuard _(s_debug_lock);
|
||||
|
||||
stackframe* frame = (stackframe*)__builtin_frame_address(0);
|
||||
if (!frame)
|
||||
{
|
||||
dprintln("Could not get frame address");
|
||||
return;
|
||||
}
|
||||
uintptr_t first_ip = frame->ip;
|
||||
uintptr_t last_ip = 0;
|
||||
const stackframe* frame = reinterpret_cast<const stackframe*>(bp);
|
||||
|
||||
void* first_ip = frame->ip;
|
||||
void* last_ip = 0;
|
||||
bool first = true;
|
||||
|
||||
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)
|
||||
{
|
||||
if (!PageTable::is_valid_pointer((vaddr_t)frame))
|
||||
|
|
|
|||
|
|
@ -277,7 +277,11 @@ namespace Kernel
|
|||
#endif
|
||||
if (isr == ISR::PageFault)
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue