![]() |
SyterKit 0.4.0.x
SyterKit is a bare-metal framework
|
Go to the source code of this file.
Functions | |
| int | backtrace (char *PC, long *SP, char *LR) |
| Perform a backtrace to find the call stack. | |
| int | dump_stack (void) |
| Dumps the current stack state and performs a backtrace. | |
| int backtrace | ( | char * | PC, |
| long * | SP, | ||
| char * | LR | ||
| ) |
Perform a backtrace to find the call stack.
This function attempts to walk the call stack by analyzing the program counter (PC), stack pointer (SP), and link register (LR) to determine the sequence of function calls leading to the current execution point.
The backtrace process works by using the stack and link register to trace the call hierarchy, logging each level of the backtrace, and attempting recovery from any errors. If the backtrace from the stack fails, it will attempt to trace using the link register (LR).
| PC | The current program counter (PC), typically pointing to the instruction where the backtrace starts. |
| SP | The current stack pointer (SP), pointing to the top of the stack. |
| LR | The link register (LR), used to store return addresses for function calls. |
Perform a backtrace to find the call stack.
This function tries to traverse the stack to generate a backtrace, logging the current PC at each level. If the stack backtrace fails, it attempts to trace using the LR as a fallback.
| PC | Pointer to the program counter. |
| SP | Pointer to the stack pointer. |
| LR | Pointer to the link register (return address). |
| int dump_stack | ( | void | ) |
Dumps the current stack state and performs a backtrace.
This function captures the current program counter (PC), stack pointer (SP), link register (LR), and current processor status register (CPSR). It uses inline assembly to obtain these values, then performs a backtrace to provide insight into the function call stack.
The function also checks if the processor is in THUMB mode based on the CPSR state and adjusts the program counter (PC) accordingly. If the program counter or stack pointer is invalid, the function will return early with a status of 0.
Dumps the current stack state and performs a backtrace.
This function retrieves the current values of the stack pointer, program counter, and link register, then uses these to generate a backtrace. If either the stack pointer or program counter is invalid, it returns 0.