public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: mips: Fix large-frame.exp test case failure
@ 2022-03-15  1:21 Youling Tang
  2022-03-16 16:40 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Youling Tang @ 2022-03-15  1:21 UTC (permalink / raw)
  To: gdb-patches, Maciej W. Rozycki

$ objdump -d outputs/gdb.base/large-frame/large-frame-O2
0000000120000b20 <func>:
   120000b20:   67bdbff0        daddiu  sp,sp,-16400
   120000b24:   ffbc4000        sd      gp,16384(sp)
   120000b28:   3c1c0002        lui     gp,0x2
   120000b2c:   679c8210        daddiu  gp,gp,-32240
   120000b30:   0399e02d        daddu   gp,gp,t9
   120000b34:   df998058        ld      t9,-32680(gp)
   120000b38:   ffbf4008        sd      ra,16392(sp)
   120000b3c:   0411ffd8        bal     120000aa0 <blah>
...

The disassembly of the above func function shows that we may use instructions
such as daddiu/daddu, so add "daddiu $gp,$gp,n", "daddu $gp,$gp,$t9" and
"daddu $gp,$t9,$gp" to the mips32_scan_prologue function to fix the large-frame.exp
test case.

Before applying the patch:
 backtrace^M
 #0  blah (a=0xfffffee220) at /home/tang/gdb-work/upstream/binutils-gdb/gdb/testsuite/gdb.base/large-frame-1.c:24^M
 #1  0x0000000120000b44 in func ()^M
 Backtrace stopped: frame did not save the PC^M
 (gdb) FAIL: gdb.base/large-frame.exp: optimize=-O2: backtrace

 # of expected passes            5
 # of unexpected failures        1

After applying the patch:
 # of expected passes            6

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
---
 gdb/mips-tdep.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 5cd72ae..7e37578 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -3588,8 +3588,11 @@ mips32_scan_prologue (struct gdbarch *gdbarch,
 	       || (inst & 0xFF9F07FF) == 0x00800021 /* move reg,$a0-$a3 */
 	       || high_word == 0x3c1c /* lui $gp,n */
 	       || high_word == 0x279c /* addiu $gp,$gp,n */
+	       || high_word == 0x679c /* daddiu $gp,$gp,n */
 	       || inst == 0x0399e021 /* addu $gp,$gp,$t9 */
 	       || inst == 0x033ce021 /* addu $gp,$t9,$gp */
+	       || inst == 0x0399e02d /* daddu $gp,$gp,$t9 */
+	       || inst == 0x033ce02d /* daddu $gp,$t9,$gp */
 	      )
 	{
 	  /* These instructions are part of the prologue, but we don't
-- 
2.1.0


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

* Re: [PATCH] gdb: mips: Fix large-frame.exp test case failure
  2022-03-15  1:21 [PATCH] gdb: mips: Fix large-frame.exp test case failure Youling Tang
@ 2022-03-16 16:40 ` Tom Tromey
  2022-03-16 18:36   ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2022-03-16 16:40 UTC (permalink / raw)
  To: Youling Tang; +Cc: gdb-patches, Maciej W. Rozycki

Hi.  Thank you for the patch.

>> The disassembly of the above func function shows that we may use instructions
>> such as daddiu/daddu, so add "daddiu $gp,$gp,n", "daddu $gp,$gp,$t9" and
>> "daddu $gp,$t9,$gp" to the mips32_scan_prologue function to fix the large-frame.exp
>> test case.

Since I don't know the MIPS architecture, my main question for this kind
of patch is whether this applies to the whole MIPS family, or whether it
somehow depends on some micro-architecture.

If it applies universally, or if it can't hurt other forms of MIPS, then
the patch itself looks good to me and you can go ahead.

thanks,
Tom

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

* Re: [PATCH] gdb: mips: Fix large-frame.exp test case failure
  2022-03-16 16:40 ` Tom Tromey
@ 2022-03-16 18:36   ` Maciej W. Rozycki
  2022-03-16 20:30     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2022-03-16 18:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Youling Tang, gdb-patches

On Wed, 16 Mar 2022, Tom Tromey wrote:

> >> The disassembly of the above func function shows that we may use instructions
> >> such as daddiu/daddu, so add "daddiu $gp,$gp,n", "daddu $gp,$gp,$t9" and
> >> "daddu $gp,$t9,$gp" to the mips32_scan_prologue function to fix the large-frame.exp
> >> test case.
> 
> Since I don't know the MIPS architecture, my main question for this kind
> of patch is whether this applies to the whole MIPS family, or whether it
> somehow depends on some micro-architecture.

 It is a standard code sequence for loading the GP with the n64 ABI (I 
don't know why DADDIU rather than ADDIU has been chosen for the low part 
of the 32-bit offset given that they produce the same result, but there 
you go), produced either explicitly by GCC or by GAS with the `.cpsetup' 
assembly pseudo-op (in which case ADDIU is actually used).

  Maciej

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

* Re: [PATCH] gdb: mips: Fix large-frame.exp test case failure
  2022-03-16 18:36   ` Maciej W. Rozycki
@ 2022-03-16 20:30     ` Tom Tromey
  2022-05-10 21:13       ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2022-03-16 20:30 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Tom Tromey, Youling Tang, gdb-patches

Maciej>  It is a standard code sequence for loading the GP with the n64 ABI (I 
Maciej> don't know why DADDIU rather than ADDIU has been chosen for the low part 
Maciej> of the 32-bit offset given that they produce the same result, but there 
Maciej> you go), produced either explicitly by GCC or by GAS with the `.cpsetup' 
Maciej> assembly pseudo-op (in which case ADDIU is actually used).

Thanks!  If you're still looking at MIPS patches I will just let them
slide by :-)

Tom

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

* Re: [PATCH] gdb: mips: Fix large-frame.exp test case failure
  2022-03-16 20:30     ` Tom Tromey
@ 2022-05-10 21:13       ` Maciej W. Rozycki
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej W. Rozycki @ 2022-05-10 21:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Youling Tang, gdb-patches

On Wed, 16 Mar 2022, Tom Tromey wrote:

> Maciej>  It is a standard code sequence for loading the GP with the n64 ABI (I 
> Maciej> don't know why DADDIU rather than ADDIU has been chosen for the low part 
> Maciej> of the 32-bit offset given that they produce the same result, but there 
> Maciej> you go), produced either explicitly by GCC or by GAS with the `.cpsetup' 
> Maciej> assembly pseudo-op (in which case ADDIU is actually used).
> 
> Thanks!  If you're still looking at MIPS patches I will just let them
> slide by :-)

 I thought this change had been pushed, and then I've noticed it has not.  
I have therefore verified the microMIPS prologue scanner already has the 
corresponding bits, reformatted the change description so as to make it 
fit in 74 columns, added a couple of line breaks, removed `^M' artifacts, 
and finally pushed the commit.

 Thank you, Youling, for your contribution!

  Maciej

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

end of thread, other threads:[~2022-05-10 21:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15  1:21 [PATCH] gdb: mips: Fix large-frame.exp test case failure Youling Tang
2022-03-16 16:40 ` Tom Tromey
2022-03-16 18:36   ` Maciej W. Rozycki
2022-03-16 20:30     ` Tom Tromey
2022-05-10 21:13       ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).