Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions
@ 2025-08-19  7:33 Xi Ruoyao
  2025-08-19  8:45 ` Tiezhu Yang
  2025-08-25 12:12 ` Tiezhu Yang
  0 siblings, 2 replies; 5+ messages in thread
From: Xi Ruoyao @ 2025-08-19  7:33 UTC (permalink / raw)
  To: gdb-patches
  Cc: Tiezhu Yang, Hui Li, Lulu Cheng, Mingcong Bai, Xuerui Wang, Xi Ruoyao

We can't put a breakpoint in the middle of a ll/sc atomic sequence,
recognize the sc.q, screl.w, and screl.d instructions added in LoongArch
v1.10 so a ll/sc atomic sequence using them won't loop forever being
debugged.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
 gdb/loongarch-tdep.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index cc75cd4a3d3..7556b81a9fa 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -98,7 +98,9 @@ static bool
 loongarch_insn_is_ll (insn_t insn)
 {
   if ((insn & 0xff000000) == 0x20000000		/* ll.w  */
-      || (insn & 0xff000000) == 0x22000000)	/* ll.d  */
+      || (insn & 0xff000000) == 0x22000000	/* ll.d  */
+      || (insn & 0xfffffc00) == 0x38578000	/* llacq.w  */
+      || (insn & 0xfffffc00) == 0x38578800)	/* llacq.d  */
     return true;
   return false;
 }
