[PATCH V2] gdb/testsuite: Add LoongArch case in my-syscalls.S

Zewei Yang
2025-10-23T01:46:27Z

This patch adds syscall wrappers for LoongArch64 to gdb/testsuite/lib/my-syscalls.S.

- Implements the missing `__loongarch64` section.
- Uses `li.w` to load the syscall number into `$a7`.
- Triggers system calls via `syscall 0`.
- Returns to the caller using `ret`.

This change fixes build errors when running
`gdb.threads/step-over-thread-exit-while-stop-all-threads.exp`
on LoongArch64 targets caused by the absence of the LoongArch-specific
syscall wrappers in `my-syscalls.S`.

Tested on: loongarch64-unknown-linux-gnu
Result: expected testcases passed.

Signed-off-by: Zewei Yang <yangzewei@loongson.cn>
---
gdb/testsuite/lib/my-syscalls.S | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/gdb/testsuite/lib/my-syscalls.S b/gdb/testsuite/lib/my-syscalls.S
index c514b32d..3e2e397d 100644
--- a/gdb/testsuite/lib/my-syscalls.S
+++ b/gdb/testsuite/lib/my-syscalls.S
@@ -63,6 +63,18 @@ NAME: ;\
NAME ## _syscall: ;\
svc #0

+#elif defined(__loongarch64)
+
+/* LoongArch 64-bit syscall wrapper */
+#define SYSCALL(NAME, NR) \
+.global NAME ;\
+NAME: ;\
+ li.w $a7, NR ;\
+ /* syscall number */ \
+NAME ## _syscall: ;\
+ syscall 0 ;\
+ ret
+
#else
# error "Unsupported architecture"
#endif
--
2.43.0