Skip to content

Commit 50bb458

Browse files
committed
gh-152240: Fix LoongArch frame pointer unwinding
1 parent 7d128e3 commit 50bb458

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix C stack unwinding tests on Linux LoongArch builds by teaching the manual
2+
frame pointer unwinder to recognize the LoongArch frame layout.

Modules/_testinternalcapi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ static const uintptr_t min_frame_pointer_addr = 0x1000;
9898
// https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
9999
# define FRAME_POINTER_NEXT_OFFSET 0
100100
# define FRAME_POINTER_RETURN_OFFSET 2
101+
#elif defined(__loongarch__)
102+
// On LoongArch, the frame pointer is the caller's stack pointer.
103+
// The saved frame pointer is stored at fp[-2], and the return
104+
// address is stored at fp[-1].
105+
# define FRAME_POINTER_NEXT_OFFSET -2
106+
# define FRAME_POINTER_RETURN_OFFSET -1
101107
#else
102108
# define FRAME_POINTER_NEXT_OFFSET 0
103109
# define FRAME_POINTER_RETURN_OFFSET 1

0 commit comments

Comments
 (0)