Patchwork Don't use print_insn_XXX in GDB

login
register
mail settings
Submitter Yao Qi
Date June 12, 2017, 10:19 a.m.
Message ID <1497262774-19487-1-git-send-email-yao.qi@linaro.org>
Download mbox | patch
Permalink /patch/20943/
State New
Headers show

Comments

Yao Qi - June 12, 2017, 10:19 a.m.
This is a follow-up to

  [PATCH 0/6] Unify the disassembler selection in gdb and objdump
  https://sourceware.org/ml/binutils/2017-05/msg00192.html

that is, opcodes is able to select the right disassembler, so gdb
doesn't have to select them.  Instead, gdb can just use
default_print_insn.  As a result, these print_insn_XXX are not used
out of opcodes, so this patch also moves their declarations from
include/dis-asm.h to opcodes/disassemble.h.  With this change,
GDB doesn't use any print_insn_XXX directly any more.

Regression tested binutils with all targets enabled.  Manually test
GDB disassemble command for arm-linux target.

gdb:

2017-06-12  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_gdb_print_insn): Call
	default_print_insn instead of print_insn_aarch64.
	* arm-tdep.c (gdb_print_insn_arm): Call
	default_print_insn instead of print_insn_big_arm
	and print_insn_little_arm.
	* i386-tdep.c (i386_print_insn): Call default_print_insn
	instead of print_insn_i386.
	* ia64-tdep.c (ia64_print_insn): Call
	default_print_insn instead of print_insn_ia64.
	* mips-tdep.c (gdb_print_insn_mips): Call
	default_print_insn instead of print_insn_big_mips
	and print_insn_little_mips.
	* spu-tdep.c (gdb_print_insn_spu): Call default_print_insn
	instead of print_insn_spu.

include:

2017-06-12  Yao Qi  <yao.qi@linaro.org>

	* dis-asm.h (print_insn_aarch64): Move it to opcodes/disassemble.h.
	(print_insn_big_arm, print_insn_big_mips): Likewise.
	(print_insn_i386, print_insn_ia64): Likewise.
	(print_insn_little_arm, print_insn_little_mips): Likewise.
	(print_insn_spu): Likewise.

opcodes:

2017-06-12  Yao Qi  <yao.qi@linaro.org>

	* aarch64-dis.c: Include disassemble.h instead of dis-asm.h.
	* arm-dis.c: Likewise.
	* ia64-dis.c: Likewise.
	* mips-dis.c: Likewise.
	* spu-dis.c: Likewise.
	* disassemble.h (print_insn_aarch64): New declaration, moved from
	include/dis-asm.h.
	(print_insn_big_arm, print_insn_big_mips): Likewise.
	(print_insn_i386, print_insn_ia64): Likewise.
	(print_insn_little_arm, print_insn_little_mips): Likewise.
---
 gdb/aarch64-tdep.c    | 2 +-
 gdb/arm-tdep.c        | 5 +----
 gdb/i386-tdep.c       | 2 +-
 gdb/ia64-tdep.c       | 2 +-
 gdb/mips-tdep.c       | 6 +-----
 gdb/spu-tdep.c        | 2 +-
 include/dis-asm.h     | 8 --------
 opcodes/aarch64-dis.c | 2 +-
 opcodes/arm-dis.c     | 2 +-
 opcodes/disassemble.h | 8 ++++++++
 opcodes/ia64-dis.c    | 2 +-
 opcodes/mips-dis.c    | 2 +-
 opcodes/spu-dis.c     | 2 +-
 13 files changed, 19 insertions(+), 26 deletions(-)
Nick Clifton - June 13, 2017, 4:03 p.m.
Hi Yao,

> include:
> 
> 2017-06-12  Yao Qi  <yao.qi@linaro.org>
> 
> 	* dis-asm.h (print_insn_aarch64): Move it to opcodes/disassemble.h.
> 	(print_insn_big_arm, print_insn_big_mips): Likewise.
> 	(print_insn_i386, print_insn_ia64): Likewise.
> 	(print_insn_little_arm, print_insn_little_mips): Likewise.
> 	(print_insn_spu): Likewise.
> 
> opcodes:
> 
> 2017-06-12  Yao Qi  <yao.qi@linaro.org>
> 
> 	* aarch64-dis.c: Include disassemble.h instead of dis-asm.h.
> 	* arm-dis.c: Likewise.
> 	* ia64-dis.c: Likewise.
> 	* mips-dis.c: Likewise.
> 	* spu-dis.c: Likewise.
> 	* disassemble.h (print_insn_aarch64): New declaration, moved from
> 	include/dis-asm.h.
> 	(print_insn_big_arm, print_insn_big_mips): Likewise.
> 	(print_insn_i386, print_insn_ia64): Likewise.
> 	(print_insn_little_arm, print_insn_little_mips): Likewise.
 
These parts are approved.

Cheers
  Nick
