public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* objdump.c calls which do not use internal text streams
@ 2003-03-16  1:07 J. Grant
  2003-03-17 11:16 ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: J. Grant @ 2003-03-16  1:07 UTC (permalink / raw)
  To: binutils

Hello,

In objdump.c I have noticed printf() used here when such effort is is 
generally made to send all output through the 2 streams configured setup 
in INIT_DISASSEMBLE_INFO().  Is this an exception? Personally I would 
rather just use fprintf(stdout, ""); etc but there seems to be some 
effort to use the streams setup internally.


disassemble_data (abfd)

	  if (! prefix_addresses)
	    {
	      printf ("\n");


Please include my email address in any replies.

Cheers

JG

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: objdump.c calls which do not use internal text streams
  2003-03-16  1:07 objdump.c calls which do not use internal text streams J. Grant
@ 2003-03-17 11:16 ` Nick Clifton
  2003-03-19 12:47   ` J. Grant
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2003-03-17 11:16 UTC (permalink / raw)
  To: J. Grant; +Cc: binutils

Hi JG,

> In objdump.c I have noticed printf() used here when such effort is
> is generally made to send all output through the 2 streams
> configured setup in INIT_DISASSEMBLE_INFO().  Is this an exception?

No it is a bug.  I am applying the patch below to fix it.

Cheers
         Nick

2003-03-17  Nick Clifton  <nickc@redhat.com>

	* objdump.c (disassemble_data): Use disasm_info.fprintf_func not
	printf for emitting new lines.

Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.62
diff -c -3 -p -w -r1.62 objdump.c
*** binutils/objdump.c	13 Feb 2003 09:53:07 -0000	1.62
--- binutils/objdump.c	17 Mar 2003 11:14:27 -0000
*************** disassemble_data (abfd)
*** 1728,1739 ****
  
  	  if (! prefix_addresses)
  	    {
! 	      printf ("\n");
  	      objdump_print_addr_with_sym (abfd, section, sym,
  					   section->vma + addr_offset,
  					   &disasm_info,
  					   FALSE);
! 	      printf (":\n");
  	    }
  
  	  if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset)
--- 1728,1739 ----
  
  	  if (! prefix_addresses)
  	    {
! 	      (* disasm_info.fprintf_func) (disasm_info.stream, "\n");
  	      objdump_print_addr_with_sym (abfd, section, sym,
  					   section->vma + addr_offset,
  					   &disasm_info,
  					   FALSE);
! 	      (* disasm_info.fprintf_func) (disasm_info.stream, ":\n");
  	    }
  
  	  if (sym != NULL && bfd_asymbol_value (sym) > section->vma + addr_offset)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: objdump.c calls which do not use internal text streams
  2003-03-17 11:16 ` Nick Clifton
@ 2003-03-19 12:47   ` J. Grant
  2003-03-19 15:48     ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: J. Grant @ 2003-03-19 12:47 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hi Nick,

Thanks for correcting this.

Could you tell me why objdump uses printf/fprintf this way please? I
have not seen any way to redirect output to a file etc.

fprintf_func is always fprintf and stream is always stdout from what I
have seen [it is even set again in code other than
INIT_DISASSEMBLE_INFO()].  I have not seen any args that would change
this either.  It makes the code less readable having to have (*
disasm_info.fprintf_func)
(disasm_info.stream, "\n"); if any extra functionality from having this
way is not used IMO.

Normally I make my code in keeping with the formating style of the
current src's. However, I do not find the GNU coding standards as
perfect in some respects IMO. Does someone run indent on
the binutils src's to maintain the formating?

It would be more hassle coding in my own style then converting back to
GNU style though. So I will probably just write my code in GNU style...


Regards

JG




on the 17/03/03 11:16, Nick Clifton wrote:
> Hi JG,
> 
>> In objdump.c I have noticed printf() used here when such effort is
>> is generally made to send all output through the 2 streams
>> configured setup in INIT_DISASSEMBLE_INFO().  Is this an exception?
> 
> No it is a bug.  I am applying the patch below to fix it.
> 





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: objdump.c calls which do not use internal text streams
  2003-03-19 12:47   ` J. Grant
@ 2003-03-19 15:48     ` Nick Clifton
  2003-03-19 17:17       ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2003-03-19 15:48 UTC (permalink / raw)
  To: J. Grant; +Cc: binutils

Hi JG,

> Could you tell me why objdump uses printf/fprintf this way please? I
> have not seen any way to redirect output to a file etc.

It is used in objdump.c:disassemble_bytes() to encapsulate the
printing function when calling the external 'disassemble_fn' code.
The actual need for this is probably historical, although it does make
for a reasonably clean interface.  ie the disassembly code does not
have to worry about file redirection, it can just use the fprintf_func
in the info structure.  If file redirection is ever needed then it can
be handled by the code in objdump itself.

> Normally I make my code in keeping with the formating style of the
> current src's. However, I do not find the GNU coding standards as
> perfect in some respects IMO. Does someone run indent on
> the binutils src's to maintain the formating?

No - the style is maintained on an ad hoc basis.


Cheers
        Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: objdump.c calls which do not use internal text streams
  2003-03-19 15:48     ` Nick Clifton
@ 2003-03-19 17:17       ` Ian Lance Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2003-03-19 17:17 UTC (permalink / raw)
  To: Nick Clifton; +Cc: J. Grant, binutils

Nick Clifton <nickc@redhat.com> writes:

> > Could you tell me why objdump uses printf/fprintf this way please? I
> > have not seen any way to redirect output to a file etc.
> 
> It is used in objdump.c:disassemble_bytes() to encapsulate the
> printing function when calling the external 'disassemble_fn' code.
> The actual need for this is probably historical, although it does make
> for a reasonably clean interface.  ie the disassembly code does not
> have to worry about file redirection, it can just use the fprintf_func
> in the info structure.  If file redirection is ever needed then it can
> be handled by the code in objdump itself.

The dissassemblers in the opcodes directory are also used by gdb, and
gdb sets fprintf_func to a gdb function which does `more' processing.
So the disassemblers need to use fprintf_func.

objdump itself doesn't need to use fprintf_func.  But it's probably
cleaner to do so.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-03-19 17:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-16  1:07 objdump.c calls which do not use internal text streams J. Grant
2003-03-17 11:16 ` Nick Clifton
2003-03-19 12:47   ` J. Grant
2003-03-19 15:48     ` Nick Clifton
2003-03-19 17:17       ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).