This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] Eliminate deprecated_tm_print_insn pass #1
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 27 Aug 2003 22:52:00 -0400
- Subject: [commit] Eliminate deprecated_tm_print_insn pass #1
Hello,
This is a first pass through the elimination of
deprecated_tm_print_insn. It's largely straight forward. A few not
quite obvious simplifications deserve to be highlighted:
- cris
The first time through the old code was doing the sequence: disasm.c ->
TARGET_PRINT_INSN -> legacy_print_insn -> deprecated_tm_print_insn ->
cris_delayed_get_disassembler [fortunatly this modified
deprecated_tm_print_insn] -> TARGET_PRINT_INSN -> legacy_print_insn ->
deprecated_tm_print_insn -> <real disassembler>. The new code is
simpler. I also added a comment explaining a likely bug.
- s390
The old code was customizing the disassembler output by including a hex
dump of the instructions vis:
0x0000000080039a90 <main+84>: 07 F4 br %r4
I've removed this, making the behavior consistent with the rest of GDB.
A useful feature would be an option to enable output like this in the
generic disassembler.
- sparc
Turned out that disasm.c, gdb_print_insn_sparc, and sparc_gdbarch_init
were all setting the disassembler_info -> mach to the bfd's mach.
Andrew
2003-08-27 Andrew Cagney <cagney@redhat.com>
* Makefile.in (cris-tdep.o): Update dependencies.
* cris-tdep.c: Include "gdb_assert.h".
(cris_gdbarch_init): Set print_insn.
(_initialize_cris_tdep): Do not set deprecated_tm_print_insn.
(cris_delayed_get_disassembler): Simplify, directly call the
disassembler returned by cris_get_disassembler.
* hppa-tdep.c (hppa_gdbarch_init): Set print_insn.
(_initialize_hppa_tdep): Do not set deprecated_tm_print_insn.
* ns32k-tdep.c (ns32k_gdbarch_init): Set print_insn.
(_initialize_ns32k_tdep): Do not set deprecated_tm_print_insn.
* mn10300-tdep.c (mn10300_gdbarch_init): Set print_insn.
(_initialize_mn10300_tdep): Do not set deprecated_tm_print_insn.
* mcore-tdep.c (mcore_gdbarch_init): Set print_insn.
(_initialize_mcore_tdep): Do not set deprecated_tm_print_insn.
* frv-tdep.c (frv_gdbarch_init): Set print_insn.
(_initialize_frv_tdep): Do not set deprecated_tm_print_insn.
* sparc-tdep.c (sparc_gdbarch_init): Set print_insn.
(gdb_print_insn_sparc): Delete function.
(_initialize_sparc_tdep): Do not set deprecated_tm_print_insn or
deprecated_tm_print_insn_info.
* v850-tdep.c (v850_gdbarch_init): Set print_insn.
(_initialize_v850_tdep): Do not set deprecated_tm_print_insn.
(v850_gdbarch_init): Do not set deprecated_tm_print_insn_info.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Set print_insn.
(_initialize_xstormy16_tdep): Do not set deprecated_tm_print_insn.
* s390-tdep.c (gdb_print_insn_s390): Delete function.
(_initialize_s390_tdep): Do not set deprecated_tm_print_insn.
(s390_gdbarch_init): Set print_insn.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.432
diff -u -r1.432 Makefile.in
--- Makefile.in 28 Aug 2003 00:49:31 -0000 1.432
+++ Makefile.in 28 Aug 2003 02:16:19 -0000
@@ -1666,7 +1666,7 @@
cris-tdep.o: cris-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(inferior_h) \
$(gdbtypes_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(value_h) \
$(opcode_cris_h) $(arch_utils_h) $(regcache_h) $(symfile_h) \
- $(solib_h) $(solib_svr4_h) $(gdb_string_h)
+ $(solib_h) $(solib_svr4_h) $(gdb_string_h) $(gdb_assert_h)
c-typeprint.o: c-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \
$(language_h) $(demangle_h) $(c_lang_h) $(typeprint_h) $(cp_abi_h) \
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.79
diff -u -r1.79 cris-tdep.c
--- cris-tdep.c 16 Jun 2003 16:47:41 -0000 1.79
+++ cris-tdep.c 28 Aug 2003 02:16:32 -0000
@@ -31,6 +31,7 @@
#include "opcode/cris.h"
#include "arch-utils.h"
#include "regcache.h"
+#include "gdb_assert.h"
/* To get entry_point_address. */
#include "symfile.h"
@@ -3540,8 +3541,14 @@
static int
cris_delayed_get_disassembler (bfd_vma addr, disassemble_info *info)
{
- deprecated_tm_print_insn = cris_get_disassembler (exec_bfd);
- return TARGET_PRINT_INSN (addr, info);
+ int (*print_insn) (bfd_vma addr, disassemble_info *info);
+ /* 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? */
+ gdb_assert (exec_bfd != NULL);
+ print_insn = cris_get_disassembler (exec_bfd);
+ gdb_assert (print_insn != NULL);
+ return print_insn (addr, info);
}
/* Copied from <asm/elf.h>. */
@@ -3854,9 +3861,6 @@
gdbarch_register (bfd_arch_cris, cris_gdbarch_init, cris_dump_tdep);
- /* Used in disassembly. */
- deprecated_tm_print_insn = cris_delayed_get_disassembler;
-
/* CRIS-specific user-commands. */
c = add_set_cmd ("cris-version", class_support, var_integer,
(char *) &usr_cmd_cris_version,
@@ -4304,5 +4308,10 @@
set_solib_svr4_fetch_link_map_offsets
(gdbarch, cris_linux_svr4_fetch_link_map_offsets);
+ /* 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;
}
Index: frv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/frv-tdep.c,v
retrieving revision 1.48
diff -u -r1.48 frv-tdep.c
--- frv-tdep.c 20 Aug 2003 20:22:41 -0000 1.48
+++ frv-tdep.c 28 Aug 2003 02:16:33 -0000
@@ -1140,6 +1140,8 @@
break;
}
+ set_gdbarch_print_insn (gdbarch, print_insn_frv);
+
return gdbarch;
}
@@ -1147,8 +1149,6 @@
_initialize_frv_tdep (void)
{
register_gdbarch_init (bfd_arch_frv, frv_gdbarch_init);
-
- deprecated_tm_print_insn = print_insn_frv;
}
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.89
diff -u -r1.89 hppa-tdep.c
--- hppa-tdep.c 15 Aug 2003 23:02:03 -0000 1.89
+++ hppa-tdep.c 28 Aug 2003 02:16:36 -0000
@@ -5203,6 +5203,8 @@
/* Helper for function argument information. */
set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
+ set_gdbarch_print_insn (gdbarch, print_insn_hppa);
+
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
@@ -5224,7 +5226,6 @@
void break_at_finish_at_depth_command (char *arg, int from_tty);
gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep);
- deprecated_tm_print_insn = print_insn_hppa;
add_cmd ("unwind", class_maintenance, unwind_command,
"Print unwind table entry at given address.",
Index: mcore-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mcore-tdep.c,v
retrieving revision 1.71
diff -u -r1.71 mcore-tdep.c
--- mcore-tdep.c 26 Jun 2003 17:18:42 -0000 1.71
+++ mcore-tdep.c 28 Aug 2003 02:16:36 -0000
@@ -1119,6 +1119,8 @@
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
+ set_gdbarch_print_insn (gdbarch, print_insn_mcore);
+
return gdbarch;
}
@@ -1133,9 +1135,7 @@
void
_initialize_mcore_tdep (void)
{
- extern int print_insn_mcore (bfd_vma, disassemble_info *);
gdbarch_register (bfd_arch_mcore, mcore_gdbarch_init, mcore_dump_tdep);
- deprecated_tm_print_insn = print_insn_mcore;
#ifdef MCORE_DEBUG
add_show_from_set (add_set_cmd ("mcoredebug", no_class,
Index: mn10300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v
retrieving revision 1.84
diff -u -r1.84 mn10300-tdep.c
--- mn10300-tdep.c 30 Jul 2003 20:44:46 -0000 1.84
+++ mn10300-tdep.c 28 Aug 2003 02:16:38 -0000
@@ -1218,6 +1218,8 @@
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
+ set_gdbarch_print_insn (gdbarch, print_insn_mn10300);
+
return gdbarch;
}
@@ -1225,8 +1227,6 @@
_initialize_mn10300_tdep (void)
{
/* printf("_initialize_mn10300_tdep\n"); */
-
- deprecated_tm_print_insn = print_insn_mn10300;
register_gdbarch_init (bfd_arch_mn10300, mn10300_gdbarch_init);
}
Index: ns32k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ns32k-tdep.c,v
retrieving revision 1.54
diff -u -r1.54 ns32k-tdep.c
--- ns32k-tdep.c 26 Jun 2003 17:18:42 -0000 1.54
+++ ns32k-tdep.c 28 Aug 2003 02:16:40 -0000
@@ -606,6 +606,8 @@
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
+ set_gdbarch_print_insn (gdbarch, print_insn_ns32k);
+
/* Hook in OS ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
@@ -619,5 +621,4 @@
{
gdbarch_register (bfd_arch_ns32k, ns32k_gdbarch_init, NULL);
- deprecated_tm_print_insn = print_insn_ns32k;
}
Index: s390-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/s390-tdep.c,v
retrieving revision 1.108
diff -u -r1.108 s390-tdep.c
--- s390-tdep.c 2 Jul 2003 19:20:55 -0000 1.108
+++ s390-tdep.c 28 Aug 2003 02:16:46 -0000
@@ -1971,26 +1971,6 @@
value, arglen);
}
}
-static int
-gdb_print_insn_s390 (bfd_vma memaddr, disassemble_info * info)
-{
- bfd_byte instrbuff[S390_MAX_INSTR_SIZE];
- int instrlen, cnt;
-
- instrlen = s390_readinstruction (instrbuff, (CORE_ADDR) memaddr, info);
- if (instrlen < 0)
- {
- (*info->memory_error_func) (instrlen, memaddr, info);
- return -1;
- }
- for (cnt = 0; cnt < instrlen; cnt++)
- info->fprintf_func (info->stream, "%02X ", instrbuff[cnt]);
- for (cnt = instrlen; cnt < S390_MAX_INSTR_SIZE; cnt++)
- info->fprintf_func (info->stream, " ");
- instrlen = print_insn_s390 (memaddr, info);
- return instrlen;
-}
-
/* Not the most efficent code in the world */
@@ -2722,6 +2702,8 @@
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
+ set_gdbarch_print_insn (gdbarch, print_insn_s390);
+
return gdbarch;
}
@@ -2735,6 +2717,4 @@
/* Hook us into the gdbarch mechanism. */
register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init);
- if (!deprecated_tm_print_insn) /* Someone may have already set it */
- deprecated_tm_print_insn = gdb_print_insn_s390;
}
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.119
diff -u -r1.119 sparc-tdep.c
--- sparc-tdep.c 24 Aug 2003 11:47:18 -0000 1.119
+++ sparc-tdep.c 28 Aug 2003 02:16:49 -0000
@@ -2139,16 +2139,6 @@
// OBSOLETE }
#endif
-
-static int
-gdb_print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
-{
- /* It's necessary to override mach again because print_insn messes it up. */
- info->mach = TARGET_ARCHITECTURE->mach;
- return print_insn_sparc (memaddr, info);
-}
-
-
#define SPARC_F0_REGNUM FP0_REGNUM /* %f0 */
#define SPARC_F1_REGNUM (FP0_REGNUM + 1)/* %f1 */
#define SPARC_O0_REGNUM O0_REGNUM /* %o0 */
@@ -2559,8 +2549,6 @@
/* Hook us into the gdbarch mechanism. */
gdbarch_register (bfd_arch_sparc, sparc_gdbarch_init, sparc_dump_tdep);
- deprecated_tm_print_insn = gdb_print_insn_sparc;
- deprecated_tm_print_insn_info.mach = TM_PRINT_INSN_MACH; /* Selects sparc/sparclite */
/* OBSOLETE target_architecture_hook = sparc_target_architecture_hook; */
}
@@ -3576,6 +3564,8 @@
tdep->print_insn_mach = bfd_mach_sparc_v9a;
break;
}
+
+ set_gdbarch_print_insn (gdbarch, print_insn_sparc);
/* Hook in OS ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
Index: v850-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/v850-tdep.c,v
retrieving revision 1.68
diff -u -r1.68 v850-tdep.c
--- v850-tdep.c 13 Jun 2003 04:40:34 -0000 1.68
+++ v850-tdep.c 28 Aug 2003 02:16:49 -0000
@@ -1215,7 +1215,6 @@
if (v850_processor_type_table[i].mach == info.bfd_arch_info->mach)
{
v850_register_names = v850_processor_type_table[i].regnames;
- deprecated_tm_print_insn_info.mach = info.bfd_arch_info->mach;
break;
}
}
@@ -1288,6 +1287,8 @@
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
+ set_gdbarch_print_insn (gdbarch, print_insn_v850);
+
return gdbarch;
}
@@ -1296,6 +1297,5 @@
void
_initialize_v850_tdep (void)
{
- deprecated_tm_print_insn = print_insn_v850;
register_gdbarch_init (bfd_arch_v850, v850_gdbarch_init);
}
Index: xstormy16-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xstormy16-tdep.c,v
retrieving revision 1.58
diff -u -r1.58 xstormy16-tdep.c
--- xstormy16-tdep.c 16 Jun 2003 16:47:43 -0000 1.58
+++ xstormy16-tdep.c 28 Aug 2003 02:16:50 -0000
@@ -1114,6 +1114,8 @@
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
+ set_gdbarch_print_insn (gdbarch, print_insn_xstormy16);
+
return gdbarch;
}
@@ -1129,5 +1131,4 @@
extern int print_insn_xstormy16 ();
register_gdbarch_init (bfd_arch_xstormy16, xstormy16_gdbarch_init);
- deprecated_tm_print_insn = print_insn_xstormy16;
}