Yao Qi - June 14, 2017, 3:30 p.m.
On Tue, Jun 13, 2017 at 5:03 PM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Yao,
>
>> include:
>>
>> 2017-06-12  Yao Qi  <yao.qi@linaro.org>
>>
>>       * dis-asm.h (print_insn_aarch64): Move it to opcodes/disassemble.h.
>>       (print_insn_big_arm, print_insn_big_mips): Likewise.
>>       (print_insn_i386, print_insn_ia64): Likewise.
>>       (print_insn_little_arm, print_insn_little_mips): Likewise.
>>       (print_insn_spu): Likewise.
>>
>> opcodes:
>>
>> 2017-06-12  Yao Qi  <yao.qi@linaro.org>
>>
>>       * aarch64-dis.c: Include disassemble.h instead of dis-asm.h.
>>       * arm-dis.c: Likewise.
>>       * ia64-dis.c: Likewise.
>>       * mips-dis.c: Likewise.
>>       * spu-dis.c: Likewise.
>>       * disassemble.h (print_insn_aarch64): New declaration, moved from
>>       include/dis-asm.h.
>>       (print_insn_big_arm, print_insn_big_mips): Likewise.
>>       (print_insn_i386, print_insn_ia64): Likewise.
>>       (print_insn_little_arm, print_insn_little_mips): Likewise.
>
> These parts are approved.
>

Thanks, Nick.  I pushed it in.

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index a5db6ed..75bb00f 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1777,7 +1777,7 @@  static int
 aarch64_gdb_print_insn (bfd_vma memaddr, disassemble_info *info)
 {
   info->symbols = NULL;
-  return print_insn_aarch64 (memaddr, info);
+  return default_print_insn (memaddr, info);
 }
 
 /* AArch64 BRK software debug mode instruction.
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 691fae7..9943324 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -7773,10 +7773,7 @@  gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info)
   else
     info->symbols = NULL;
 
-  if (info->endian == BFD_ENDIAN_BIG)
-    return print_insn_big_arm (memaddr, info);
-  else
-    return print_insn_little_arm (memaddr, info);
+  return default_print_insn (memaddr, info);
 }
 
 /* The following define instruction sequences that will cause ARM
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index fe68486..bd728f0 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -4011,7 +4011,7 @@  i386_print_insn (bfd_vma pc, struct disassemble_info *info)
 
   info->disassembler_options = disassembly_flavor;
 
-  return print_insn_i386 (pc, info);
+  return default_print_insn (pc, info);
 }
 
 
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index d396fb8..5a16db1 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -3926,7 +3926,7 @@  static int
 ia64_print_insn (bfd_vma memaddr, struct disassemble_info *info)
 {
   info->bytes_per_line = SLOT_MULTIPLIER;
-  return print_insn_ia64 (memaddr, info);
+  return default_print_insn (memaddr, info);
 }
 
 /* The default "size_of_register_frame" gdbarch_tdep routine for ia64.  */
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 82f91ba..c7b0404 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -7013,11 +7013,7 @@  gdb_print_insn_mips (bfd_vma memaddr, struct disassemble_info *info)
        register naming conventions specified by the user.  */
     info->disassembler_options = "gpr-names=32";
 
-  /* Call the appropriate disassembler based on the target endian-ness.  */
-  if (info->endian == BFD_ENDIAN_BIG)
-    return print_insn_big_mips (memaddr, info);
-  else
-    return print_insn_little_mips (memaddr, info);
+  return default_print_insn (memaddr, info);
 }
 
 static int
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 08ab194..1ab9a9c 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1721,7 +1721,7 @@  gdb_print_insn_spu (bfd_vma memaddr, struct disassemble_info *info)
   memcpy (&spu_info, info, sizeof (*info));
   spu_info.id = SPUADDR_SPU (memaddr);
   spu_info.print_address_func = spu_dis_asm_print_address;
-  return print_insn_spu (memaddr, &spu_info);
+  return default_print_insn (memaddr, &spu_info);
 }
 
 
diff --git a/include/dis-asm.h b/include/dis-asm.h
index 911bfb0..9b42514 100644
--- a/include/dis-asm.h
+++ b/include/dis-asm.h
@@ -238,19 +238,11 @@  typedef struct
 typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *);
 
 /* Disassemblers used out side of opcodes library.  */
-extern int print_insn_aarch64		(bfd_vma, disassemble_info *);
-extern int print_insn_big_arm		(bfd_vma, disassemble_info *);
-extern int print_insn_big_mips		(bfd_vma, disassemble_info *);
-extern int print_insn_i386		(bfd_vma, disassemble_info *);
-extern int print_insn_ia64		(bfd_vma, disassemble_info *);
-extern int print_insn_little_arm	(bfd_vma, disassemble_info *);
-extern int print_insn_little_mips	(bfd_vma, disassemble_info *);
 extern int print_insn_m32c		(bfd_vma, disassemble_info *);
 extern int print_insn_mep		(bfd_vma, disassemble_info *);
 extern int print_insn_sh		(bfd_vma, disassemble_info *);
 extern int print_insn_sh64x_media	(bfd_vma, disassemble_info *);
 extern int print_insn_sparc		(bfd_vma, disassemble_info *);
-extern int print_insn_spu		(bfd_vma, disassemble_info *);
 extern int print_insn_rx		(bfd_vma, disassemble_info *);
 extern int print_insn_rl78		(bfd_vma, disassemble_info *);
 extern int print_insn_rl78_g10		(bfd_vma, disassemble_info *);
diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c
index e5fe61f..27ef22b 100644
--- a/opcodes/aarch64-dis.c
+++ b/opcodes/aarch64-dis.c
@@ -20,7 +20,7 @@ 
 
 #include "sysdep.h"
 #include "bfd_stdint.h"
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "libiberty.h"
 #include "opintl.h"
 #include "aarch64-dis.h"
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index a0a03ee..c35a053 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -22,7 +22,7 @@ 
 
 #include "sysdep.h"
 
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "opcode/arm.h"
 #include "opintl.h"
 #include "safe-ctype.h"
diff --git a/opcodes/disassemble.h b/opcodes/disassemble.h
index dec09fe..bccd6af 100644
--- a/opcodes/disassemble.h
+++ b/opcodes/disassemble.h
@@ -21,9 +21,12 @@ 
 #define DISASSEMBLE_H
 #include "dis-asm.h"
 
+extern int print_insn_aarch64		(bfd_vma, disassemble_info *);
 extern int print_insn_alpha		(bfd_vma, disassemble_info *);
 extern int print_insn_avr		(bfd_vma, disassemble_info *);
 extern int print_insn_bfin		(bfd_vma, disassemble_info *);
+extern int print_insn_big_arm		(bfd_vma, disassemble_info *);
+extern int print_insn_big_mips		(bfd_vma, disassemble_info *);
 extern int print_insn_big_nios2	(bfd_vma, disassemble_info *);
 extern int print_insn_big_powerpc	(bfd_vma, disassemble_info *);
 extern int print_insn_big_score         (bfd_vma, disassemble_info *);
@@ -42,14 +45,18 @@  extern int print_insn_h8300s		(bfd_vma, disassemble_info *);
 extern int print_insn_h8500		(bfd_vma, disassemble_info *);
 extern int print_insn_hppa		(bfd_vma, disassemble_info *);
 extern int print_insn_i370		(bfd_vma, disassemble_info *);
+extern int print_insn_i386		(bfd_vma, disassemble_info *);
 extern int print_insn_i386_att		(bfd_vma, disassemble_info *);
 extern int print_insn_i386_intel	(bfd_vma, disassemble_info *);
 extern int print_insn_i860		(bfd_vma, disassemble_info *);
 extern int print_insn_i960		(bfd_vma, disassemble_info *);
+extern int print_insn_ia64		(bfd_vma, disassemble_info *);
 extern int print_insn_ip2k		(bfd_vma, disassemble_info *);
 extern int print_insn_iq2000		(bfd_vma, disassemble_info *);
 extern int print_insn_little_nios2	(bfd_vma, disassemble_info *);
 extern int print_insn_riscv		(bfd_vma, disassemble_info *);
+extern int print_insn_little_arm	(bfd_vma, disassemble_info *);
+extern int print_insn_little_mips	(bfd_vma, disassemble_info *);
 extern int print_insn_little_powerpc	(bfd_vma, disassemble_info *);
 extern int print_insn_little_score      (bfd_vma, disassemble_info *);
 extern int print_insn_lm32		(bfd_vma, disassemble_info *);
@@ -78,6 +85,7 @@  extern int print_insn_pru		(bfd_vma, disassemble_info *);
 extern int print_insn_rs6000		(bfd_vma, disassemble_info *);
 extern int print_insn_s390		(bfd_vma, disassemble_info *);
 extern int print_insn_sh64		(bfd_vma, disassemble_info *);
+extern int print_insn_spu		(bfd_vma, disassemble_info *);
 extern int print_insn_tic30		(bfd_vma, disassemble_info *);
 extern int print_insn_tic4x		(bfd_vma, disassemble_info *);
 extern int print_insn_tic54x		(bfd_vma, disassemble_info *);
diff --git a/opcodes/ia64-dis.c b/opcodes/ia64-dis.c
index 3f2253a..2cf6e60 100644
--- a/opcodes/ia64-dis.c
+++ b/opcodes/ia64-dis.c
@@ -22,7 +22,7 @@ 
 #include "sysdep.h"
 #include <assert.h>
 
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "opcode/ia64.h"
 
 #define NELEMS(a)	((int) (sizeof (a) / sizeof (a[0])))
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index 8caae81..b541e03 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -20,7 +20,7 @@ 
    MA 02110-1301, USA.  */
 
 #include "sysdep.h"
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "libiberty.h"
 #include "opcode/mips.h"
 #include "opintl.h"
diff --git a/opcodes/spu-dis.c b/opcodes/spu-dis.c
index 3009463..b57faf5 100644
--- a/opcodes/spu-dis.c
+++ b/opcodes/spu-dis.c
@@ -21,7 +21,7 @@ 
 
 #include "sysdep.h"
 #include <stdio.h>
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "opcode/spu.h"
 
 /* This file provides a disassembler function which uses