Replacing or disabling "printf" calls

Ralf Corsepius ralf.corsepius at rtems.org
Mon Oct 17 17:15:25 UTC 2011


On 10/17/2011 05:37 PM, Joel Sherrill wrote:
> On 10/17/2011 7:31 AM, Ralf Corsepius wrote:
>> On 10/17/2011 02:12 PM, Rafael Morales wrote:
>>> Hello everyone,
>>>
>>> We are working in a space project using RTEMS and we are worried about
>>> program sizes.
>>>
>>> Reviewing the map file of a sample program using MIL-STD-1553B and
>>> spacewire driver, we have found :
>>>
>>> 9460 bytes used by lib_a-vfprinft.o
>>> 9192 bytes used by lib_a-svfprintf.o
>>>
>>>
>>> Almost 18KB for printing it a lot!
>> This actually is very little!
> When you are on a PC with GBs of memory, it is.

We are talking about 18kB of very compact, shared code.

It you systematically apply "fprintf" instead of a zoo of "custom 
printfs", "puts" etc. you are likely to spare memory.

(In newlib most *printf* are lean wrappers on very few, and small 
functions).

>>> We are not using "printf" in main program, but we have found it in the
>>> source file of MIL-STD-1553B and spacewire driver.
>>> Those drivers was originally compiled with RTEMS and are linked with the
>>> main program in any compilation.
>> Are these source files part of the RTEMS source tree?
>>
>> If yes, which files are you referring to?
>> If no, ... c.f. below.
> This is an important point
>>> Can any one help us to replace or disable that "printf" calls?
>> The only option to get rid of printf is to replace all references to it
>> from all code you are using.
> If it is in a driver, it is almost certainly debug or status code and
> probably should be
> printk(). But without seeing the code, I don't know.
>> In most cases, this is hardly possible without fundamentally breaking
>> the code.
> Not if it is just debug.

And sprintf, vsprint, vnsprint etc.

Ralf




More information about the users mailing list