From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oPYWKggUwWKnIwsAWB0awg (envelope-from ) for ; Sat, 02 Jul 2022 23:59:04 -0400 Received: by simark.ca (Postfix, from userid 112) id A77261E22B; Sat, 2 Jul 2022 23:59:04 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=PU0OsECS; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 575001E227 for ; Sat, 2 Jul 2022 23:59:03 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09AB4384602A for ; Sun, 3 Jul 2022 03:59:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09AB4384602A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1656820743; bh=FiXiIaI9DnU2joIutP8+wX0AWgOjSIEybSMcYhLzQ7I=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PU0OsECSvWnOnxYW5XLcUc6p7E8ueYWPjJEY7nRGRV11e2t7ROxn1sovMMIX4v+ja VYbT8N11qlnd/ZFdxSiX1vvx+q9doUt0xOREK55WN+Dpog8f2ttZbIhnWYJAWWUcKB 2ttQVzqSsAaOGVsC2KeplMwVuS7jF0bQ+earDc3s= Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 5B4A83857360 for ; Sun, 3 Jul 2022 03:58:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B4A83857360 Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id BEFCE66777; Sat, 2 Jul 2022 23:58:40 -0400 (EDT) Message-ID: Subject: [PATCH] gdb: LoongArch: add orig_a0 into register set To: gdb-patches@sourceware.org Date: Sun, 03 Jul 2022 11:58:38 +0800 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 MIME-Version: 1.0 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Xi Ruoyao via Gdb-patches Reply-To: Xi Ruoyao Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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/tre= e/arch/loongarch/include/uapi/asm/ptrace.h#n24 Signed-off-by: Xi Ruoyao --- 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(-) diff --git a/gdb/features/loongarch/base32.c b/gdb/features/loongarch/base3= 2.c index 7105c152aed..3fb35ef2d05 100644 --- a/gdb/features/loongarch/base32.c +++ b/gdb/features/loongarch/base32.c @@ -41,6 +41,7 @@ create_feature_loongarch_base32 (struct target_desc *resu= lt, long regnum) tdesc_create_reg (feature, "r29", regnum++, 1, "general", 32, "uint32"); tdesc_create_reg (feature, "r30", regnum++, 1, "general", 32, "uint32"); tdesc_create_reg (feature, "r31", regnum++, 1, "general", 32, "uint32"); + tdesc_create_reg (feature, "orig_a0", regnum++, 1, "general", 32, "uint3= 2"); tdesc_create_reg (feature, "pc", regnum++, 1, "general", 32, "code_ptr")= ; tdesc_create_reg (feature, "badv", regnum++, 1, "general", 32, "code_ptr= "); return regnum; diff --git a/gdb/features/loongarch/base32.xml b/gdb/features/loongarch/bas= e32.xml index 5b00f8a8d37..af47bbd3da4 100644 --- a/gdb/features/loongarch/base32.xml +++ b/gdb/features/loongarch/base32.xml @@ -39,6 +39,7 @@ + diff --git a/gdb/features/loongarch/base64.c b/gdb/features/loongarch/base6= 4.c index 63eee024554..d84d4256294 100644 --- a/gdb/features/loongarch/base64.c +++ b/gdb/features/loongarch/base64.c @@ -41,6 +41,7 @@ create_feature_loongarch_base64 (struct target_desc *resu= lt, long regnum) tdesc_create_reg (feature, "r29", regnum++, 1, "general", 64, "uint64"); tdesc_create_reg (feature, "r30", regnum++, 1, "general", 64, "uint64"); tdesc_create_reg (feature, "r31", regnum++, 1, "general", 64, "uint64"); + tdesc_create_reg (feature, "orig_a0", regnum++, 1, "general", 64, "uint6= 4"); tdesc_create_reg (feature, "pc", regnum++, 1, "general", 64, "code_ptr")= ; tdesc_create_reg (feature, "badv", regnum++, 1, "general", 64, "code_ptr= "); return regnum; diff --git a/gdb/features/loongarch/base64.xml b/gdb/features/loongarch/bas= e64.xml index bef91e50dd7..2d8a1f6b734 100644 --- a/gdb/features/loongarch/base64.xml +++ b/gdb/features/loongarch/base64.xml @@ -39,6 +39,7 @@ + diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c index 21fc67f9323..8f70dda83eb 100644 --- a/gdb/loongarch-linux-tdep.c +++ b/gdb/loongarch-linux-tdep.c @@ -48,6 +48,9 @@ loongarch_supply_gregset (const struct regset *regset, regcache->raw_supply (i, (const void *) buf); } =20 + buf =3D (const gdb_byte*) gprs + regsize * LOONGARCH_ORIG_A0_REGNUM; + regcache->raw_supply (LOONGARCH_ORIG_A0_REGNUM, (const void *) buf); + buf =3D (const gdb_byte*) gprs + regsize * LOONGARCH_PC_REGNUM; regcache->raw_supply (LOONGARCH_PC_REGNUM, (const void *) buf); =20 @@ -57,6 +60,7 @@ loongarch_supply_gregset (const struct regset *regset, else if (regnum =3D=3D 0) regcache->raw_supply_zeroed (0); else if ((regnum > 0 && regnum < 32) + || regnum =3D=3D LOONGARCH_ORIG_A0_REGNUM || regnum =3D=3D LOONGARCH_PC_REGNUM || regnum =3D=3D LOONGARCH_BADV_REGNUM) { diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index f2f4e3be909..76480ce6c94 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -576,6 +576,7 @@ loongarch_gdbarch_init (struct gdbarch_info info, struc= t gdbarch_list *arches) for (int i =3D 0; i < 32; i++) valid_p &=3D tdesc_numbered_register (feature_cpu, tdesc_data.get (), = regnum++, loongarch_r_normal_name[i] + 1); + valid_p &=3D tdesc_numbered_register (feature_cpu, tdesc_data.get (), re= gnum++, "orig_a0"); valid_p &=3D tdesc_numbered_register (feature_cpu, tdesc_data.get (), re= gnum++, "pc"); valid_p &=3D tdesc_numbered_register (feature_cpu, tdesc_data.get (), re= gnum++, "badv"); if (!valid_p) diff --git a/gdb/loongarch-tdep.h b/gdb/loongarch-tdep.h index 54b34af1d66..acf0191fd65 100644 --- a/gdb/loongarch-tdep.h +++ b/gdb/loongarch-tdep.h @@ -35,9 +35,10 @@ enum LOONGARCH_A0_REGNUM =3D 4, /* First Argument/Return Value. */ LOONGARCH_A7_REGNUM =3D 11, /* Seventh Argument/Syscall Number. */ LOONGARCH_FP_REGNUM =3D 22, /* Frame Pointer. */ - LOONGARCH_PC_REGNUM =3D 32, /* Program Counter. */ - LOONGARCH_BADV_REGNUM =3D 33, /* Bad Vaddr for Addressing Exception. *= / - LOONGARCH_LINUX_NUM_GREGSET =3D 45, /* 32 GPR, PC, BADV, RESERVED 11. *= / + LOONGARCH_ORIG_A0_REGNUM =3D 32, /* Syscall's original arg0. */ + LOONGARCH_PC_REGNUM =3D 33, /* Program Counter. */ + LOONGARCH_BADV_REGNUM =3D 34, /* Bad Vaddr for Addressing Exception. *= / + LOONGARCH_LINUX_NUM_GREGSET =3D 45, /* 32 GPR, ORIG_A0, PC, BADV, RESERV= ED 10. */ }; =20 /* Register set definitions. */ --=20 2.37.0