DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Analyzing run-time behavior

Invoking lprof

lprof correlates the data file with the profiled program to produce its report. By default, lprof expects the profiled program to be called a.out and the data file a.out.cnt. If the default names are used, and both the profiled program and the data file are in your current directory, you invoke lprof without arguments:

$ lprof

If the program and data file are in a different directory, you specify their paths relative to the current directory with the -o and -c options, respectively:

   $ lprof -o dir/a.out -c dir/a.out.cnt

To invoke lprof for a program with a name other than a.out, you specify its name after the -o option:

$ lprof -o travel

lprof will assume the data file is called travel.cnt.

You can also invoke lprof for the data file. You specify the name of the data file after the -c option:

$ lprof -c travel.cnt

The name of the profiled program is stored in the data file exactly as it appeared on the command line when the program was run. When the -c option is invoked, lprof consults the data file for the name of the profiled program. Even if run-time data has been written to a data file other than the default prog.cnt -- say, to a data file whose name you have specified in the PROFOPTS environment variable -- lprof will be able to determine the name of the profiled program with which the data file is to be correlated. Because the name of the data file is not stored in the profiled program, however, 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 other than prog.cnt.

The simplest way to invoke lprof is to specify the name of the data file and let lprof determine the name of the profiled program. However, because the name of the program is stored in the data file exactly as it appeared on the command line when it was run, lprof cannot access the profiled program if one of the following conditions occurs:

For example, when working in the directory /home/cur.dir, if you enter the commands

   $ cc -ql -o newprog newprog.c
   $ newprog
A data file called newprog.cnt is created in cur.dir. The data file contains the name of the profiled program exactly as it appeared on the command line when the program was run, newprog. Now you change directories to /home and enter the command

$ lprof -c cur.dir/newprog.cnt

lprof looks for newprog in the current directory and fails to find it:

   UX:lprof: ERROR: Unable to open file ./newprog/
To make sure that lprof can access both the data file and the profiled program, you should specify their paths relative to /home with the -c and -o options, respectively:

$ lprof -c cur.dir/newprog.cnt -o cur.dir/newprog

lprof now finds the profiled program but issues another error message:

   UX:lprof: WARNING:  cannot access newprog.c
   UX:lprof: ERROR: No source files found.
   

because the source file is also in cur.dir. The complete command uses the -I option to lprof to specify search directories in addition to the current directory for source or header files:
   lprof -I/home/cur.dir -c cur.dir/newprog.cnt -o cur.dir/newprog
or
   lprof -I cur.dir -c cur.dir/newprog.cnt -o cur.dir/newprog

Next topic: Searching for source files
Previous topic: Profiling programs that fork

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004