This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch rfc] Deprecate tm_print_insn_info


Hello,

This patch cleans up / deprecates:

	tm_print_insn_info
	TARGET_PRINT_INSN_INFO
	dis_asm_print_address
	dis_asm_memory_read
	dis_asm_memory_error

they are merged into a single:

deprecated_tm_print_insn_info

that lives in "disasm.c". It would all be static, with "deprecated_tm_print_insn_info" deleted, if it were not for some accesses that still need eliminating (at least it is now possible to find them).

Note that "printcmd.c" is still using deprecated_tm_print_insn_info instead of gdb_disassemble. Turns out that further gdb_disassemble fixes are needed - the "sim" target has the same problems as "core", "thread", "procfs", .... Fix to follow.

I'll commit in a day or so,
Andrew
Index: ChangeLog
2003-04-28  Andrew Cagney  <cagney at redhat dot com>

	* gdbarch.sh (deprecated_tm_print_insn_info): Rename
	"tm_print_insn_info".
	(TARGET_PRINT_INSN_INFO): Delete macro.
	(dis_asm_read_memory): Delete function declaration.
	(dis_asm_memory_error, dis_asm_print_address): Ditto.
	(tm_print_insn_info): Delete variable definition.
	(_initialize_gdbarch): Do not initialize "tm_print_insn_info".
	* gdbarch.h, gdbarch.c: Re-generate.
	* d10v-tdep.c (display_trace): Replace "tm_print_insn_info" with
	"deprecated_tm_print_insn_info".
	* mcore-tdep.c (mcore_dump_insn): Ditto.
	* mips-tdep.c (mips_gdbarch_init): Ditto.
	* sparc-tdep.c (_initialize_sparc_tdep): Ditto.
	* v850-tdep.c (v850_scan_prologue, v850_gdbarch_init): Ditto.
	* ia64-tdep.c (_initialize_ia64_tdep): Ditto.
	* printcmd.c (print_insn): Use "deprecated_tm_print_insn_info"
	instead of TARGET_PRINT_INSN_INFO, add comment.
	* s390-tdep.c (s390_get_frame_info): Instead of
	"dis_asm_read_memory", use "deprecated_tm_print_insn_info".
	(s390_check_function_end, s390_is_sigreturn): Ditto.
	* corefile.c (dis_asm_read_memory): Move to "disasm.c".
	(dis_asm_memory_error, dis_asm_print_address): Ditto.
	* disasm.c: Include "gdbcore.h".
	(_initialize_disasm): New function, initialize
	"deprecated_tm_print_insn_info".
	(deprecated_tm_print_insn_info): New variable.
	(dis_asm_read_memory): Moved from "corefile.c", made static.
	(dis_asm_print_address, dis_asm_memory_error): Ditto.
	* Makefile.in (disasm.o): Update dependencies.

Index: gdbtk/ChangeLog
2003-04-28  Andrew Cagney  <cagney at redhat dot com>

	* generic/gdbtk-cmds.c (gdb_disassemble_driver): Instead of
	TARGET_PRINT_INSN_INFO, "dis_asm_memory_error",
	"dis_asm_read_memory", and "dis_asm_print_address", use
	"deprecated_tm_print_insn_info"

Index: tui/ChangeLog
2003-04-28  Andrew Cagney  <cagney at redhat dot com>

	* tuiDisassem.c (tui_disassemble): Use
	"deprecated_tm_print_insn_info" instead of TARGET_PRINT_INSN_INFO,
	add comment.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.368
diff -u -r1.368 Makefile.in
--- Makefile.in	27 Apr 2003 03:23:37 -0000	1.368
+++ Makefile.in	28 Apr 2003 19:45:28 -0000
@@ -1656,7 +1656,7 @@
 dink32-rom.o: dink32-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
 	$(serial_h) $(symfile_h) $(inferior_h) $(regcache_h)
 disasm.o: disasm.c $(defs_h) $(gdb_string_h) $(target_h) $(value_h) \
-	$(disasm_h) $(ui_out_h)
+	$(disasm_h) $(ui_out_h) $(gdbcore_h)
 doublest.o: doublest.c $(defs_h) $(doublest_h) $(floatformat_h) \
 	$(gdb_assert_h) $(gdb_string_h) $(gdbtypes_h)
 dpx2-nat.o: dpx2-nat.c $(defs_h) $(gdbcore_h) $(gdb_string_h)
Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gdb/corefile.c,v
retrieving revision 1.22
diff -u -r1.22 corefile.c
--- corefile.c	14 Jan 2003 00:49:03 -0000	1.22
+++ corefile.c	28 Apr 2003 19:45:29 -0000
@@ -238,28 +238,6 @@
     memory_error (status, memaddr);
 }
 
-/* Like target_read_memory, but slightly different parameters.  */
-int
-dis_asm_read_memory (bfd_vma memaddr, bfd_byte *myaddr, unsigned int len,
-		     disassemble_info *info)
-{
-  return target_read_memory (memaddr, (char *) myaddr, len);
-}
-
-/* Like memory_error with slightly different parameters.  */
-void
-dis_asm_memory_error (int status, bfd_vma memaddr, disassemble_info *info)
-{
-  memory_error (status, memaddr);
-}
-
-/* Like print_address with slightly different parameters.  */
-void
-dis_asm_print_address (bfd_vma addr, struct disassemble_info *info)
-{
-  print_address (addr, info->stream);
-}
-
 /* Argument / return result struct for use with
    do_captured_read_memory_integer().  MEMADDR and LEN are filled in
    by gdb_read_memory_integer().  RESULT is the contents that were
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.108
diff -u -r1.108 d10v-tdep.c
--- d10v-tdep.c	25 Apr 2003 22:14:05 -0000	1.108
+++ d10v-tdep.c	28 Apr 2003 19:45:32 -0000
@@ -1368,7 +1368,7 @@
 	  printf_filtered ("\t");
 	  wrap_here ("    ");
 	  next_address += TARGET_PRINT_INSN (next_address,
-					     &tm_print_insn_info);
+					     &deprecated_tm_print_insn_info);
 	  printf_filtered ("\n");
 	  gdb_flush (gdb_stdout);
 	}
Index: disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/disasm.c,v
retrieving revision 1.6
diff -u -r1.6 disasm.c
--- disasm.c	8 Apr 2003 01:40:31 -0000	1.6
+++ disasm.c	28 Apr 2003 19:45:32 -0000
@@ -24,8 +24,8 @@
 #include "value.h"
 #include "ui-out.h"
 #include "gdb_string.h"
-
 #include "disasm.h"
+#include "gdbcore.h"
 
 /* Disassemble functions.
    FIXME: We should get rid of all the duplicate code in gdb that does
@@ -43,6 +43,28 @@
   CORE_ADDR end_pc;
 };
 
+/* Like target_read_memory, but slightly different parameters.  */
+static int
+dis_asm_read_memory (bfd_vma memaddr, bfd_byte *myaddr, unsigned int len,
+		     disassemble_info *info)
+{
+  return target_read_memory (memaddr, (char *) myaddr, len);
+}
+
+/* Like memory_error with slightly different parameters.  */
+static void
+dis_asm_memory_error (int status, bfd_vma memaddr, disassemble_info *info)
+{
+  memory_error (status, memaddr);
+}
+
+/* Like print_address with slightly different parameters.  */
+static void
+dis_asm_print_address (bfd_vma addr, struct disassemble_info *info)
+{
+  print_address (addr, info->stream);
+}
+
 /* This variable determines where memory used for disassembly is read from. */
 int gdb_disassemble_from_exec = -1;
 
@@ -390,4 +412,22 @@
 				  high, symtab, how_many, stb);
 
   gdb_flush (gdb_stdout);
+}
+
+
+/* FIXME: cagney/2003-04-28: This global deprecated_tm_print_insn_info
+   is going away.  */
+disassemble_info deprecated_tm_print_insn_info;
+
+extern void _initialize_disasm (void);
+
+void
+_initialize_disasm (void)
+{
+  INIT_DISASSEMBLE_INFO_NO_ARCH (deprecated_tm_print_insn_info, gdb_stdout,
+				 (fprintf_ftype)fprintf_filtered);
+  deprecated_tm_print_insn_info.flavour = bfd_target_unknown_flavour;
+  deprecated_tm_print_insn_info.read_memory_func = dis_asm_read_memory;
+  deprecated_tm_print_insn_info.memory_error_func = dis_asm_memory_error;
+  deprecated_tm_print_insn_info.print_address_func = dis_asm_print_address;
 }
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.226
diff -u -r1.226 gdbarch.sh
--- gdbarch.sh	28 Apr 2003 16:17:28 -0000	1.226
+++ gdbarch.sh	28 Apr 2003 19:45:40 -0000
@@ -1209,23 +1209,11 @@
 
 /* The target-system-dependent disassembler is semi-dynamic */
 
