Re: [PATCH] gdb: LoongArch: add orig_a0 into register set

Tiezhu Yang
2022-07-04T02:50:49Z

On 07/03/2022 11:58 AM, Xi Ruoyao wrote:
> Upstreamed Linux kernel has added orig_a0 into struct user_pt_regs.
> Adapt GDB register definition so it will work with upstream kernel.
>
> Url: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/uapi/asm/ptrace.h#n24
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
> ---
> gdb/features/loongarch/base32.c | 1 +
> gdb/features/loongarch/base32.xml | 1 +
> gdb/features/loongarch/base64.c | 1 +
> gdb/features/loongarch/base64.xml | 1 +
> gdb/loongarch-linux-tdep.c | 4 ++++
> gdb/loongarch-tdep.c | 1 +
> gdb/loongarch-tdep.h | 7 ++++---
> 7 files changed, 13 insertions(+), 3 deletions(-)

Hi Ruoyao,

Thank you for your patch.

The related code in gdb/loongarch-linux-nat.c also need to be modified.

Additionally, we know that the LoongArch upstream Linux kernel can not
actually be used before efistub, irqchip and pci are merged [0].

[0]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6f2f3e2c80e

So I think we can modify the patch subject and the commit message like this:

gdb: LoongArch: Add orig_a0 to match upstream Linux kernel

The basic support for LoongArch has been merged into the upstream Linux
kernel since 5.19-rc1 on June 5, 2022, this commit adds orig_a0 which
is added into struct user_pt_regs [1] to match the upstream kernel, and
then the upstream GDB will work with the upstream kernel.

Note that there is no orig_a0 in struct user_pt_regs in the product kernel
which version is 4.19, if somebody wants to use the upstream GDB with the
product kernel, please revert this commit manually.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/uapi/asm/ptrace.h#n24

Thanks,
Tiezhu