Next: , Up: Profiling an Ada Program with gprof


25.2.1 Compilation for profiling

In order to profile a program the first step is to tell the compiler to generate the necessary profiling information. The compiler switch to be used is -pg, which must be added to other compilation switches. This switch needs to be specified both during compilation and link stages, and can be specified 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.