KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Stack Traces

API for managing stack backtracing More...

Files

file  stack.h
 Stack functions.
 

Macros

#define THD_STACK_ALIGNMENT   8
 Required alignment for stack.
 
#define THD_STACK_SIZE   32768
 Default thread stack size.
 
#define THD_KERNEL_STACK_SIZE   (64 * 1024)
 Main/kernel thread's stack size.
 

Functions

static __always_inline uintptr_t arch_get_ret_addr (void)
 DC specific "function" to get the return address from the current function.
 
static __always_inline uintptr_t arch_get_fptr (void)
 DC specific "function" to get the frame pointer from the current function.
 
static uintptr_t arch_fptr_ret_addr (uintptr_t fptr)
 Pass in a frame pointer value to get the return address for the given frame.
 
static uintptr_t arch_fptr_next (uintptr_t fptr)
 Pass in a frame pointer value to get the previous frame pointer for the given frame.
 
void arch_stk_setup (kthread_t *nt)
 Set up new stack before running.
 
void arch_stk_trace (int n)
 Do a stack trace from the current function.
 
void arch_stk_trace_at (uint32_t fp, size_t n)
 Do a stack trace from the current function.
 

Detailed Description

API for managing stack backtracing

Macro Definition Documentation

◆ THD_KERNEL_STACK_SIZE

#define THD_KERNEL_STACK_SIZE   (64 * 1024)

Main/kernel thread's stack size.

◆ THD_STACK_ALIGNMENT

#define THD_STACK_ALIGNMENT   8

Required alignment for stack.

◆ THD_STACK_SIZE

#define THD_STACK_SIZE   32768

Default thread stack size.

Function Documentation

◆ arch_fptr_next()

static uintptr_t arch_fptr_next ( uintptr_t fptr)
inlinestatic

Pass in a frame pointer value to get the previous frame pointer for the given frame.

Parameters
fptrThe frame pointer to look at.
Returns
The previous frame pointer.

References arch_fptr_ret_addr().

◆ arch_fptr_ret_addr()

static uintptr_t arch_fptr_ret_addr ( uintptr_t fptr)
inlinestatic

Pass in a frame pointer value to get the return address for the given frame.

Parameters
fptrThe frame pointer to look at.
Returns
The return address of the pointer.

Referenced by arch_fptr_next().

◆ arch_get_fptr()

static __always_inline uintptr_t arch_get_fptr ( void )
static

DC specific "function" to get the frame pointer from the current function.

Returns
The frame pointer from the current function.
Note
This only works if you don't disable frame pointers.

◆ arch_get_ret_addr()

static __always_inline uintptr_t arch_get_ret_addr ( void )
static

DC specific "function" to get the return address from the current function.

Returns
The return address of the current function.

◆ arch_stk_setup()

void arch_stk_setup ( kthread_t * nt)

Set up new stack before running.

This function does nothing as it is unnecessary on Dreamcast.

Parameters
ntA pointer to the new thread for which a stack is to be set up.

◆ arch_stk_trace()

void arch_stk_trace ( int n)

Do a stack trace from the current function.

This function does a stack trace from the current function, printing the results to stdout. This is used, for instance, when an assertion fails in assert().

Parameters
nThe number of frames to leave off. Each frame is a jump to subroutine or branch to subroutine. assert() leaves off 2 frames, for reference.

◆ arch_stk_trace_at()

void arch_stk_trace_at ( uint32_t fp,
size_t n )

Do a stack trace from the current function.

This function does a stack trace from the the specified frame pointer, printing the results to stdout. This could be used for doing something like stack tracing a main thread from inside an IRQ handler.

Parameters
fpThe frame pointer to start from.
nThe number of frames to leave off.