Displays object file profile data.
prof [ -t | -c | -a | -n ] [ -o | -x ] [ -g ] [ -z ] [ -h ] [ -s ] [ -S ] [ -v ] [ -L PathName ] [ Program ] [ -m MonitorData ... ]
The prof command interprets profile data collected by the monitor subroutine for the object file Program (a.out by default). It reads the symbol table in the object file Program and correlates it with the profile file (mon.out by default). The prof command displays, for each external text symbol, the percentage of execution time spent between the address of that symbol and the address of the next, the number of times that function was called, and the average number of milliseconds per call.
Note: Symbols from C++ object files have their names demangled before they are used.
To tally the number of calls to a function, you must have compiled the file using the cc command with the -p flag. The -p flag causes the compiler to insert a call to the mcount subroutine into the object code generated for each recompiled function of your program. While the program runs, each time a parent calls a child function the child calls the mcount subroutine to increment a distinct counter for that parent-child pair. Programs not recompiled with the -p flag do not have the mcount subroutine inserted and therefore keep no record of which function called them.
The -p flag also arranges for the object file to include a special profiling startup function that calls the monitor subroutine when the program begins and ends. The call to the monitor subroutine when the program ends actually writes the mon.out file. Therefore, only programs that explicitly exit or return from the main program cause the mon.out file to be produced.
The location and names of the objects loaded are stored in the mon.out file. If you do not select any flags, prof will use these names. You must specify a program or use the -L option to access other objects.
Note: Imported external routine calls, such as a call to a shared library routine, have an intermediate call to local glink code that sets up the call to the actual routine. If the timer clock goes off while running this code, time is charged to a routine called routine.gl, where routine is the routine being called. For example, if the timer goes off while in the glink code to call the printf subroutine, time is charged to the printf.gl routine.
The mutually exclusive flags
a, c, n, and t determine how
the prof command sorts the output lines:
-a | Sorts by increasing symbol address. |
-c | Sorts by decreasing number of calls. |
-n | Sorts lexically by symbol name. |
-t | Sorts by decreasing percentage of total time (default). |
Note: The prof command can still run successfully if you use more than one of flags a, c, n, and t in the same command. The prof command accepts the first of these flags it encounters on the command line and ignores the others.
The mutually exclusive flags
o and x specify how to display the address of each
symbol monitored.
-o | Displays each address in octal, along with the symbol name. |
-x | Displays each address in hexadecimal, along with the symbol name. |
Note: The prof command can still run successfully if you use both the -o and -x flags in the same command. The prof command accepts the first of these two flags it encounters on the command line and ignores the other flag.
Use the following flags in any
combination:
prof -t -h
prof -x -L/home/score/lib runfile -m runfile.mon
mon.out | Default profile. |
a.out | Default object file. |
mon.sum | Summary profile. |
The cc command, nm command, gprof command.
The exit subroutine, profil subroutine, monitor subroutine.
The Commands Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.
The Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.