6.2.1.1 Compilation for profiling

In order to profile a program, you must first to tell the compiler to generate the necessary profiling information. You do this using the compiler switch -pg, which you must add to other compilation switches. You need to specify this switch during compilation and link stages, and you can specified it only once when using gnatmake:

$ gnatmake -f -pg -P my_project

Note that only the objects that were compiled with the -pg switch will be profiled; if you need to profile your whole project, use the -f gnatmake switch to force full recompilation.

Note that on Windows, gprof does not support PIE. You should add the -no-pie switch to the linker flags to disable PIE.