Page 1 of 1

tool to calculate task stack size

Posted: Fri Aug 31, 2018 1:45 pm
by davdav
Hi everybody,

I wonder if there is a tool based on .elf, .bin and .map after compilation and linkage which can calculate the stask size required by a task.

Around the forum when people ask about "stack overflow" the answer is typically: "try increase until you don't get "stack overflow"".

Any insight on this can be usefull.

Thanks

Re: tool to calculate task stack size

Posted: Fri Aug 31, 2018 1:50 pm
by urbanze
You can try analyze individual stack with High Water Mark: https://www.freertos.org/uxTaskGetStack ... rMark.html

Or using xTaskGetInfo() to see all stacks (HighWater Mark) together, you need active some settings in menuconfig to use this: https://www.freertos.org/vTaskGetInfo.html

Re: tool to calculate task stack size

Posted: Fri Aug 31, 2018 2:10 pm
by davdav
Thanks @urbanze,

I already use High Water Mark feature but it requires to flash and run the program. And you have to be sure to test cover all the branch program flow of the task.

I'm looking for an "offline" tool (if it exists) to use without downloading firmware to device. Something which says "Hey, the task XXX will crash for stack overflow" after I have compiled the program. I guess it can leverage on files genereted by the compiler/linker..

Re: tool to calculate task stack size

Posted: Fri Aug 31, 2018 2:37 pm
by fly135
davdav wrote:I'm looking for an "offline" tool (if it exists) to use without downloading firmware to device. Something which says "Hey, the task XXX will crash for stack overflow" after I have compiled the program. I guess it can leverage on files genereted by the compiler/linker..
Probably not going to find that. The tool would have to be able to parse the C/C++ code and intelligently look at all the local variables stored on the stack in a function. Then it would have to traverse into all the called functions and do the same. As soon as the tool hit a call into a function that was binary only with no source available it would fail to accurately compute stack requirements.

John A

Re: tool to calculate task stack size

Posted: Fri Aug 31, 2018 2:47 pm
by davdav
Exactly @fly135, you resume what was my sentiment. Your explanation about "binary only" functions makes sense and therefore stopped my hope.. Thanks