AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
trace.c File Reference

x86: a panic's stack trace. More...

#include <core/system.h>
#include <core/printk.h>
#include <boot/boot.h>

Go to the source code of this file.

Data Structures

struct  stack_frame
 A stack frame, as the compiler lays it out with frame pointers. More...

Functions

static const elf_sym_t * symbol_of (uintptr_t ip)
 Returns the symbol of the function that ip is in, or NULL if there are no symbols or no function holds it.
void arch_stack_trace (void)
 Prints the stack trace of the running code, for a panic: the return address of each frame.

Variables

struct boot * __kboot
int __printing_trace = 0

Detailed Description

x86: a panic's stack trace.

The trace follows the frame pointers: each frame holds the caller's saved ebp (rbp) and the return address. Each address is named from the kernel's symbol table when the boot loader passed it (Limine does, QEMU's -kernel doesn't); otherwise, mk/backtrace.sh names them from the kernel's ELF file.

Definition in file trace.c.

Function Documentation

◆ arch_stack_trace()

void arch_stack_trace ( void )

Prints the stack trace of the running code, for a panic: the return address of each frame.

Definition at line 43 of file trace.c.

References __kboot, __printing_trace, arch_stack_trace(), stack_frame::bp, stack_frame::ip, NULL, printk(), elf32_shdr::sh_addr, elf32_sym::st_name, elf32_sym::st_value, boot::strtab, and symbol_of().

◆ symbol_of()

const elf_sym_t * symbol_of ( uintptr_t ip)
static

Returns the symbol of the function that ip is in, or NULL if there are no symbols or no function holds it.

Definition at line 27 of file trace.c.

References __kboot, ELF32_ST_TYPE, NULL, elf32_shdr::sh_addr, elf32_sym::st_info, elf32_sym::st_size, elf32_sym::st_value, boot::strtab, STT_FUNC, symbol_of(), boot::symnum, and boot::symtab.

Referenced by arch_stack_trace(), and symbol_of().

Variable Documentation

◆ __kboot

struct boot* __kboot
extern

Definition at line 19 of file init.c.

◆ __printing_trace

int __printing_trace = 0

Definition at line 23 of file trace.c.