This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: print_insn and streams
- To: Keith Seitz <keiths at cygnus dot com>
- Subject: Re: print_insn and streams
- From: "John R. Moore" <jmoore at redhat dot com>
- Date: Fri, 17 Aug 2001 15:15:12 -0700 (PDT)
- cc: <gdb at sources dot redhat dot com>
> printcmd.c currently defines print_insn as:
>
> static int
> print_insn (CORE_ADDR memaddr, struct ui_file *stream)
> {
> if (TARGET_BYTE_ORDER == BIG_ENDIAN)
> TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG;
> else
> TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE;
>
> if (TARGET_ARCHITECTURE != NULL)
> TARGET_PRINT_INSN_INFO->mach = TARGET_ARCHITECTURE->mach;
> /* else: should set .mach=0 but some disassemblers don't grok this */
>
> return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO);
> }
>
> Is there some reason that it is ignoring the parameter stream? Can it not
> just be set in the disasm info? (TARGET_PRINT_INSN_INFO->stream = stream;)
>
> Curious.
> Keith
When print_insn was first put in printcmd.c (-r1.108):
--------------------------------------------------------------
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns length of the instruction, in bytes. */
int
print_insn (memaddr, stream)
CORE_ADDR memaddr;
GDB_FILE *stream;
{
disassemble_info info;
#define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \
(INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \
(INFO).stream = (STREAM), \
(INFO).read_memory_func = dis_asm_read_memory, \
(INFO).memory_error_func = dis_asm_memory_error, \
(INFO).print_address_func = dis_asm_print_address, \
(INFO).insn_info_valid = 0
GDB_INIT_DISASSEMBLE_INFO(info, stream);
/* If there's no disassembler, something is very wrong. */
if (tm_print_insn == NULL)
abort ();
return (*tm_print_insn) (memaddr, &info);
}
-------------------------------------------
"stream" was used until -r1.124
revision 1.124
date: 1996/07/15 23:54:22; author: grossman; state: Exp; lines: +11 -8
* defs.h printcmd.c: Create global disassemble_info structure
tm_print_insn_info.
* gdbtk.c (gdb_disassemble): Setup di.mach from
tm_print_insn_info.mach, and set endian from TARGET_BYTE_ORDER.
* i386-tdep.c (set_assembly_language_command): set
tm_print_insn_info.mach to the appropriate value for 386 or 8086
disassembly.
* printcmd.c (print_insn): Move init of disassembler_info to
_initialize_printcmd. Set endian for disassembler here.
* sparc-tdep.c: Set tm_print_insn_info.mach as appropriate to
select sparc/sparclite.
* config/sparc/{tm-sparc.h tm-sparclite.h}: Get rid of
TM_PRINT_INSN. Set TM_PRINT_INSN_MACH to
bfd_mach_sparc/bfd_mach_sparc_sparclite.
---------
The parameter was left in rather than removing and fixing all the
routines that call it.
FWIW,
John