How to debug C Library functions?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to debug C Library functions?

2,364 Views
0815
Contributor II

I have strange 'behavior' of the printf library function here. The first call of it with some string replacement (I mean something like printf("\n%s\n", string)) results in some crazy output.

I would like to debug the function, but how can I load the symbols of the library (and from where)? Or do I need to build the library for myself?

 

I'm using S32 Design Studio, the controller is a S9KEAZ128. So far, I tested both newlib and newlib-nano.

 

Any help is appreciated!

Labels (1)
3 Replies

1,748 Views
BlackNight
NXP Employee
NXP Employee

Yes, I think you need to rebuild the library with debug information enabled. I did this for the Kinetis parts (see GNU Libs with Debug Information: Rebuilding the GNU ARM Libraries | MCU on Eclipse ), but I have to tell that this is rather painful.

If you get some cracy output: are you using a physical UART or semihosting for the output? as printf() and family is using a lot of stack, I recommend that you increase the stack size (say 3 or 4 KB) to rule out a possible stack overflow.

I hope this helps,

Erich

1,748 Views
0815
Contributor II

Thanks for the response!

But after reading your article I'm really not sure whether I'm wanna do this...

However, I already thought on a stack issue and increased stack (and heap) up to 6 KB each. And yes, I'm using physical UART (together with PE ConsoleIO component).

I also tried the semihosting but didn't see any output on the Semihosting Console...

Any other ideas?

0 Kudos

1,748 Views
0815
Contributor II

Whilst I'm still away from a solution, I know a little bit more about this: The 'strange' output I see is some earlier printf output from my software at startup time. For me it seems some of the data is written into a buffer and keeps there as long as there is no other printf. But as soon as I trigger a new printf (with string replacement), first the buffer will go to UART and after this my newest printf output.

I thought the nano library doesn't use buffers for output?

0 Kudos