Re: [PATCH 03/16] MIPS64: Add gdb patch for Loongson machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/10/2021 09:14 AM, HAGIO KAZUHITO(萩尾 一仁) wrote:
-----Original Message-----
The gssq instruction is a Loongson extended instruction, so the gssq patch
is applied to gdb.

Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxxx>
---
  Makefile               |  3 +++
  configure.c            |  2 +-
  gdb-7.6-loongson.patch | 19 +++++++++++++++++++
  3 files changed, 23 insertions(+), 1 deletion(-)
  create mode 100644 gdb-7.6-loongson.patch

diff --git a/Makefile b/Makefile
index eb1e018..c629d17 100644
--- a/Makefile
+++ b/Makefile
@@ -277,6 +277,9 @@ gdb_patch:
  			patch -p0 < ${GDB}-proc_service.h.patch; \
  		fi; \
  	fi
+	if [ "${ARCH}" = "mips64" ] && [ -f ${GDB}-loongson.patch ]; then \
+		patch -d ${GDB} -p1 -F0 < ${GDB}-loongson.patch ; \
+	fi
Does this patch break the other architectures?
If it doesn't, I would like to avoid adding a new architecture-specific
patch.  It will make the maintenance of gdb patches very complicated.

Is it possible to add that patch to the end of gdb-7.6.patch?
(Note that gdb-7.6-ppc64le.patch also has to be applied cleanly.)
The gdb patch will not affect other architectures.
The revised patch is as follows, I will send v2 if possible.

--- a/gdb-7.6.patch
+++ b/gdb-7.6.patch
@@ -2500,4 +2500,23 @@ diff -up gdb-7.6/opcodes/configure.orig gdb-7.6/opcodes/configure
 +struct target_desc *tdesc_aarch64;
  #include "features/aarch64.c"
  #include "features/aarch64-without-fpu.c"
-
+
+--- gdb-7.6/gdb/mips-tdep.c.orig
++++ gdb-7.6/gdb/mips-tdep.c
+@@ -3261,6 +3261,16 @@ restart:
+ /* Irix 6.2 N32 ABI uses sd instructions for saving $gp and $ra. */
+         set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
+       }
++ else if (((inst & 0xFFE08020) == 0xeba00020) /* gssq reg,reg,offset($sp) */
++               && regsize_is_64_bits)
++      {
++        reg = (inst >> 16) & 0x1F;
++        low_word = ((((inst >> 6) & 0x1FF) ^ 0x100) - 0x100) << 4;
++        set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
++        reg = inst & 0x1F;
++        low_word = (((((inst >> 6) & 0x1FF) ^ 0x100) - 0x100) << 4) + 8;
++        set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
++      }
+       else if (high_word == 0x27be)   /* addiu $30,$sp,size */
+       {
+         /* Old gcc frame, r30 is virtual frame pointer.  */


Thanks,
Youling
Thanks,
Kazu

  library: make_build_data ${OBJECT_FILES}
  	ar -rs ${PROGRAM}lib.a ${OBJECT_FILES}
diff --git a/configure.c b/configure.c
index e2df6f0..40351c3 100644
--- a/configure.c
+++ b/configure.c
@@ -245,7 +245,7 @@ struct supported_gdb_version {
  	    "7.6",
  	    "GDB_FILES=${GDB_7.6_FILES}",
  	    "GDB_OFILES=${GDB_7.6_OFILES}",
-	    "GDB_PATCH_FILES=gdb-7.6.patch gdb-7.6-ppc64le-support.patch gdb-7.6-proc_service.h.patch",
+	    "GDB_PATCH_FILES=gdb-7.6.patch gdb-7.6-ppc64le-support.patch gdb-7.6-proc_service.h.patch
gdb-7.6-loongson.patch",
  	    "GDB_FLAGS=-DGDB_7_6",
  	    "GPLv3"
  	},
diff --git a/gdb-7.6-loongson.patch b/gdb-7.6-loongson.patch
new file mode 100644
index 0000000..556163f
--- /dev/null
+++ b/gdb-7.6-loongson.patch
@@ -0,0 +1,19 @@
+--- gdb-7.6/gdb/mips-tdep.c.orig	2018-08-28 11:20:32.653771170 +0800
++++ gdb-7.6/gdb/mips-tdep.c	2018-08-28 11:25:53.129043377 +0800
+@@ -3261,6 +3261,16 @@ restart:
+ 	  /* Irix 6.2 N32 ABI uses sd instructions for saving $gp and $ra.  */
+ 	  set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
+ 	}
++      else if (((inst & 0xFFE08020) == 0xeba00020)	/* gssq reg,reg,offset($sp) */
++               && regsize_is_64_bits)
++	{
++	  reg = (inst >> 16) & 0x1F;
++	  low_word = ((((inst >> 6) & 0x1FF) ^ 0x100) - 0x100) << 4;
++	  set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
++	  reg = inst & 0x1F;
++	  low_word = (((((inst >> 6) & 0x1FF) ^ 0x100) - 0x100) << 4) + 8;
++	  set_reg_offset (gdbarch, this_cache, reg, sp + low_word);
++	}
+       else if (high_word == 0x27be)	/* addiu $30,$sp,size */
+ 	{
+ 	  /* Old gcc frame, r30 is virtual frame pointer.  */
--
2.1.0

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux