Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lprof(CP) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(CP)

fork(S)

prof(CP)

tmpnam(S)


 lprof(CP)                      6 January 1993                      lprof(CP)


 Name

    lprof - display line-by-line execution count profile data

 Syntax

    lprof [-p] [-s] [-x] [[-I incdir]] [[-r srcfile]] [-c cntfile] [-o prog]
    lprof -m file1.cnt file2.cnt [... filen.cnt] [-T] -d destfile.cnt

 Description

    lprof is a tool for dynamic analysis; that is, the analysis of a program
    at run time.  Specifically, lprof identifies the most frequently executed
    parts of source code and parts of code that are never executed.

    lprof interprets a profile file (prog.cnt by default) produced by the
    profiled program prog (a.out by default) that has been compiled with the
    -ql option of cc(CP) or rcc(CP).  This cc command option arranges for
    code to be inserted to record run-time behavior and for data to be writ-
    ten to a file at the end of execution.

    By default, lprof prints a listing of source files, the names of which
    are stored in the symbol table of the executable file.  Each line pre-
    ceded by its line number and the number of times it was executed.

 Options

    The following options may appear singly or be combined in any order:

    -p  Print listing, each line preceded by the line number and the number
        of times it was executed (default).  This option can be used together
        with the -s option to print both the source listing and summary in-
        formation.

    -s  Print summary information of percentage of lines of code executed per
        function.

    -x  Instead of printing the execution count numbers for each line, print
        each line preceded by its line number and a [U] if the line was not
        executed.  If the line was executed, print only the line number.

    -I incdir
        Look for source or header files in the directory incdir in addition
        to the current directory and the standard place for #include files
        (usually /usr/include).  You can specify more than one directory with
        -I on the command line.

    -r srcfile
        Instead of printing all source files, print only those files named in
        -r options (to be used with the -p option only).  You can specify
        multiple files with -r on one command line.

    -c cntfile
        Use the file cntfile instead of prog.cnt as the input profile file.

    -o prog
        Profile the program prog instead of the name used when creating the
        profile file.  Because the program name stored in the profile file
        contains the relative path, this option is necessary if the execut-
        able file or profile file has been moved.

    Merging data files

    lprof can also be used to merge data files.  The -m option must be accom-
    panied by the -d option:

    -m file1.cnt file2.cnt [filen.cnt] -ddestfile.cnt
        Merge the data files file1.cnt through filen.cnt by summing the exe-
        cution counts per line, so that data from several runs can be accumu-
        lated.  The result is written to destfile.cnt.  The data files must
        contain profiling data for the same prog (see the -T option below).

    -T  Time stamp override.  Normally, the time stamps of the executable
        files being profiled are checked, and data files will not be merged
        if the time stamps do not match.  If -T is specified, this check is
        skipped.

    Controlling the run time profiling environment

    lprof uses the environment variable PATH to locate the correct full path-
    name of the executable, for example, ../../file has an explicit pathname,
    but file does not.  The environment variable PROFOPTS provides run-time
    control over profiling.  When a profiled program is about to terminate,
    it examines the value of PROFOPTS to determine how the profiling data is
    to be handled.

    The environment variable PROFOPTS is a comma-separated list of options
    interpreted by the program being profiled.  If PROFOPTS is not defined in
    the environment, then the default action is taken: the profiling data is
    saved in a file (with the default name, prog.cnt) in the current direc-
    tory.  If PROFOPTS is set to the null string, no profiling data is saved.
    The following are the available options:

    msg=[yn]
       If msg=y is specified, a message stating that profile data is being
       saved is printed to standard error.  If msg=n is specified, print only
       profiling error messages.  The default is msg=y.

    merge=[yn]
       If merge=n is specified, do not merge data files after successive
       runs.  The data file is overwritten after each execution.  If merge=y
       is specified, the data will be merged.  The merge will fail if the
       program has been recompiled; the data file will be left in TMPDIR.
       The default is merge=n.

    pid=[yn]
       If pid=y is specified, the name of the data file will include the pro-
       cess ID of the profiled program.  This allows the creation of dif-
       ferent data files for programs calling fork(S).  If pid=n is speci-
       fied, the default name is used.  The default is pid=n.

    dir=dirname
       Place the data file in the directory dirname if this option is speci-
       fied.  Otherwise, the data file is created in the directory that is
       current at the end of execution.

    file=filename
       Use filename as the name of the data file in dir created by the pro-
       filed program if this option is specified.  Otherwise, the default
       name is used.

 Files


    prog.cnt    For profile data.

    TMPDIR/*    Temporary files.

                TMPDIR is usually /usr/tmp, but can be redefined by setting
                the environment variable TMPDIR (see tempnam() in tmpnam(S)).

 Warnings

    For the -m option, if destfile.cnt exists, its previous contents are de-
    stroyed.

    Optimizing functions may result in the loss of some line number informa-
    tion and may result in code motions, both of which may make lprof infor-
    mation unreliable.

 See also

    cc(CP), fork(S), prof(CP), tmpnam(S)


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026