The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
backtrace.c File Reference
#include "backtrace.h"
#include "arch/arch.h"
#include "common/stdio.h"
#include "kernel/klog/klog.h"
#include "kernel/debug/ksyms.h"

Macros

#define BT_LINE(fmt, ...)
#define ADDR_HEX_DIGITS   (2 * sizeof(uintptr_t))

Functions

void backtrace_print_pc (const char *label, uintptr_t pc)
 print one code address as "0x0001234a func+0x1c".
void backtrace_print_return (const char *label, uintptr_t ret)
 print one return address.
void backtrace_print (uintptr_t frame)
 print the return addresses found by walking frame pointers from frame.

Macro Definition Documentation

◆ BT_LINE

#define BT_LINE ( fmt,
... )
Value:
do \
{ \
printf(fmt "\r\n", __VA_ARGS__); \
KLOG_ERROR(fmt, __VA_ARGS__); \
} while (0)

◆ ADDR_HEX_DIGITS

#define ADDR_HEX_DIGITS   (2 * sizeof(uintptr_t))

Function Documentation

◆ backtrace_print_pc()

void backtrace_print_pc ( const char * label,
uintptr_t pc )

print one code address as "0x0001234a func+0x1c".

Parameters
labeltext printed before the address (e.g. "at" or "#3").
pcthe code address.

◆ backtrace_print_return()

void backtrace_print_return ( const char * label,
uintptr_t ret )

print one return address.

like backtrace_print_pc, but the symbol is looked up for the call instruction before it (ret - 1).

Parameters
labeltext printed before the address (e.g. "?").
retthe return address.

◆ backtrace_print()

void backtrace_print ( uintptr_t frame)

print the return addresses found by walking frame pointers from frame.

stops at the first address outside kernel code (e.g. a user-mode frame).

Parameters
framethe frame pointer to start from.