Skip to content

xtensa: gdbstub: fix backtracing and stack unwinding #90085

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dcpleung
Copy link
Member

This fixes GDB backtracing by forcibly spilling all registers, and returning 0s for WINDOWSTART and WINDOWBASE. This is effectively telling GDB that none of physical registers contains active data, and must rely on spilled values on stack. Otherwise, GDB will try to look at AR* registers for previous frame(s). Since we don't save all AR* register values, there is nothing for GDB to look at, and thus failing to unwind stack.

With this change, there is no need to populate a portion of the AR* registers, and no need for keep tracking where those registers related to windowed are.

The calculation of number of high registers is not entirely
correct. We need to get past the pointer to BSA in the stack
frame before reaching the high registers. The location address
difference between the BSA and start of high registers then
can be used to calculate how many high registers in the stack
frame. So correct the start location of high registers in
the calculation as it was incorrect before. Though the result
would be the same as further divisions would mask this error.
However, it is better to correct this for readability.

Signed-off-by: Daniel Leung <[email protected]>
@dcpleung dcpleung force-pushed the xtensa/fix_gdbstub branch from 7623ff7 to 148fe97 Compare May 16, 2025 23:44
This fixes GDB backtracing by forcibly spilling all registers,
and returning 0s for WINDOWSTART and WINDOWBASE. This is
effectively telling GDB that none of physical registers contains
active data, and must rely on spilled values on stack. Otherwise,
GDB will try to look at AR* registers for previous frame(s).
Since we don't save all AR* register values, there is nothing
for GDB to look at, and thus failing to unwind stack.

With this change, there is no need to populate a portion of
the AR* registers, and no need for keep tracking where those
registers related to windowed are.

Signed-off-by: Daniel Leung <[email protected]>
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant