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

Tiezhu Yang
2025-10-24T02:45:39Z

On 2025/10/23 上午9:45, Zewei Yang wrote:
> 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

Looks good to me in general, if there are no more comments or
objections, I will adjust the commit message and code format,
then push this patch in the next week, because it is related
with LoongArch and no side effect for the other archs.

Thanks,
Tiezhu