[2/6] Delegate opcodes to select disassembler in GDB

Message ID 1494931698-15309-3-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi May 16, 2017, 10:48 a.m. UTC
  This patch changes GDB to use disassembler selected by opcodes in
default, so that we don't have to duplicate the selection logic again
in GDB side.  For example, gdb/score-tdep.c has

static int
score_print_insn (bfd_vma memaddr, struct disassemble_info *info)
{
  if (info->endian == BFD_ENDIAN_BIG)
    return print_insn_big_score (memaddr, info);
  else
    return print_insn_little_score (memaddr, info);
}

and opcodes/disassemble.c has the same logic,

    case bfd_arch_score:
      if (big)
	disassemble = print_insn_big_score;
      else
	disassemble = print_insn_little_score;

This patch removes the logic in GDB and calls
opcodes/disassemble.c:disassembler in default to select disassembler.

gdb:

2017-05-15  Yao Qi  <yao.qi@linaro.org>

	* alpha-tdep.c (alpha_gdbarch_init): Don't call
	set_gdbarch_print_insn.
	* arc-tdep.c (arc_gdbarch_init): Likewise.
	* arch-utils.c: include dis-asm.h.
	(default_print_insn): New function.
	* arch-utils.h (default_print_insn): Declare.
	* avr-tdep.c (avr_gdbarch_init): Don't call set_gdbarch_print_insn.
	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
	* cris-tdep.c (cris_delayed_get_disassembler): Remove.
	(cris_gdbarch_init): Don't call set_gdbarch_print_insn.
	* frv-tdep.c (frv_gdbarch_init): Likewise.
	* ft32-tdep.c (ft32_gdbarch_init): Likewise.
	* gdbarch.sh (print_insn): Use default_print_insn.
	* gdbarch.c: Regenerated.
	* hppa-tdep.c (hppa_gdbarch_init): Likewise.
	* iq2000-tdep.c (iq2000_gdbarch_init): Likewise.
	* lm32-tdep.c (lm32_gdbarch_init): Likewise.
	* m32c-tdep.c (m32c_gdbarch_init): Likewise.
	* m32r-tdep.c (m32r_gdbarch_init): Likewise.
	* m68hc11-tdep.c (gdb_print_insn_m68hc11): Remove.
	(m68hc11_gdbarch_init): Don't call set_gdbarch_print_insn.
	* m68k-tdep.c (m68k_gdbarch_init): Likewise.
	* m88k-tdep.c (m88k_gdbarch_init): Likewise.
	* microblaze-tdep.c (microblaze_gdbarch_init): Likewise.
	* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
	* moxie-tdep.c (moxie_gdbarch_init): Likewise.
	* msp430-tdep.c (msp430_gdbarch_init): Likewise.
	* mt-tdep.c (mt_gdbarch_init): Likewise.
	* nds32-tdep.c (nds32_gdbarch_init): Likewise.
	* nios2-tdep.c (nios2_print_insn): Remove.
	(nios2_gdbarch_init): Don't call set_gdbarch_print_insn.
	* rx-tdep.c (rx_gdbarch_init): Likewise.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* score-tdep.c (score_print_insn): Remove.
	(score_gdbarch_init): Don't call set_gdbarch_print_insn.
	* sh-tdep.c (sh_gdbarch_init): Likewise.
	* sh64-tdep.c (sh64_gdbarch_init): Likewise.
	* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
	* tic6x-tdep.c (tic6x_print_insn): Remove.
	(tic6x_gdbarch_init): Don't call set_gdbarch_print_insn.
	* tilegx-tdep.c (tilegx_gdbarch_init): Likewise.
	* v850-tdep.c (v850_gdbarch_init): Likewise.
	* vax-tdep.c (vax_gdbarch_init): Likewise.
	* xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise.
	* xtensa-tdep.c (xtensa_gdbarch_init): Likewise.
---
 gdb/alpha-tdep.c      |  3 ---
 gdb/arc-tdep.c        |  2 --
 gdb/arch-utils.c      | 20 ++++++++++++++++++++
 gdb/arch-utils.h      |  2 ++
 gdb/avr-tdep.c        |  1 -
 gdb/bfin-tdep.c       |  1 -
 gdb/cris-tdep.c       | 18 ------------------
 gdb/frv-tdep.c        |  1 -
 gdb/ft32-tdep.c       |  2 --
 gdb/gdbarch.c         |  4 ++--
 gdb/gdbarch.sh        |  2 +-
 gdb/hppa-tdep.c       |  2 --
 gdb/iq2000-tdep.c     |  1 -
 gdb/lm32-tdep.c       |  3 ---
 gdb/m32c-tdep.c       |  3 ---
 gdb/m32r-tdep.c       |  2 --
 gdb/m68hc11-tdep.c    | 11 -----------
 gdb/m68k-tdep.c       |  4 ----
 gdb/m88k-tdep.c       |  2 --
 gdb/microblaze-tdep.c |  2 --
 gdb/mn10300-tdep.c    |  2 --
 gdb/moxie-tdep.c      |  2 --
 gdb/msp430-tdep.c     |  3 ---
 gdb/mt-tdep.c         |  1 -
 gdb/nds32-tdep.c      |  2 --
 gdb/nios2-tdep.c      | 14 --------------
 gdb/rx-tdep.c         |  2 --
 gdb/s390-linux-tdep.c |  2 --
 gdb/score-tdep.c      | 10 ----------
 gdb/sh-tdep.c         |  1 -
 gdb/sh64-tdep.c       |  2 --
 gdb/sparc-tdep.c      |  2 --
 gdb/tic6x-tdep.c      | 10 ----------
 gdb/tilegx-tdep.c     |  2 --
 gdb/v850-tdep.c       |  2 --
 gdb/vax-tdep.c        |  2 --
 gdb/xstormy16-tdep.c  |  2 --
 gdb/xtensa-tdep.c     |  2 --
 38 files changed, 25 insertions(+), 124 deletions(-)
  

Comments

Maciej W. Rozycki June 30, 2017, 12:18 a.m. UTC | #1
Hi Yao,

On Tue, 16 May 2017, Yao Qi wrote:

> This patch removes the logic in GDB and calls
> opcodes/disassemble.c:disassembler in default to select disassembler.

 This change causes an assertion failure when trying to disassemble a 
MIPS16 function:

(gdb) disassemble main
Dump of assembler code for function main:
   0x00400209 <+0>:
.../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

This is because `info->mach' is 16 (the `bfd_mach_mips16' aka `mips:16' 
BFD) whereas `bfd_get_mach (exec_bfd)' is 33 (the `bfd_mach_mipsisa32r2' 
aka `mips:isa32r2' BFD).  This is expected for MIPS16 code within a 
program that has been built for the MIPS32r2 ISA; see 
`gdb_print_insn_mips' for the origin.

 So what's the purpose of this assertion?

  Maciej
  
Yao Qi June 30, 2017, 7:38 a.m. UTC | #2
"Maciej W. Rozycki" <macro@imgtec.com> writes:

>  This change causes an assertion failure when trying to disassemble a 
> MIPS16 function:
>
> (gdb) disassemble main
> Dump of assembler code for function main:
>    0x00400209 <+0>:
> .../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)

Sorry about that.  I did deliberately run
testsuite/gdb.base/all-architectures-[0-7].exp tests to cover the case
that using disassembler for each architecture.  It covers mips, but it
doesn't cover mips16 and micromips.

>
> This is because `info->mach' is 16 (the `bfd_mach_mips16' aka `mips:16' 
> BFD) whereas `bfd_get_mach (exec_bfd)' is 33 (the `bfd_mach_mipsisa32r2' 
> aka `mips:isa32r2' BFD).  This is expected for MIPS16 code within a 
> program that has been built for the MIPS32r2 ISA; see 
> `gdb_print_insn_mips' for the origin.
>
>  So what's the purpose of this assertion?

The assertion is based on assumption that "info->mach" is got from
bfd_get_mach (exec_bfd), but it is not right for mips16.  We can remove
this line.  If you agree, I'll post a patch to remove this line.
  
Maciej W. Rozycki July 5, 2017, 11:53 p.m. UTC | #3
Hi Yao,

On Fri, 30 Jun 2017, Yao Qi wrote:

> >  This change causes an assertion failure when trying to disassemble a 
> > MIPS16 function:
> >
> > (gdb) disassemble main
> > Dump of assembler code for function main:
> >    0x00400209 <+0>:
> > .../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed.
> > A problem internal to GDB has been detected,
> > further debugging may prove unreliable.
> > Quit this debugging session? (y or n)
> 
> Sorry about that.  I did deliberately run
> testsuite/gdb.base/all-architectures-[0-7].exp tests to cover the case
> that using disassembler for each architecture.  It covers mips, but it
> doesn't cover mips16 and micromips.

 These are smoke tests really AFAICT, and for this to trigger they would 
have to cover the usual case where the gdbarch's BFD is different from one 
chosen for the disassembly, and for that `set architecture <foo>' is (or 
at least may not be) enough.  You'd really have to run full MIPS 
regression testing with a MIPS16 or microMIPS multilib, and I realise you 
may not have the necessary infrastructure available at hand.

> > This is because `info->mach' is 16 (the `bfd_mach_mips16' aka `mips:16' 
> > BFD) whereas `bfd_get_mach (exec_bfd)' is 33 (the `bfd_mach_mipsisa32r2' 
> > aka `mips:isa32r2' BFD).  This is expected for MIPS16 code within a 
> > program that has been built for the MIPS32r2 ISA; see 
> > `gdb_print_insn_mips' for the origin.
> >
> >  So what's the purpose of this assertion?
> 
> The assertion is based on assumption that "info->mach" is got from
> bfd_get_mach (exec_bfd), but it is not right for mips16.  We can remove
> this line.  If you agree, I'll post a patch to remove this line.

 I can see the assumption from the assertion itself, but what is its 
purpose?

 Normally you place an assertion in code to guard against a case that is 
not handled (correctly) and if let through it would lead execution to go 
astray, e.g. because it is a new complicated feature we have not yet got 
to implementing or because it is a case we think that will never happen, 
and code that follows has assumptions that will not be met.

 So if you say that you can remove the assertion with no adverse effect on 
processing, then I think it should not have been placed there in the first 
place.

 Anyway, if you look at code in `gdb_print_insn_mips', then you'll find 
this comment:

  /* FIXME: cagney/2003-06-26: Is this even necessary?  The
     disassembler needs to be able to locally determine the ISA, and
     not rely on GDB.  Otherwize the stand-alone 'objdump -d' will not
     work.  */

and it is indeed the case that `objdump' handles this correctly without 
the need to switch away from the BFD selected for the binary being 
handled.  However in GDB we have this problem that we do not pass the 
symbol table down to libopcodes for the disassembler, and in the case of 
the MIPS target it is the symbol table that carries information about 
which functions contain regular MIPS code, MIPS16 code and microMIPS code 
respectively.

 Lacking symbol information we resort to this hack of overriding the BFD 
for the purpose of disassembly only, and this has the adverse effect of 
getting instruction subsetting wrong: the `bfd_mach_mips16' and 
`bfd_mach_mips_micromips' BFDs always choose the maximum instruction set 
supported possible whereas the binary handled may only support a subset 
(or worse yet an alternative set), as indicated by the original BFD 
selected.  This in turn may confuse and mislead the person running a debug 
session into thinking code disassembled is not the problem they are after.

 Do you think it would be possible as a part of your disassembler rework 
