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/RFA: Disassembler mixes filtered and unfiltered output


The disassembler code in gdb_disassemble_info() initializes the
disassemble_info structure to use fprintf_unfiltered().  However, it
also sets the print_address function in that struct to use
print_address(), which does filtered output.  The effect is that
disassembly will mix filtered and unfiltered output.

This is bad, because filtered output is buffered until the end of the
line, while unfiltered output is printed immediately.

This will only be visible when disassembling an instruction which
prints an address which is not at the end of a line.  In that case,
the address will be filtered, and the text which should follow it on
the line will instead precede it.  Such instructions are uncommon.
The disassemblers typically only print an address when it is the
target of a jump or call instruction.  Such addresses normally occur
at the end of the instruction.

This worked correctly a while back, because disassemble_command()
would call print_insn(), and print_insn() would use the global
tm_print_insn_info, which was initialized using fprintf_filtered().
In fact, tm_print_insn_info is still initialized correctly, in
_initialize_disasm().  However, disassemble_command() no longer uses
the global variable, and, in fact, print_insn() doesn't either.

This patch fixes the problem.  I ran the testsuite on i386 GNU/Linux,
where it caused no regressions.

Ian


2003-05-14  Ian Lance Taylor  <ian@airs.com>

	* disasm.c (gdb_disassemble_info): Initialize disassemble_info
	with fprintf_filtered, not fprintf_unfiltered.


Index: disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/disasm.c,v
retrieving revision 1.9
diff -p -u -r1.9 disasm.c
--- disasm.c	3 May 2003 19:13:03 -0000	1.9
+++ disasm.c	14 May 2003 21:15:12 -0000
@@ -315,7 +315,7 @@ gdb_disassemble_info (struct gdbarch *gd
 {
   disassemble_info di;
   INIT_DISASSEMBLE_INFO_NO_ARCH (di, file,
-				 (fprintf_ftype) fprintf_unfiltered);
+				 (fprintf_ftype) fprintf_filtered);
   di.flavour = bfd_target_unknown_flavour;
   di.memory_error_func = dis_asm_memory_error;
   di.print_address_func = dis_asm_print_address;


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