I need to profile code on a remote embedded target (running a cortex-m).
The only information available online is this blog. It explains a few things about the -pg flag:
- It generates call count code (gnu_mcount_nc)
- It samples the program and recursively distributes the time to the callers based on the call count.
The blog explains that these must be reimplemented in order to profile for the embedded target. What I don’t get is: what exactly is the code generated? What are those gnu_mcount_nc calls? What arguments do they get called with?
Where can I find any more information about the -pg flag? The gcc documentation on the subject is blackbox-like:
-p
-pg
Generate extra code to write profile information suitable for the analysis program prof (for -p) or gprof (for -pg). You must use this option when compiling the source files you want data about, and you must also use it when linking.
You can use the function attribute no_instrument_function to suppress profiling of individual functions when compiling with these options. See Common Function Attributes.
Finally: since I want to profile the embedded code, what functions do I need to implement in order to correctly profile the code? Is there only gnu_mcount_nc
and a sampler?
Bottom note: I’ve read quite a lot that gprof is not a great profiling choice, I am however very limited, wanting to profile an embedded system. However, if you have any other idea, please tell me.