Fix backtraces from syscall stubs #571
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes oxidecomputer/hubris#2236
Functions defined with
naked_asm
do not have unwind info (see also rust-lang/rust#146736). For tasks which are in a syscall stub, this prevents our stack unwinder from making any progress: it can't get the unwind info for the bottom stack frame, so can't walk up the stack at all.This PR adds a new function
stack_syscall
which assumes that we're at a syscall, and begins stack walking one frame up to escape the tarpit: we useLR
as the program counter, and populate register values based on the pushes at syscall entry. We then prepend a synthetic stack frame with details about the syscall stub, since we can get its name from ELF tables.stack_syscall
is called if the normalhubris.stack(..)
call fails, but we did get registers (indicating that there wasn't a stack overflow). In practice, it blends in well: