KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
stack.h File Reference

Stack functions. More...

#include <kos/cdefs.h>
#include <stdint.h>
#include <kos/thread.h>

Go to the source code of this file.

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.
 
bool arch_stk_unwind_step (uintptr_t sp, uintptr_t *ret_addr_out, uintptr_t *next_sp_out)
 Find the next return address by scanning the stack.
 
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 (uintptr_t sp, size_t n)
 Do a stack trace from the given stack pointer.
 

Detailed Description

Stack functions.

This file contains arch-specific stack implementations, including defining stack sizes and alignments, as well as functions for stack tracing and debugging. On Dreamcast, the stack tracing functions use heuristic stack pointer scanning rather than frame pointer chains, because GCC for SH4 does not reliably maintain r14-based frame pointers, even with -fno-omit-frame-pointer.

Author
Megan Potter
Eric Fradella