@@ -109,7 +111,10 @@ static bool
 loongarch_insn_is_sc (insn_t insn)
 {
   if ((insn & 0xff000000) == 0x21000000		/* sc.w  */
-      || (insn & 0xff000000) == 0x23000000)	/* sc.d  */
+      || (insn & 0xff000000) == 0x23000000	/* sc.d  */
+      || (insn & 0xffff8000) == 0x38570000	/* sc.q  */
+      || (insn & 0xfffffc00) == 0x38578400	/* screl.w  */
+      || (insn & 0xfffffc00) == 0x38578c00)	/* screl.d  */
     return true;
   return false;
 }
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions
  2025-08-19  7:33 [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions Xi Ruoyao
@ 2025-08-19  8:45 ` Tiezhu Yang
  2025-08-20 10:57   ` WANG Xuerui
  2025-08-25 12:12 ` Tiezhu Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-19  8:45 UTC (permalink / raw)
  To: Xi Ruoyao, gdb-patches; +Cc: Hui Li, Lulu Cheng, Mingcong Bai, Xuerui Wang

On 2025/8/19 下午3:33, Xi Ruoyao wrote:
> We can't put a breakpoint in the middle of a ll/sc atomic sequence,
> recognize the sc.q, screl.w, and screl.d instructions added in LoongArch

sc.q, ll.acq.{w/d}, sc.rel.{w/d}

> v1.10 so a ll/sc atomic sequence using them won't loop forever being
> debugged.

It is better to add the references:

https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_sc_q
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_ll_acq_wd_sc_rel_wd

> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
> ---
>   gdb/loongarch-tdep.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
> index cc75cd4a3d3..7556b81a9fa 100644
> --- a/gdb/loongarch-tdep.c
> +++ b/gdb/loongarch-tdep.c
> @@ -98,7 +98,9 @@ static bool
>   loongarch_insn_is_ll (insn_t insn)
>   {
>     if ((insn & 0xff000000) == 0x20000000		/* ll.w  */
> -      || (insn & 0xff000000) == 0x22000000)	/* ll.d  */
> +      || (insn & 0xff000000) == 0x22000000	/* ll.d  */
> +      || (insn & 0xfffffc00) == 0x38578000	/* llacq.w  */
> +      || (insn & 0xfffffc00) == 0x38578800)	/* llacq.d  */
>       return true;
>     return false;
>   }
> @@ -109,7 +111,10 @@ static bool
>   loongarch_insn_is_sc (insn_t insn)
>   {
>     if ((insn & 0xff000000) == 0x21000000		/* sc.w  */
> -      || (insn & 0xff000000) == 0x23000000)	/* sc.d  */
> +      || (insn & 0xff000000) == 0x23000000	/* sc.d  */
> +      || (insn & 0xffff8000) == 0x38570000	/* sc.q  */
> +      || (insn & 0xfffffc00) == 0x38578400	/* screl.w  */
> +      || (insn & 0xfffffc00) == 0x38578c00)	/* screl.d  */
>       return true;
>     return false;
>   }

The encodings for the instructions that you're handling look correct
to me. I prefer using ll.acq.w, ll.acq.d, sc.rel.w, sc.rel.d in the
code comments to make consistent with the manual.

If no more comments, I will amend these when applying in the next week,
no need to send v2.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions
  2025-08-19  8:45 ` Tiezhu Yang
@ 2025-08-20 10:57   ` WANG Xuerui
  2025-08-21  1:18     ` Tiezhu Yang
  0 siblings, 1 reply; 5+ messages in thread
From: WANG Xuerui @ 2025-08-20 10:57 UTC (permalink / raw)
  To: Tiezhu Yang, Xi Ruoyao, gdb-patches; +Cc: Hui Li, Lulu Cheng, Mingcong Bai

On 8/19/25 16:45, Tiezhu Yang wrote:
> On 2025/8/19 下午3:33, Xi Ruoyao wrote:
>> We can't put a breakpoint in the middle of a ll/sc atomic sequence,
>> recognize the sc.q, screl.w, and screl.d instructions added in LoongArch
>
> sc.q, ll.acq.{w/d}, sc.rel.{w/d}

Lulu Cai said the manual was incorrect (actually the encoding table was 
correct): 
https://inbox.sourceware.org/binutils/f751042e-842d-5c60-6cb5-f3b6eb09aae2@loongson.cn/

"The instructions are llacq.[wd] and screl.[wd] instead of 
ll.acq.[wd] and sc.rel.[wd]. This is a mistake in the main text of the 
LoongArch ISA manual V1.10; the correct names can be found in Appendix B."

> [snip]
>
> The encodings for the instructions that you're handling look correct
> to me. I prefer using ll.acq.w, ll.acq.d, sc.rel.w, sc.rel.d in the
> code comments to make consistent with the manual.
So this is not necessary.
>
> If no more comments, I will amend these when applying in the next week,
> no need to send v2.
>
> Thanks,
> Tiezhu
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions
  2025-08-20 10:57   ` WANG Xuerui
@ 2025-08-21  1:18     ` Tiezhu Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-21  1:18 UTC (permalink / raw)
  To: WANG Xuerui, Xi Ruoyao, gdb-patches; +Cc: Hui Li, Lulu Cheng, Mingcong Bai

On 2025/8/20 下午6:57, WANG Xuerui wrote:
> On 8/19/25 16:45, Tiezhu Yang wrote:
>> On 2025/8/19 下午3:33, Xi Ruoyao wrote:
>>> We can't put a breakpoint in the middle of a ll/sc atomic sequence,
>>> recognize the sc.q, screl.w, and screl.d instructions added in LoongArch
>>
>> sc.q, ll.acq.{w/d}, sc.rel.{w/d}
> 
> Lulu Cai said the manual was incorrect (actually the encoding table was 
> correct)

Yes, this is true, I have confirmed with the designer, this issue will
be fixed in the next release of the manual.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions
  2025-08-19  7:33 [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions Xi Ruoyao
  2025-08-19  8:45 ` Tiezhu Yang
@ 2025-08-25 12:12 ` Tiezhu Yang
  1 sibling, 0 replies; 5+ messages in thread
From: Tiezhu Yang @ 2025-08-25 12:12 UTC (permalink / raw)
  To: Xi Ruoyao, gdb-patches; +Cc: Hui Li, Lulu Cheng, Mingcong Bai, Xuerui Wang

On 8/19/25 15:33, Xi Ruoyao wrote:
> We can't put a breakpoint in the middle of a ll/sc atomic sequence,
> recognize the sc.q, screl.w, and screl.d instructions added in LoongArch
> v1.10 so a ll/sc atomic sequence using them won't loop forever being
> debugged.
> 
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>

As we discussed offline, just modify the patch subject and commit
message to reflect the code, keep the code as is, pushed.

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c9b8f14cbafa

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-25 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-19  7:33 [PATCH] gdb: LoongArch: Recognize LoongArch v1.10 store conditional instructions Xi Ruoyao
2025-08-19  8:45 ` Tiezhu Yang
2025-08-20 10:57   ` WANG Xuerui
2025-08-21  1:18     ` Tiezhu Yang
2025-08-25 12:12 ` Tiezhu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox