Don't use print_insn_XXX in GDB
authorYao Qi <yao.qi@linaro.org>
Wed, 14 Jun 2017 15:28:30 +0000 (16:28 +0100)
committerYao Qi <yao.qi@linaro.org>
Wed, 14 Jun 2017 15:29:01 +0000 (16:29 +0100)
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.

gdb:

2017-06-14  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-14  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-14  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.

16 files changed:
gdb/ChangeLog
gdb/aarch64-tdep.c
gdb/arm-tdep.c
gdb/i386-tdep.c
gdb/ia64-tdep.c
gdb/mips-tdep.c
gdb/spu-tdep.c
include/ChangeLog
include/dis-asm.h
opcodes/ChangeLog
opcodes/aarch64-dis.c
opcodes/arm-dis.c
opcodes/disassemble.h
opcodes/ia64-dis.c
opcodes/mips-dis.c
opcodes/spu-dis.c

index 07862c8a91bf3d1091e5f258fe7b3148418e4190..67063f9e5563a16998ccd6e2104c3e12a96839b5 100644 (file)
@@ -1,3 +1,20 @@
+2017-06-14  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.
+
 2017-06-14  Pedro Alves  <palves@redhat.com>
 
        * ada-lang.c: Include "common/byte-vector.h".
index a5db6ed29d90e3166f885cd1367214fab669818f..75bb00f0b6ad9a6d7857d48c80efce9d3ca2163d 100644 (file)
@@ -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.
index 691fae7da66ea8f73b01b3c21c80be2bf5423497..99433243b4836e46c7f255b0bc9cff1fbbef0185 100644 (file)
@@ -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
index fe68486990bed50f669acd53e4dfaf537aa46c97..bd728f03dc3a378c30446cae4af36d381552497a 100644 (file)
@@ -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);
 }
 \f
 
index d396fb81a62b0c2522900fd9cb0980aa2a5fb767..5a16db1563c2a125bf20bab0cb91f7018dc2bb33 100644 (file)
@@ -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.  */
index dcd9ef21715fafb5ed07505b16ffb13acd876d4b..3ff2dab491e7760571e45ce1fcf0a5f320624f7e 100644 (file)
@@ -7019,11 +7019,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
index 08ab19418f64462dbfaca8ca2ae4683683d70273..1ab9a9cf6526919fa0a4cb708a622269da0035ce 100644 (file)
@@ -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);
 }
 
 
index 3818610b5ce59e8719b14a9e58e9a08bc2fe1274..1c7766f90a50f0161f1d8b9d858489a5fdd57d50 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-14  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.
+
 2017-06-06  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * bfdlink.h (struct bfd_link_info): Add new resolve_section_groups
index 911bfb043fd3deb0d940efa9f850b7fe5d202e3f..9b4251405e3b01269f7fbef80d0835993c7b1210 100644 (file)
@@ -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 *);
index 4c6b6a7b90936a6ad23f79495fb8aca5c9d59623..fa9bb75ab8868ddcbf43d4cd47fc87951fbf6835 100644 (file)
@@ -1,3 +1,16 @@
+2017-06-14  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.
+
 2017-06-14  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/21587
index e5fe61f51d13e06342947437ec80731f692e2628..27ef22bc09f1ca29aa69f43be3c02a692ae391c3 100644 (file)
@@ -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"
index fbb7c10a4e2b623c86aa1548be1b1ec1135245d6..a30afb9a7ee482cb9204cdac6faf5dc9e59a09c1 100644 (file)
@@ -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"
index dec09fe1409565ca33cf4fb1408dc3953ca6de16..bccd6af553ec39f7d5859c3e3d2af7bd395bed21 100644 (file)
 #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 *);
index 3f2253a90369a086f94ac3e93fa23c7da348beb7..2cf6e603082d1bb195d35d574decbc5bd4a44935 100644 (file)
@@ -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])))
index 8caae81edf56d5d347fa843fe0d27e78de183198..b541e03b8522dcabbe8c3102fb68a1f23ea87f73 100644 (file)
@@ -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"
index 3009463e350c6f441f79bf940536583d9b72b3f8..b57faf58eaa0cbe2059b6c2519674646371a2a6d 100644 (file)
@@ -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