I can calculate stack space used by any my function using compiler annotations in asm listings. But I can't know how much of stack is used by library functions because they are already compiled. Is there any means to get such information?
Unfortunately there is no easy way to determine the stack usage for each individual standard library function. You'd have to examine each library function manually, which could be quite a tedious task.
Since this information is not available, you want to determine your application's maximum stack usage. I've attached a file you can add to your project which will override _install_default_handlers() routine to initialize the entire stack memory region to the pattern 0x55555555 before main() is executed, you can then call get_stack_usage() (which searches this region of memory from top to bottom for the first non 0x55555555 value) to return your maximum stack usage in bytes at any particular point.
Is this any use to you at all? If not could you elaborate further on the reasons why you need to know each function's stack usage, perhaps there's another way to achieve what you want without knowing this.
Thank you Sean. Your idea is clear, but this method may fault if some local variable will have such value. And I would like to know stack usage before runtime. Some tools from other microcontroller's or toolchain vendors give a listing with per-function stack consumption, so I used to use this information.
I use multitask kernel and have to calculate stack for each task.
May be someone else can share his experience in this problem?
Of course you're correct, I neglected to mention that 0x55555555 was simply an easily recognisable pattern I selected (I was thinking "sssssssstack" ) and that this could present problems should your program push such a value to the stack.
Unfortunately though we do not document stack usage for our library functions, so it looks like you could be stuck making conservative estimates. You could take a look at the sources for the DSP functions written in assembly (VDSP_Location/Blackfin/lib/src/libdsp/) since we tend to track their stack usage in comments. Sorry I've not been able to be more helpful, I can see that such information would be quite useful and for what it's worth I'll suggest that we look into providing it in the future in some form - however this would be quite a long while off even if approved.
Ok. But if there isn't simple way to calculate needed size of stack, maybe there is another aproach to keep control on the stack?
I understand that your additional questions have been addressed through private support, so we can discontinue this thread.
Retrieving data ...