This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RFA: cleanup INIT_DISASSEMBLE_INFO macro
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 26 Aug 2003 19:47:00 -0400
- Subject: RFA: cleanup INIT_DISASSEMBLE_INFO macro
Hello,
The attached replaces the body of the INIT_DISASSEMBLE_INFO macro with a
function (init_disassemble_info). As for INIT_DISASSEMBLE_INFO_NO_ARCH,
it deletes it (For reference, I've also attached a patch expunging the
macro from GDB).
This started out with me fixing a problem MichaelS spotted with the old
macro (It didn't initialize "insn_sets") but I let my distaste for
macros get the better of me :-)
Ok?
Should binutils/objdump be updated and INIT_DISASSEMBLE_INFO also deleted.
Should both macro's be retained for "backward compatibility"?
Andrew
Index: include/ChangeLog
2003-08-26 Andrew Cagney <cagney@redhat.com>
* dis-asm.h (init_disassemble_info): Declare.
(INIT_DISASSEMBLE_INFO): Call init_disassemble_info.
(INIT_DISASSEMBLE_INFO_NO_ARCH): Delete macro.
Index: opcodes/ChangeLog
2003-08-26 Andrew Cagney <cagney@redhat.com>
* dis-init.c (init_disassemble_info): New file and function. Also
initialize "insn_sets".
* Makefile.am (CFILES): Add "dis-init.c".
(libopcodes_la_SOURCES): Add "dis-init.c".
(dis-init.lo): Specify dependencies.
* Makefile.in: Regenerate.
Index: include/dis-asm.h
===================================================================
RCS file: /cvs/src/src/include/dis-asm.h,v
retrieving revision 1.44
diff -u -r1.44 dis-asm.h
--- include/dis-asm.h 7 Aug 2003 02:25:49 -0000 1.44
+++ include/dis-asm.h 26 Aug 2003 23:34:31 -0000
@@ -284,42 +284,12 @@
extern int generic_symbol_at_address
(bfd_vma, struct disassemble_info *);
-/* Macro to initialize a disassemble_info struct. This should be called
- by all applications creating such a struct. */
+/* Method to initialize a disassemble_info struct. This should be
+ called by all applications creating such a struct. */
+extern void init_disassemble_info (struct disassemble_info *info, void *stream,
+ fprintf_ftype fprintf_func);
#define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC) \
- (INFO).flavour = bfd_target_unknown_flavour, \
- (INFO).arch = bfd_arch_unknown, \
- (INFO).mach = 0, \
- (INFO).insn_sets = 0, \
- (INFO).endian = BFD_ENDIAN_UNKNOWN, \
- (INFO).octets_per_byte = 1, \
- INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC)
-
-/* Call this macro to initialize only the internal variables for the
- disassembler. Architecture dependent things such as byte order, or machine
- variant are not touched by this macro. This makes things much easier for
- GDB which must initialize these things separately. */
-
-#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
- (INFO).fprintf_func = (fprintf_ftype)(FPRINTF_FUNC), \
- (INFO).stream = (STREAM), \
- (INFO).section = NULL, \
- (INFO).symbols = NULL, \
- (INFO).num_symbols = 0, \
- (INFO).private_data = NULL, \
- (INFO).buffer = NULL, \
- (INFO).buffer_vma = 0, \
- (INFO).buffer_length = 0, \
- (INFO).read_memory_func = buffer_read_memory, \
- (INFO).memory_error_func = perror_memory, \
- (INFO).print_address_func = generic_print_address, \
- (INFO).symbol_at_address_func = generic_symbol_at_address, \
- (INFO).flags = 0, \
- (INFO).bytes_per_line = 0, \
- (INFO).bytes_per_chunk = 0, \
- (INFO).display_endian = BFD_ENDIAN_UNKNOWN, \
- (INFO).disassembler_options = NULL, \
- (INFO).insn_info_valid = 0
+ init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC))
#ifdef __cplusplus
}
Index: opcodes/Makefile.am
===================================================================
RCS file: /cvs/src/src/opcodes/Makefile.am,v
retrieving revision 1.68
diff -u -r1.68 Makefile.am
--- opcodes/Makefile.am 14 Aug 2003 07:03:18 -0000 1.68
+++ opcodes/Makefile.am 26 Aug 2003 23:34:42 -0000
@@ -63,6 +63,7 @@
d30v-opc.c \
dlx-dis.c \
dis-buf.c \
+ dis-init.c \
disassemble.c \
fr30-asm.c \
fr30-desc.c \
@@ -281,7 +282,7 @@
disassemble.lo: disassemble.c $(INCDIR)/dis-asm.h
$(LIBTOOL) --mode=compile $(COMPILE) -c @archdefs@ $(srcdir)/disassemble.c
-libopcodes_la_SOURCES = dis-buf.c disassemble.c
+libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
libopcodes_la_DEPENDENCIES = $(OFILES) ../bfd/libbfd.la
libopcodes_la_LIBADD = $(OFILES) @WIN32LIBADD@ ../bfd/libbfd.la
libopcodes_la_LDFLAGS = -release $(VERSION) @WIN32LDFLAGS@
@@ -546,6 +547,8 @@
dlx-dis.lo: dlx-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/dlx.h
dis-buf.lo: dis-buf.c sysdep.h config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h opintl.h
+dis-init.lo: dis-init.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h opintl.h
disassemble.lo: disassemble.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
Index: gdb/ChangeLog
2003-08-26 Andrew Cagney <cagney@redhat.com>
* disasm.c (fprintf_disasm): New function.
(gdb_disassemble_info): Call "init_disassemble_info", instead of
INIT_DISASSEMBLE_INFO_NO_ARCH. Do not initialize "insn_sets".
(_initialize_disasm): Call "init_disassemble_info", instead of
INIT_DISASSEMBLE_INFO_NO_ARCH.
Index: gdb/disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/disasm.c,v
retrieving revision 1.13
diff -u -r1.13 disasm.c
--- gdb/disasm.c 14 Aug 2003 21:39:05 -0000 1.13
+++ gdb/disasm.c 26 Aug 2003 23:34:23 -0000
@@ -313,12 +313,22 @@
/* Initialize the disassemble info struct ready for the specified
stream. */
+static int
+fprintf_disasm (void *stream, const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ vfprintf_filtered (stream, format, args);
+ va_end (args);
+ /* Something non -ve. */
+ return 0;
+}
+
static disassemble_info
gdb_disassemble_info (struct gdbarch *gdbarch, struct ui_file *file)
{
disassemble_info di;
- INIT_DISASSEMBLE_INFO_NO_ARCH (di, file,
- (fprintf_ftype) fprintf_filtered);
+ init_disassemble_info (&di, file, fprintf_disasm);
di.flavour = bfd_target_unknown_flavour;
di.memory_error_func = dis_asm_memory_error;
di.print_address_func = dis_asm_print_address;
@@ -334,7 +344,6 @@
di.arch = gdbarch_bfd_arch_info (gdbarch)->arch;
di.mach = gdbarch_bfd_arch_info (gdbarch)->mach;
di.endian = gdbarch_byte_order (gdbarch);
- di.insn_sets = 0;
return di;
}
@@ -395,9 +404,8 @@
void
_initialize_disasm (void)
{
-
- INIT_DISASSEMBLE_INFO_NO_ARCH (deprecated_tm_print_insn_info, gdb_stdout,
- (fprintf_ftype)fprintf_filtered);
+ init_disassemble_info (&deprecated_tm_print_insn_info, gdb_stdout,
+ fprintf_disasm);
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;