-extern int dis_asm_read_memory (bfd_vma memaddr, bfd_byte *myaddr,
-				unsigned int len, disassemble_info *info);
-
-extern void dis_asm_memory_error (int status, bfd_vma memaddr,
-				  disassemble_info *info);
-
-extern void dis_asm_print_address (bfd_vma addr,
-				   disassemble_info *info);
-
-/* Use set_gdbarch_print_insn instead.  */
+/* Use gdb_disassemble, and gdbarch_print_insn instead.  */
 extern int (*deprecated_tm_print_insn) (bfd_vma, disassemble_info*);
-extern disassemble_info tm_print_insn_info;
-#ifndef TARGET_PRINT_INSN_INFO
-#define TARGET_PRINT_INSN_INFO (&tm_print_insn_info)
-#endif
-
 
+/* Use set_gdbarch_print_insn instead.  */
+extern disassemble_info deprecated_tm_print_insn_info;
 
 /* Set the dynamic target-system-dependent parameters (architecture,
    byte-order, ...) using information found in the BFD */
@@ -2379,8 +2367,6 @@
 
 /* Pointer to the target-dependent disassembly function.  */
 int (*deprecated_tm_print_insn) (bfd_vma, disassemble_info *);
-disassemble_info tm_print_insn_info;
-
 
 extern void _initialize_gdbarch (void);
 
@@ -2388,12 +2374,6 @@
 _initialize_gdbarch (void)
 {
   struct cmd_list_element *c;
-
-  INIT_DISASSEMBLE_INFO_NO_ARCH (tm_print_insn_info, gdb_stdout, (fprintf_ftype)fprintf_filtered);
-  tm_print_insn_info.flavour = bfd_target_unknown_flavour;
-  tm_print_insn_info.read_memory_func = dis_asm_read_memory;
-  tm_print_insn_info.memory_error_func = dis_asm_memory_error;
-  tm_print_insn_info.print_address_func = dis_asm_print_address;
 
   add_show_from_set (add_set_cmd ("arch",
 				  class_maintenance,
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.70
diff -u -r1.70 ia64-tdep.c
--- ia64-tdep.c	28 Apr 2003 16:17:28 -0000	1.70
+++ ia64-tdep.c	28 Apr 2003 19:45:40 -0000
@@ -2252,5 +2252,5 @@
   register_gdbarch_init (bfd_arch_ia64, ia64_gdbarch_init);
 
   deprecated_tm_print_insn = print_insn_ia64;
-  tm_print_insn_info.bytes_per_line = SLOT_MULTIPLIER;
+  deprecated_tm_print_insn_info.bytes_per_line = SLOT_MULTIPLIER;
 }
Index: mcore-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mcore-tdep.c,v
retrieving revision 1.58
diff -u -r1.58 mcore-tdep.c
--- mcore-tdep.c	28 Apr 2003 16:17:28 -0000	1.58
+++ mcore-tdep.c	28 Apr 2003 19:45:42 -0000
@@ -163,7 +163,7 @@
     {
       printf_filtered ("MCORE:  %s %08x %08x ",
 		       commnt, (unsigned int) pc, (unsigned int) insn);
-      TARGET_PRINT_INSN (pc, &tm_print_insn_info);
+      TARGET_PRINT_INSN (pc, &deprecated_tm_print_insn_info);
       printf_filtered ("\n");
     }
 }
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.192
diff -u -r1.192 mips-tdep.c
--- mips-tdep.c	28 Apr 2003 16:17:28 -0000	1.192
+++ mips-tdep.c	28 Apr 2003 19:45:47 -0000
@@ -5543,9 +5543,9 @@
 
   /* Reset the disassembly info, in case it was set to something
      non-default.  */
-  tm_print_insn_info.flavour = bfd_target_unknown_flavour;
-  tm_print_insn_info.arch = bfd_arch_unknown;
-  tm_print_insn_info.mach = 0;
+  deprecated_tm_print_insn_info.flavour = bfd_target_unknown_flavour;
+  deprecated_tm_print_insn_info.arch = bfd_arch_unknown;
+  deprecated_tm_print_insn_info.mach = 0;
 
   elf_flags = 0;
 
@@ -5626,7 +5626,7 @@
   if (wanted_abi != MIPS_ABI_UNKNOWN)
     mips_abi = wanted_abi;
 
-  /* We have to set tm_print_insn_info before looking for a
+  /* We have to set deprecated_tm_print_insn_info before looking for a
      pre-existing architecture, otherwise we may return before we get
      a chance to set it up.  */
   if (mips_abi == MIPS_ABI_N32 || mips_abi == MIPS_ABI_N64)
@@ -5634,17 +5634,17 @@
       /* Set up the disassembler info, so that we get the right
 	 register names from libopcodes.  */
       if (mips_abi == MIPS_ABI_N32)
-	tm_print_insn_info.disassembler_options = "gpr-names=n32";
+	deprecated_tm_print_insn_info.disassembler_options = "gpr-names=n32";
       else
-	tm_print_insn_info.disassembler_options = "gpr-names=64";
-      tm_print_insn_info.flavour = bfd_target_elf_flavour;
-      tm_print_insn_info.arch = bfd_arch_mips;
+	deprecated_tm_print_insn_info.disassembler_options = "gpr-names=64";
+      deprecated_tm_print_insn_info.flavour = bfd_target_elf_flavour;
+      deprecated_tm_print_insn_info.arch = bfd_arch_mips;
       if (info.bfd_arch_info != NULL
 	  && info.bfd_arch_info->arch == bfd_arch_mips
 	  && info.bfd_arch_info->mach)
-	tm_print_insn_info.mach = info.bfd_arch_info->mach;
+	deprecated_tm_print_insn_info.mach = info.bfd_arch_info->mach;
       else
-	tm_print_insn_info.mach = bfd_mach_mips8000;
+	deprecated_tm_print_insn_info.mach = bfd_mach_mips8000;
     }
   else
     /* This string is not recognized explicitly by the disassembler,
@@ -5652,7 +5652,7 @@
        the bfd elf headers, such that, if the user overrides the ABI
        of a program linked as NewABI, the disassembly will follow the
        register naming conventions specified by the user.  */
-    tm_print_insn_info.disassembler_options = "gpr-names=32";
+    deprecated_tm_print_insn_info.disassembler_options = "gpr-names=32";
 
   if (gdbarch_debug)
     {
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.59
diff -u -r1.59 printcmd.c
--- printcmd.c	1 Apr 2003 23:51:17 -0000	1.59
+++ printcmd.c	28 Apr 2003 19:45:47 -0000
@@ -2243,21 +2243,25 @@
 /* Print the instruction at address MEMADDR in debugged memory,
    on STREAM.  Returns length of the instruction, in bytes.  */
 
+/* FIXME: cagney/2003-04-28: Should instead be using the generic
+   disassembler but first need to clean that up and stop it trying to
+   access the exec file.  */
+
 static int
 print_insn (CORE_ADDR memaddr, struct ui_file *stream)
 {
   if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
-    TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG;
+    deprecated_tm_print_insn_info.endian = BFD_ENDIAN_BIG;
   else
-    TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE;
+    deprecated_tm_print_insn_info.endian = BFD_ENDIAN_LITTLE;
 
   if (TARGET_ARCHITECTURE != NULL)
-    TARGET_PRINT_INSN_INFO->mach = TARGET_ARCHITECTURE->mach;
+    deprecated_tm_print_insn_info.mach = TARGET_ARCHITECTURE->mach;
   /* else: should set .mach=0 but some disassemblers don't grok this */
 
-  TARGET_PRINT_INSN_INFO->stream = stream;
+  deprecated_tm_print_insn_info.stream = stream;
 
-  return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO);
+  return TARGET_PRINT_INSN (memaddr, &deprecated_tm_print_insn_info);
 }
 
 
Index: s390-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/s390-tdep.c,v
retrieving revision 1.93
diff -u -r1.93 s390-tdep.c
--- s390-tdep.c	28 Apr 2003 16:17:28 -0000	1.93
+++ s390-tdep.c	28 Apr 2003 19:45:48 -0000
@@ -280,7 +280,7 @@
 
   memset (gprs_saved, 0, sizeof (gprs_saved));
   memset (fprs_saved, 0, sizeof (fprs_saved));
-  info.read_memory_func = dis_asm_read_memory;
+  info.read_memory_func = deprecated_tm_print_insn_info.read_memory_func;
 
   save_link_regidx = subtract_sp_regidx = 0;
   if (fextra_info)
@@ -682,7 +682,7 @@
   disassemble_info info;
   int regidx, instrlen;
 
-  info.read_memory_func = dis_asm_read_memory;
+  info.read_memory_func = deprecated_tm_print_insn_info.read_memory_func;
   instrlen = s390_readinstruction (instr, pc, &info);
   if (instrlen < 0)
     return -1;
@@ -819,7 +819,7 @@
 
   scontext = temp_sregs = 0;
 