to make the symbol table available to libopcodes?  Then the hack currently 
present in `gdb_print_insn_mips' could go.  I remember looking into it a 
while ago and concluding it would be somewhat tricky because the symbol 
table format expected by libopcodes is not the same that we use in GDB.

  Maciej
  

Patch

diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index d62566c..b1bc6a1 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -1798,9 +1798,6 @@  alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Prologue heuristics.  */
   set_gdbarch_skip_prologue (gdbarch, alpha_skip_prologue);
 
-  /* Disassembler.  */
-  set_gdbarch_print_insn (gdbarch, print_insn_alpha);
-
   /* Call info.  */
 
   set_gdbarch_return_value (gdbarch, alpha_return_value);
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 4f866a9..d9ee5c6 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -2013,8 +2013,6 @@  arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_frame_align (gdbarch, arc_frame_align);
 
-  set_gdbarch_print_insn (gdbarch, arc_delayed_print_insn);
-
   set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
 
   /* "nonsteppable" watchpoint means that watchpoint triggers before
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index b1cec80..c011b0f 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -37,6 +37,7 @@ 
 
 #include "floatformat.h"
 
+#include "dis-asm.h"
 
 struct displaced_step_closure *
 simple_displaced_step_copy_insn (struct gdbarch *gdbarch,
@@ -973,6 +974,25 @@  default_guess_tracepoint_registers (struct gdbarch *gdbarch,
   regcache_raw_supply (regcache, pc_regno, regs);
 }
 
+int
+default_print_insn (bfd_vma memaddr, disassemble_info *info)
+{
+  disassembler_ftype disassemble_fn;
+
+  if (exec_bfd != NULL)
+    {
+      gdb_assert (info->arch == bfd_get_arch (exec_bfd));
+      gdb_assert (info->endian == (bfd_big_endian (exec_bfd)
+				   ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE));
+      gdb_assert (info->mach == bfd_get_mach (exec_bfd));
+    }
+  disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG,
+				 info->mach, exec_bfd);
+
+  gdb_assert (disassemble_fn != NULL);
+  return (*disassemble_fn) (memaddr, info);
+}
+
 /* -Wmissing-prototypes */
 extern initialize_file_ftype _initialize_gdbarch_utils;
 
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 967a4b1..040afca 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -273,4 +273,6 @@  extern void default_guess_tracepoint_registers (struct gdbarch *gdbarch,
 						struct regcache *regcache,
 						CORE_ADDR addr);
 
+extern int default_print_insn (bfd_vma memaddr, disassemble_info *info);
+
 #endif
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index ec9db1c..3d041c6 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1499,7 +1499,6 @@  avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_pseudo_register_write (gdbarch, avr_pseudo_register_write);
 
   set_gdbarch_return_value (gdbarch, avr_return_value);
-  set_gdbarch_print_insn (gdbarch, print_insn_avr);
 
   set_gdbarch_push_dummy_call (gdbarch, avr_push_dummy_call);
 
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index c590a91..bfb5d57 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -838,7 +838,6 @@  bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frame_args_skip (gdbarch, 8);
   set_gdbarch_unwind_pc (gdbarch, bfin_unwind_pc);
   set_gdbarch_frame_align (gdbarch, bfin_frame_align);
-  set_gdbarch_print_insn (gdbarch, print_insn_bfin);
 
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index eb39772..e554e24 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3785,19 +3785,6 @@  cris_gdb_func (struct gdbarch *gdbarch, enum cris_op_type op_type,
     }
 }
 
-/* This wrapper is to avoid cris_get_assembler being called before 
-   exec_bfd has been set.  */
-
-static int
-cris_delayed_get_disassembler (bfd_vma addr, struct disassemble_info *info)
-{
-  int (*print_insn) (bfd_vma addr, struct disassemble_info *info);
-
-  print_insn = cris_get_disassembler (exec_bfd);
-  gdb_assert (print_insn != NULL);
-  return print_insn (addr, info);
-}
-
 /* Originally from <asm/elf.h>.  */
 typedef unsigned char cris_elf_greg_t[4];
 
@@ -4134,10 +4121,5 @@  cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
-  /* FIXME: cagney/2003-08-27: It should be possible to select a CRIS
-     disassembler, even when there is no BFD.  Does something like
-     "gdb; target remote; disassmeble *0x123" work?  */
-  set_gdbarch_print_insn (gdbarch, cris_delayed_get_disassembler);
-
   return gdbarch;
 }
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 8744733..c0257bd 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -1582,7 +1582,6 @@  frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       break;
     }
 
-  set_gdbarch_print_insn (gdbarch, print_insn_frv);
   if (frv_abi (gdbarch) == FRV_ABI_FDPIC)
     set_gdbarch_convert_from_func_ptr_addr (gdbarch,
 					    frv_convert_from_func_ptr_addr);
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 5b28275..966a593 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -637,8 +637,6 @@  ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_unwind_pc (gdbarch, ft32_unwind_pc);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_ft32);
-
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 9c827ac..257c39f 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -429,6 +429,7 @@  gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
   gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
   gdbarch->addr_bits_remove = core_addr_identity;
+  gdbarch->print_insn = default_print_insn;
   gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
   gdbarch->skip_solib_resolver = generic_skip_solib_resolver;
   gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
@@ -621,8 +622,7 @@  verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of addr_bits_remove, invalid_p == 0 */
   /* Skip verify of software_single_step, has predicate.  */
   /* Skip verify of single_step_through_delay, has predicate.  */
-  if (gdbarch->print_insn == 0)
-    log.puts ("\n\tprint_insn");
+  /* Skip verify of print_insn, invalid_p == 0 */
   /* Skip verify of skip_trampoline_code, invalid_p == 0 */
   /* Skip verify of skip_solib_resolver, invalid_p == 0 */
   /* Skip verify of in_solib_return_trampoline, invalid_p == 0 */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 753819f..7992cbe 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -643,7 +643,7 @@  F;std::vector<CORE_ADDR>;software_single_step;struct regcache *regcache;regcache
 M;int;single_step_through_delay;struct frame_info *frame;frame
 # FIXME: cagney/2003-08-28: Need to find a better way of selecting the
 # disassembler.  Perhaps objdump can handle it?
-f;int;print_insn;bfd_vma vma, struct disassemble_info *info;vma, info;;0;
+f;int;print_insn;bfd_vma vma, struct disassemble_info *info;vma, info;;default_print_insn;;0
 f;CORE_ADDR;skip_trampoline_code;struct frame_info *frame, CORE_ADDR pc;frame, pc;;generic_skip_trampoline_code;;0
 
 
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 2636a27..229b061 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -3122,8 +3122,6 @@  hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Helper for function argument information.  */
   set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_hppa);
-
   /* When a hardware watchpoint triggers, we'll move the inferior past
      it by removing all eventpoints; stepping past the instruction
      that caused the trigger; reinserting eventpoints; and checking
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index 7d8ed3c..99824b7 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -838,7 +838,6 @@  iq2000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frame_args_skip      (gdbarch, 0);
   set_gdbarch_skip_prologue        (gdbarch, iq2000_skip_prologue);
   set_gdbarch_inner_than           (gdbarch, core_addr_lessthan);
-  set_gdbarch_print_insn           (gdbarch, print_insn_iq2000);
   set_gdbarch_register_type (gdbarch, iq2000_register_type);
   set_gdbarch_frame_align (gdbarch, iq2000_frame_align);
   set_gdbarch_unwind_sp (gdbarch, iq2000_unwind_sp);
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index bd3e182..84ece3e 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -565,9 +565,6 @@  lm32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_push_dummy_call (gdbarch, lm32_push_dummy_call);
   set_gdbarch_return_value (gdbarch, lm32_return_value);
 
-  /* Instruction disassembler.  */
-  set_gdbarch_print_insn (gdbarch, print_insn_lm32);
-
   lm32_add_reggroups (gdbarch);
   set_gdbarch_register_reggroup_p (gdbarch, lm32_register_reggroup_p);
 
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 7376372..1bc5950 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -2639,9 +2639,6 @@  m32c_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Register set.  */
   make_regs (gdbarch);
 
-  /* Disassembly.  */
-  set_gdbarch_print_insn (gdbarch, print_insn_m32c);
-
   /* Breakpoints.  */
   set_gdbarch_breakpoint_kind_from_pc (gdbarch, m32c_breakpoint::kind_from_pc);
   set_gdbarch_sw_breakpoint_from_kind (gdbarch, m32c_breakpoint::bp_from_kind);
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 0820af9..2d14ced 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -947,8 +947,6 @@  m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Return the unwound PC value.  */
   set_gdbarch_unwind_pc (gdbarch, m32r_unwind_pc);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_m32r);
-
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 893d9c2..b19ddf7b 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -1344,16 +1344,6 @@  m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
   if (flags & STO_M68HC12_INTERRUPT)
     MSYMBOL_SET_RTI (msym);
 }
-
-static int
-gdb_print_insn_m68hc11 (bfd_vma memaddr, disassemble_info *info)
-{
-  if (info->arch == bfd_arch_m68hc11)
-    return print_insn_m68hc11 (memaddr, info);
-  else
-    return print_insn_m68hc12 (memaddr, info);
-}
-
 
 
 /* 68HC11/68HC12 register groups.
@@ -1525,7 +1515,6 @@  m68hc11_gdbarch_init (struct gdbarch_info info,
 				       m68hc11_breakpoint::kind_from_pc);
   set_gdbarch_sw_breakpoint_from_kind (gdbarch,
 				       m68hc11_breakpoint::bp_from_kind);
-  set_gdbarch_print_insn (gdbarch, gdb_print_insn_m68hc11);
 
   m68hc11_add_reggroups (gdbarch);
   set_gdbarch_register_reggroup_p (gdbarch, m68hc11_register_reggroup_p);
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 7c3bf4c..5b4736d 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -1240,10 +1240,6 @@  m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_return_in_first_hidden_param_p (gdbarch,
 					      m68k_return_in_first_hidden_param_p);
 
-
-  /* Disassembler.  */
-  set_gdbarch_print_insn (gdbarch, print_insn_m68k);
-
 #if defined JB_PC && defined JB_ELEMENT_SIZE
   tdep->jb_pc = JB_PC;
   tdep->jb_elt_size = JB_ELEMENT_SIZE;
diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c
index 57fe644..d08a913 100644
--- a/gdb/m88k-tdep.c
+++ b/gdb/m88k-tdep.c
@@ -838,8 +838,6 @@  m88k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_iterate_over_regset_sections
     (gdbarch, m88k_iterate_over_regset_sections);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_m88k);
-
   set_gdbarch_skip_prologue (gdbarch, m88k_skip_prologue);
 
   /* Stack grows downward.  */
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 59f94c5..86cb090 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -738,8 +738,6 @@  microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_frame_args_skip (gdbarch, 8);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_microblaze);
-
   set_gdbarch_write_pc (gdbarch, microblaze_write_pc);
 
   set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 0f5e10f..1e2526f 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -1444,8 +1444,6 @@  mn10300_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_sw_breakpoint_from_kind (gdbarch,
 				       mn10300_breakpoint::bp_from_kind);
   /* decr_pc_after_break?  */
-  /* Disassembly.  */
-  set_gdbarch_print_insn (gdbarch, print_insn_mn10300);
 
   /* Stage 2 */
   set_gdbarch_return_value (gdbarch, mn10300_return_value);
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 2972d52..91248cc 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -1142,8 +1142,6 @@  moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_unwind_pc (gdbarch, moxie_unwind_pc);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_moxie);
-
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index d9eebf0..d730e1b 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -997,9 +997,6 @@  msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 				       msp430_breakpoint::bp_from_kind);
   set_gdbarch_decr_pc_after_break (gdbarch, 1);
 
-  /* Disassembly.  */
-  set_gdbarch_print_insn (gdbarch, print_insn_msp430);
-
   /* Frames, prologues, etc.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   set_gdbarch_skip_prologue (gdbarch, msp430_skip_prologue);
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index 1f94b01..2ab6c02 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -1174,7 +1174,6 @@  mt_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_sw_breakpoint_from_kind (gdbarch, mt_sw_breakpoint_from_kind);
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
   set_gdbarch_frame_args_skip (gdbarch, 0);
-  set_gdbarch_print_insn (gdbarch, print_insn_mt);
   set_gdbarch_register_type (gdbarch, mt_register_type);
   set_gdbarch_register_reggroup_p (gdbarch, mt_register_reggroup_p);
 
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index f942780..ae84567 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -2161,8 +2161,6 @@  nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frame_align (gdbarch, nds32_frame_align);
   frame_base_set_default (gdbarch, &nds32_frame_base);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_nds32);
-
   /* Handle longjmp.  */
   set_gdbarch_get_longjmp_target (gdbarch, nds32_get_longjmp_target);
 
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index c214078..905d859 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -1772,18 +1772,6 @@  nios2_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-/* Implement the print_insn gdbarch method.  */
-
-static int
-nios2_print_insn (bfd_vma memaddr, disassemble_info *info)
-{
-  if (info->endian == BFD_ENDIAN_BIG)
-    return print_insn_big_nios2 (memaddr, info);
-  else
-    return print_insn_little_nios2 (memaddr, info);
-}
-
-
 /* Implement the frame_align gdbarch method.  */
 
 static CORE_ADDR
@@ -2357,8 +2345,6 @@  nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   frame_base_set_default (gdbarch, &nios2_frame_base);
 
-  set_gdbarch_print_insn (gdbarch, nios2_print_insn);
-
   /* Enable inferior call support.  */
   set_gdbarch_push_dummy_call (gdbarch, nios2_push_dummy_call);
 
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 83bb3ec..cfd1856 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -1117,8 +1117,6 @@  rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_sw_breakpoint_from_kind (gdbarch, rx_breakpoint::bp_from_kind);
   set_gdbarch_skip_prologue (gdbarch, rx_skip_prologue);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_rx);
-
   set_gdbarch_unwind_pc (gdbarch, rx_unwind_pc);
   set_gdbarch_unwind_sp (gdbarch, rx_unwind_sp);
 
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 8139d81..6d68260 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -8040,8 +8040,6 @@  s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       break;
     }
 
-  set_gdbarch_print_insn (gdbarch, print_insn_s390);
-
   set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
 
   /* Enable TLS support.  */
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 94cf0ca..d231674 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -126,15 +126,6 @@  score_register_sim_regno (struct gdbarch *gdbarch, int regnum)
 }
 #endif
 
-static int
-score_print_insn (bfd_vma memaddr, struct disassemble_info *info)
-{
-  if (info->endian == BFD_ENDIAN_BIG)
-    return print_insn_big_score (memaddr, info);
-  else
-    return print_insn_little_score (memaddr, info);
-}
-
 static inst_t *
 score7_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *memblock)
 {
@@ -1491,7 +1482,6 @@  score_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   set_gdbarch_unwind_sp (gdbarch, score_unwind_sp);
   set_gdbarch_unwind_pc (gdbarch, score_unwind_pc);
-  set_gdbarch_print_insn (gdbarch, score_print_insn);
 
   switch (target_mach)
     {
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 0bc678a..2c2b268 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -2289,7 +2289,6 @@  sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_breakpoint_kind_from_pc (gdbarch, sh_breakpoint_kind_from_pc);
   set_gdbarch_sw_breakpoint_from_kind (gdbarch, sh_sw_breakpoint_from_kind);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_sh);
   set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno);
 
   set_gdbarch_return_value (gdbarch, sh_return_value_nofpu);
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 33986fd..581b57f 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -2416,8 +2416,6 @@  sh64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_breakpoint_kind_from_pc (gdbarch, sh64_breakpoint_kind_from_pc);
   set_gdbarch_sw_breakpoint_from_kind (gdbarch, sh64_sw_breakpoint_from_kind);
-
-  set_gdbarch_print_insn (gdbarch, print_insn_sh);
   set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno);
 
   set_gdbarch_return_value (gdbarch, sh64_return_value);
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index d1e64b4..40c47ae 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1817,8 +1817,6 @@  sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_frame_args_skip (gdbarch, 8);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_sparc);
-
   set_gdbarch_software_single_step (gdbarch, sparc_software_single_step);
   set_gdbarch_write_pc (gdbarch, sparc_write_pc);
 
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index 012b749..156a54f 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -346,14 +346,6 @@  tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     return tdep->breakpoint;
 }
 
-/* This is the implementation of gdbarch method print_insn.  */
-
-static int
-tic6x_print_insn (bfd_vma memaddr, disassemble_info *info)
-{
-  return print_insn_tic6x (memaddr, info);
-}
-
 static void
 tic6x_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			     struct dwarf2_frame_state_reg *reg,
@@ -1318,8 +1310,6 @@  tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Single stepping.  */
   set_gdbarch_software_single_step (gdbarch, tic6x_software_single_step);
 
-  set_gdbarch_print_insn (gdbarch, tic6x_print_insn);
-
   /* Call dummy code.  */
   set_gdbarch_frame_align (gdbarch, tic6x_frame_align);
 
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index fd42a35..2db6790 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -1055,8 +1055,6 @@  tilegx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 				       tilegx_breakpoint::bp_from_kind);
   set_gdbarch_return_value (gdbarch, tilegx_return_value);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_tilegx);
-
   gdbarch_init_osabi (info, gdbarch);
 
   dwarf2_append_unwinders (gdbarch);
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 668635e..087026a 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -1463,8 +1463,6 @@  v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_push_dummy_call (gdbarch, v850_push_dummy_call);
   set_gdbarch_skip_prologue (gdbarch, v850_skip_prologue);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_v850);
-
   set_gdbarch_frame_align (gdbarch, v850_frame_align);
   set_gdbarch_unwind_sp (gdbarch, v850_unwind_sp);
   set_gdbarch_unwind_pc (gdbarch, v850_unwind_pc);
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index 870d268..a92a35a 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -502,8 +502,6 @@  vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_deprecated_function_start_offset (gdbarch, 2);
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_vax);
-
   set_gdbarch_unwind_pc (gdbarch, vax_unwind_pc);
 
   frame_base_set_default (gdbarch, &vax_frame_base);
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 7fdfc65..9d91fd5 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -849,8 +849,6 @@  xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_skip_trampoline_code (gdbarch, xstormy16_skip_trampoline_code);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_xstormy16);
-
   gdbarch_init_osabi (info, gdbarch);
 
   dwarf2_append_unwinders (gdbarch);
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 0a4ed37..f9e8584 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -3256,8 +3256,6 @@  xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   frame_unwind_append_unwinder (gdbarch, &xtensa_unwind);
   dwarf2_append_unwinders (gdbarch);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_xtensa);
-
   set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
 
   xtensa_add_reggroups (gdbarch);