Consider removing the need for a "sentinel stack frame" while unwinding #382
Description
At the moment, it is necessary for probe-run
to "run into" a sentinel frame where the link register is recorded as 0xFFFF_FFFF
while unwinding (on panic).
rust-embedded/cortex-m-rt#337 was opened to include this in c-m-rt
, but it turns out, this caused a pretty serious regression, that we just recently caught.
We're fixing this for cortex-m-rt
v0.7.3 (in rust-embedded/cortex-m#463) by pushing another word to the stack, but this means that all targets have 8 bytes of "dead" stack usage, as well as some startup code (and confusing asm) necessary to insert the necessary "full stack frame".
During testing, we noticed that GDB was actually totally happy to not have the sentinel frame at all - only probe-run
was upset (it throws a warning that the stack is corrupted).
We're currently looking at whether it would be possible to totally remove the sentinel frame in c-m-rt. Ideally, this would involve probe-run being able to handle the case where it hits the end of the stack without hitting the sentinel frame.
No hard decision has been made to remove the termination frame (and cfi/cfa hints) yet, but there seems to be some desire to. We decided to keep it (and add a second push) for now, to allow us to ship 0.7.3 ASAP, and not break (or cause problems for) probe-run.
(suggested impl ahead, feel free to ignore): I think it should be possible to notice when hitting the stack top symbol, and if it was hit "gracefully", e.g. there is SOME frame right at the top of the stack with no excess data, it can be treated as the terminal frame, and not throw a "stack corrupted" warning.
I'm happy to provide a patched version of cortex-m-rt that would reproduce the currently discussed behavior for testing.