gh-152240: Fix test_c_stack_unwind on Linux LoongArch builds (#152241) · python/cpython@8458582

GitHub

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.

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# defineFRAME_POINTER_NEXT_OFFSET 0

100100# defineFRAME_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+# defineFRAME_POINTER_NEXT_OFFSET -2

106+# defineFRAME_POINTER_RETURN_OFFSET -1

101107#else

102108# defineFRAME_POINTER_NEXT_OFFSET 0

103109# defineFRAME_POINTER_RETURN_OFFSET 1