Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coredump: ARM: Ensure sp in dump is set as gdb expects #79622

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

mrkhldn
Copy link
Contributor

@mrkhldn mrkhldn commented Oct 9, 2024

Gdb is typically able to reconstruct the first two frames of the failing stack using the "pc" and "lr" registers. After that, (if the frame pointer is omitted) it appears to need the stack pointer (sp register) to point to the top of the stack before a fatal error occurred.

The ARM Cortex-M processors push registers r0-r3, r12, LR, {possibly FPU registers}, PC, SPSR onto the stack before entering the exception handler. We adjust the stack pointer back to the point before these registers were pushed for preservation in the dump.

During k_oops/k_panic, the sp wasn't stored in the core dump at all. Apply similar logic to store it when failures occur in that path.

Fixes #78788

@zephyrbot zephyrbot added the area: ARM ARM (32-bit) Architecture label Oct 9, 2024
@mrkhldn mrkhldn linked an issue Oct 9, 2024 that may be closed by this pull request
@mrkhldn
Copy link
Contributor Author

mrkhldn commented Oct 9, 2024

Re-submitting #73189 with a fix for the regression

Gdb is typically able to reconstruct the first two frames of the
failing stack using the "pc" and "lr" registers. After that, (if
the frame pointer is omitted) it appears to need the stack pointer
(sp register) to point to the top of the stack before a fatal
error occurred.

The ARM Cortex-M processors push registers r0-r3, r12, LR,
{possibly FPU registers}, PC, SPSR onto the stack before entering the
exception handler. We adjust the stack pointer back to the point
before these registers were pushed for preservation in the dump.

During k_oops/k_panic, the sp wasn't stored in the core dump at all.
Apply similar logic to store it when failures occur in that path.

Signed-off-by: Mark Holden <[email protected]>
@mrkhldn
Copy link
Contributor Author

mrkhldn commented Oct 22, 2024

@ithinuel, thanks for approving the previous attempt at this fix. Can you take a quick look at this resubmission, with the build fix?

@ycsin
Copy link
Member

ycsin commented Nov 4, 2024

ping @ithinuel @carlocaione

Copy link
Member

@stephanosio stephanosio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not seeing anything obviously wrong with it.

@dkalowsk dkalowsk merged commit 8bd4f24 into zephyrproject-rtos:main Nov 6, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception Stack Frames are not correct in coredumps
6 participants