The lprof tool must have access to three kinds of files in order to produce profiling information.
When you run a profiled program. the name of the program is stored in the data file exactly as it appears on the command line. If you do not specify the -o option when you run lprof, it consults the data file to obtain the name of the program. Therefore, you may invoke lprof, specifying the name of the data file, and let lprof determine the name of the program. Because the name of the data file is not stored in the program itself, the reverse is not true: you cannot specify the name of the program and expect lprof to determine the name of the data file if it is not the default name.
The lprof tool will not be able to display data if you perform the following steps in the order shown:
When you run lprof from a directory other than the one in which you have executed your profiled program, and you have used a relative path name when executing the profiled program, then you must specify the -o option to lprof with either the profiled program's full pathname or the program's pathname relative to your current directory. The following example illustrates this:
$ cd $HOME $ mybin/a.out $ cd src $ lprof -o ../mybin/a.out -c ../a.out.cntIn this example, the -c is necessary because you are no longer in the directory where the program was run (and hence where the data file was created). The -o is necessary because otherwise lprof will look for an executable file called mybin/a.out in the current directory ($HOME/src). It is assumed in this example that the source files are in the current directory.
The names of the source files for the profiled program are also stored in the data file. However, only the file names, not the directories, are stored. Consequently when lprof searches for source files, it must assume that the source files are in the current directory. If they are in another directory, you must specify their location with the -I option and a path name.
The following example is a modified version of the previous one that demonstrates the use of -I. As before, assume that the source files are in the directory $HOME/src.
$ cd $HOME $ mybin/a.out $ cd doc $ lprof -o $HOME/mybin/a.out -c $HOME/a.out.cnt -I $HOME/srcIn this example, lprof is run from the directory $HOME/doc, but the source files are in $HOME/src.
You can specify multiple -I arguments.