xc32 static stack analyzer
I developed a static stack analyzer for Microchip's XC32 compiler, which can be found here:https://github.com/SentinelSw/MipsStaticStackAnalyzer
For an automotive project a pic32mz is used and the software for it is compiled with microchip's xc32. To comply with ASIL-B requirements from customer, we had to do a static memory analysis. Easy for flash and static RAM usage, as it is part of the map file. But what about the static stack usage?
After discussing this topic with Microchip directly, these were the results:
- XC32 is gcc based, but -fstack-usage is officially not supported and does not deliver reliable information. It is highly encouraged to NOT use this feature.
- XC32 does not have and will not have the possibility to report stack usage, neither on function basis nor on project basis.
- There is no additional Microchip tool or solution for measuring the stack usage statically.
- There is no 3rd party tool, which performs static code analysis for MIPS in general and xc32 in particular.
- If you want to know the stack usage of your program, you should measure it during runtime, i.e. with a high water mark (quoted microchip proposal) (Why this is a bad idea is a different discussion)
The topic came back onto my desk, and as I was not satisfied with Microchips information and proposals, I created my own tool for determining the stack usage, statically of course.
This tool should work for all MIPS gcc, but it is written especially for xc32. First feedback seems to show, that is might also work for C32.
Try it out, give it a shot! Bug tracking on GitHub, if you find any.
Sentinel Software GmbH