Am 14.11.2011 19:15, schrieb Sergio Campamá:
> Hello,
> 
> I'm developing an app that uses heavily printf for debugging... Now, when
> activated (through a DEBUG macro), the app crashes very rapidly, being
> random the moment it crashes (almost always it crashes mid sentence)...

crashes often happen when memory gets overwritten...
either some buffer overflow or more common, stack overflow.
a stack overflow is when the stack gets too large and starts overwriting
the heap (if you're using it - i would not) or variables.

calls to printf put the arguments on the stack and itself uses a couple
of bytes on the stack. you should leave enough free RAM.

also note that the older printf in mspgcc 3.2.3 has a limitation of max.
20 characters when using "%s". the latest version in the 4.x series does
not have any limitation.

> I just found this page:
> http://processors.wiki.ti.com/index.php/Tips_for_using_printf
> 
> How much of it correlates to the way mspgcc handles printf? Is it the same?
> Can I use the same techniques for using static memory for printf?
>
> Basically, i want to use this (I'm trying to extract the most important
> info of the page)
> 
> char static_array[20];
> setvbuf(stdout, static_array, _IOLBF, sizeof(static_array));
> 
> Does this work on mspgcc?

no. mspgcc's printf just calls a function named "putchar" you can
implement that function to do what you want.

(there is also uprintf which accepts a function pointer so that you can
use your own functions instead of putchar).

chris

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to