-  info.read_memory_func = dis_asm_read_memory;
+  info.read_memory_func = deprecated_tm_print_insn_info.read_memory_func;
   instrlen = s390_readinstruction (instr, pc, &info);
   if (sigcaller_pc)
     *sigcaller_pc = 0;
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.91
diff -u -r1.91 sparc-tdep.c
--- sparc-tdep.c	28 Apr 2003 16:17:28 -0000	1.91
+++ sparc-tdep.c	28 Apr 2003 19:45:52 -0000
@@ -2461,7 +2461,7 @@
   gdbarch_register (bfd_arch_sparc, sparc_gdbarch_init, sparc_dump_tdep);
 
   deprecated_tm_print_insn = gdb_print_insn_sparc;
-  tm_print_insn_info.mach = TM_PRINT_INSN_MACH;		/* Selects sparc/sparclite */
+  deprecated_tm_print_insn_info.mach = TM_PRINT_INSN_MACH;		/* Selects sparc/sparclite */
   /* OBSOLETE target_architecture_hook = sparc_target_architecture_hook; */
 }
 
Index: v850-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/v850-tdep.c,v
retrieving revision 1.57
diff -u -r1.57 v850-tdep.c
--- v850-tdep.c	28 Apr 2003 16:17:28 -0000	1.57
+++ v850-tdep.c	28 Apr 2003 19:45:53 -0000
@@ -614,7 +614,7 @@
 
 #ifdef DEBUG
       printf_filtered ("0x%.8lx ", (long) current_pc);
-      TARGET_PRINT_INSN (current_pc, &tm_print_insn_info);
+      TARGET_PRINT_INSN (current_pc, &deprecated_tm_print_insn_info);
 #endif
 
       insn = read_memory_unsigned_integer (current_pc, 2);
@@ -1215,7 +1215,7 @@
       if (v850_processor_type_table[i].mach == info.bfd_arch_info->mach)
 	{
 	  v850_register_names = v850_processor_type_table[i].regnames;
-	  tm_print_insn_info.mach = info.bfd_arch_info->mach;
+	  deprecated_tm_print_insn_info.mach = info.bfd_arch_info->mach;
 	  break;
 	}
     }
Index: gdbtk/generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.72
diff -u -r1.72 gdbtk-cmds.c
--- gdbtk/generic/gdbtk-cmds.c	6 Mar 2003 21:58:41 -0000	1.72
+++ gdbtk/generic/gdbtk-cmds.c	28 Apr 2003 19:45:55 -0000
@@ -1928,12 +1928,15 @@
       INIT_DISASSEMBLE_INFO_NO_ARCH (di, gdb_stdout,
                                      (fprintf_ftype) fprintf_unfiltered);
       di.flavour = bfd_target_unknown_flavour;
-      di.memory_error_func = dis_asm_memory_error;
-      di.print_address_func = dis_asm_print_address;
+      /* NOTE: cagney/2003-04: This all goes away, along with this
+         function, when insight starts using the "disasm.h"
+         disassembler.  */
+      di.memory_error_func = deprecated_tm_print_insn_info.memory_error_func;
+      di.print_address_func = deprecated_tm_print_insn_info.print_address_func;
       di_initialized = 1;
     }
 
-  di.mach = TARGET_PRINT_INSN_INFO->mach;
+  di.mach = deprecated_tm_print_insn_info.mach;
   if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     di.endian = BFD_ENDIAN_BIG;
   else
@@ -1977,7 +1980,7 @@
   if (disassemble_from_exec)
     di.read_memory_func = gdbtk_dis_asm_read_memory;
   else
-    di.read_memory_func = dis_asm_read_memory;
+    di.read_memory_func = deprecated_tm_print_insn_info.read_memory_func;
 
   /* If just doing straight assembly, all we need to do is disassemble
      everything between low and high.  If doing mixed source/assembly, we've
Index: tui/tuiDisassem.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiDisassem.c,v
retrieving revision 1.18
diff -u -r1.18 tuiDisassem.c
--- tui/tuiDisassem.c	29 Nov 2002 19:15:16 -0000	1.18
+++ tui/tuiDisassem.c	28 Apr 2003 19:45:55 -0000
@@ -73,7 +73,11 @@
   /* now init the ui_file structure */
   gdb_dis_out = tui_sfileopen (256);
 
-  memcpy (&asm_info, TARGET_PRINT_INSN_INFO, sizeof (asm_info));
+  /* FIXME: cagney/2003-04-28: Should instead be using the generic
+     disassembler but first need to clean that up and stop it trying
+     to access the exec file.  */
+
+  memcpy (&asm_info, &deprecated_tm_print_insn_info, sizeof (asm_info));
   asm_info.stream = gdb_dis_out;
 
   if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]