home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / REF102.ZIP / REF.DOC < prev    next >
Text File  |  1991-09-24  |  69KB  |  1,882 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                                        REF 1.0
  14.                                      User's Guide
  15.                              Shareware Evaluation Version
  16.  
  17.  
  18.  
  19.                                The Cove Software Group
  20.                                     P.O. Box 1072
  21.                                   Columbia, MD 21044
  22.                                     (301) 992-9371
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                                     Version 1.02
  35.                                    September, 1991
  36.                       Copyright (C) 1991 The Cove Software Group
  37.                                  All Rights Reserved
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.                                   Table of Contents
  46.  
  47.  
  48.           1 Introduction  . . . . . . . . . . . . . . . . . . . . . . .   1
  49.                1.1 What is REF? . . . . . . . . . . . . . . . . . . . .   1
  50.                1.2 Registration . . . . . . . . . . . . . . . . . . . .   1
  51.                1.3 Getting started  . . . . . . . . . . . . . . . . . .   2
  52.                     1.3.1 System requirements . . . . . . . . . . . . .   2
  53.                     1.3.2 Printing the User's Guide . . . . . . . . . .   2
  54.                     1.3.3 Installing PWBRMAKE . . . . . . . . . . . . .   2
  55.                     1.3.4 Installing REF  . . . . . . . . . . . . . . .   4
  56.  
  57.           2 Preparing for REF . . . . . . . . . . . . . . . . . . . . .   5
  58.                2.1 Manual preparation . . . . . . . . . . . . . . . . .   5
  59.                2.2 Using NMAKE  . . . . . . . . . . . . . . . . . . . .   6
  60.  
  61.           3 Using REF . . . . . . . . . . . . . . . . . . . . . . . . .   8
  62.                3.1 REF services . . . . . . . . . . . . . . . . . . . .   8
  63.                3.2 Symbol types, attributes, instances  . . . . . . . .   9
  64.                3.3 Running REF  . . . . . . . . . . . . . . . . . . .    10
  65.                     3.3.1 Syntax  . . . . . . . . . . . . . . . . . .    10
  66.                     3.3.2 Specifying the input file . . . . . . . . .    11
  67.                     3.3.3 Specifying options  . . . . . . . . . . . .    11
  68.                          3.3.3.1 File suppression (/Ex) . . . . . . .    11
  69.                          3.3.3.2 Standard format (/S) . . . . . . . .    12
  70.                     3.3.4 Specifying symbol names . . . . . . . . . .    12
  71.                     3.3.5 Specifying actions  . . . . . . . . . . . .    13
  72.                     3.3.6 Specifying symbol-type filters  . . . . . .    15
  73.                     3.3.7 Specifying attribute filters  . . . . . . .    15
  74.  
  75.           4 Reports . . . . . . . . . . . . . . . . . . . . . . . . .    17
  76.                4.1 Cross-reference (/X) . . . . . . . . . . . . . . .    18
  77.                     4.1.1 REF format  . . . . . . . . . . . . . . . .    18
  78.                     4.1.2 Standard (/S) format  . . . . . . . . . . .    20
  79.                4.2 Call trees (/T, /Tx) . . . . . . . . . . . . . . .    21
  80.                     4.2.1 Forward call trees (/T) . . . . . . . . . .    21
  81.                     4.2.2 Subtrees and levels . . . . . . . . . . . .    22
  82.                     4.2.3 Recursion . . . . . . . . . . . . . . . . .    22
  83.                     4.2.4 Indirect calls  . . . . . . . . . . . . . .    23
  84.                     4.2.5 Symbols required  . . . . . . . . . . . . .    24
  85.                     4.2.6 Reverse call trees  . . . . . . . . . . . .    24
  86.                4.3 Calls, Called-by (/C, /Cx) . . . . . . . . . . . .    25
  87.                4.4 Uses, used-by (/U, /Ux)  . . . . . . . . . . . . .    25
  88.                4.5 Modules (/M) . . . . . . . . . . . . . . . . . . .    26
  89.                4.6 Unreferenced symbols (/N)  . . . . . . . . . . . .    27
  90.                4.7 Outline (/O) . . . . . . . . . . . . . . . . . . .    28
  91.                4.8 Dump (/D, /Dm, /Ds)  . . . . . . . . . . . . . . .    29
  92.  
  93.           Appendix A: Error Messages  . . . . . . . . . . . . . . . .    31
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.           1 Introduction
  103.  
  104.           1.1 What is REF?
  105.  
  106.           REF is a utility that can provide considerable information about
  107.           projects developed with the Microsoft (R) Professional
  108.           Development System (PDS) running under DOS or OS/2.  REF provides
  109.           information about functions, variables, macros, and other symbols
  110.           in a variety of formats, including cross references, uses/used-by
  111.           tables, call trees, etc.  It is especially useful for projects
  112.           developed using multiple languages (C and assembler, for example)
  113.           because it is language independent and makes no attempt at
  114.           source-parsing parsing is handled by the language processor
  115.           itself.
  116.  
  117.           REF is currently compatible with the following languages (all are
  118.           Microsoft products):
  119.  
  120.                ∙ BASIC 7.10
  121.                ∙ C 6.0
  122.                ∙ COBOL 4.0
  123.                ∙ Fortran 5.1
  124.                ∙ Macro Assembler 6.0
  125.  
  126.           REF will automatically be compatible with revisions of these
  127.           products and with other languages (such as Pascal) if and when
  128.           they are released in PDS versions.
  129.  
  130.  
  131.           1.2 Registration
  132.  
  133.           After many years of providing free software for public use (over
  134.           seventy-five programs before we lost track), we are bowing to
  135.           reality and releasing REF as our first shareware offering.
  136.  
  137.           If you continue to use REF after a reasonable evaluation period,
  138.           you are required to register your use with us and pay a modest
  139.           license fee.  There are two levels of registration:
  140.  
  141.                $20 - basic registration.  You receive the current version
  142.                of REF without the shareware information screen, and a paid
  143.                invoice.
  144.  
  145.                $35 - full registration.  You receive the above plus a
  146.                typeset copy of the manual, a Microsoft QuickHelp-compatible
  147.                help file, and a free upgrade to the next release of REF.
  148.  
  149.           The shareware evaluation package is not "crippled" in any way.
  150.           No features are disabled, and the documentation file is complete.
  151.           The registered version of REF.EXE is identical except that it
  152.           does not display the shareware information.
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.                                                        1.2: Registration  2
  161.  
  162.           Please see the REGISTER.DOC and LICENSE.DOC for registraion
  163.           forms, licenses and warranty, etc.
  164.  
  165.  
  166.           1.3 Getting started
  167.  
  168.           1.3.1 System requirements
  169.  
  170.           REF requires DOS 2.0 or later, or OS/2.
  171.  
  172.           To use REF, you must develop your projects using Microsoft's
  173.           "Professional Development System" languages.  These include the
  174.           products listed section 1.1 and are the Microsoft products with
  175.           which are included the Programmer's Workbench (PWB).  You do NOT
  176.           have to install or use the PWB in order to make full use of REF,
  177.           but you must have a PWB-compatible version of the language
  178.           compiler or assembler.
  179.  
  180.           If you develop a project in mixed languages and not all of the
  181.           languages are PWB-compatible (say, Microsoft C 6.0 with MASM 5.x
  182.           or Borland's TASM), you can use REF on the PWB-compatible portion
  183.           of the project.
  184.  
  185.  
  186.           1.3.2 Printing the User's Guide
  187.  
  188.           To print the User's Guide, simply turn on your printer and type
  189.  
  190.                COPY [d:path]REF.DOC PRN
  191.  
  192.           where d:path, of course, represents the drive and directory that
  193.           contains REF.DOC (this file).
  194.  
  195.  
  196.           1.3.3 Installing PWBRMAKE
  197.  
  198.           Although REF does not require that the PWB be installed, it does
  199.           require one PWB-related program, namely, PWBRMAKE.EXE. If you do
  200.           not have PWBRMAKE.EXE on your fixed disk, you must first install
  201.           it.
  202.  
  203.           Before you start, decide where you are going to put PWBRMAKE.
  204.           PWBRMAKE is a bound (family mode) executable that will run under
  205.           either DOS or OS/2, so it will usually go into the BINB directory
  206.           (\C\BINB, \MASM\BINB, etc.) along with LINK and LIB.
  207.  
  208.  
  209.           Installing PWBRMAKE from SETUP
  210.  
  211.           First, locate the "SETUP" or "INSTALLATION" diskette for your
  212.           Microsoft language product.  Insert the disk in your diskette
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.                                                     1.3: Getting started  3
  221.  
  222.           drive and make that drive the current drive; type SETUP and press
  223.           Enter.  Look for a menu option that reads something like:
  224.  
  225.                Copy a file from the distribution disk
  226.  
  227.           If there is no such option, exit SETUP and follow the alternate
  228.           instructions below.
  229.  
  230.           Select the "copy" option and follow the prompts.  In most
  231.           versions of SETUP, the first prompt will request the name of the
  232.           file to be copied ("PWBRMAKE.EXE") and the second prompt will ask
  233.           the name of the directory to which you want the file copied.
  234.           After you've responded to both prompts, SETUP will install the
  235.           program for you; exit SETUP when you're done and put the SETUP
  236.           diskette away.
  237.  
  238.  
  239.           Alternate instructions
  240.  
  241.           If your version of SETUP does not include an option to install a
  242.           single file, follow these instructions to install PWBRMAKE
  243.           manually.  Your SETUP disk should still be in the diskette drive,
  244.           of course.
  245.  
  246.                1. Find and view the file PACKING.LST on the setup diskette.
  247.                Locate the entry for PWBRMAKE.EXE; this will tell you which
  248.                diskette and directory contains the PWBRMAKE program.  Make
  249.                a note of this information.
  250.  
  251.                2. If PWBRMAKE is not located on the setup diskette:
  252.  
  253.                     a. Copy the program DECOMP.EXE from the setup diskette
  254.                     to a working directory on your fixed disk.
  255.  
  256.                     b. Remove the setup diskette and insert the PWBRMAKE
  257.                     diskette.
  258.  
  259.                3. Install the compressed file PWBRMAKE.EX$ from the
  260.                diskette by running the DECOMP program.  Just type
  261.  
  262.                     DECOMP
  263.  
  264.                and, at the first DECOMP prompt, enter
  265.  
  266.                     d:path\pwbrmake.ex$
  267.  
  268.                where 'd:path' is the installation drive and directory that
  269.                contains PWBRMAKE (usually A:\BINB).  Note that the filename
  270.                extension is EX$, not EXE.
  271.  
  272.                At the second DECOMP prompt, enter:
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.                                                     1.3: Getting started  4
  281.  
  282.                     d:path\pwbrmake.exe
  283.  
  284.                where d:path represents the drive and directory you have
  285.                selected for permanent storage of PWBRMAKE.  DECOMP will
  286.                decompress PWBRMAKE and store it in the directory you
  287.                specified.
  288.  
  289.                4. Installation of PWBRMAKE is now complete.  If you copied
  290.                DECOMP from the diskette to your fixed disk in step 3, you
  291.                can erase it if you wish.
  292.  
  293.  
  294.           1.3.4 Installing REF
  295.  
  296.           If you're writing programs for DOS or OS/2, we're going to assume
  297.           that you know how to copy files, so this will be simple.
  298.  
  299.           You should have received all of the following files:
  300.  
  301.                PACKING.LST         A list of files that should be included
  302.                REGISTER.DOC   Registration information
  303.                LICENSE.DOC         License/redistribution information
  304.                WARRANTY.DOC   Warranty information
  305.                REF.EXE        The REF program (DOS version)
  306.                REFP.EXE       The REF program (OS/2 version)
  307.                REF.DOC        This document
  308.                DEMO1.C        First module of a simple demo "project"
  309.                DEMO2.C        Second module of the demo
  310.                DEMO.MAK       Make file for making the demo
  311.                DEMO.BSC       Browser database for demo
  312.  
  313.           If any of these files are missing, you have not received the
  314.           complete package, which is a violation of our redistribution
  315.           agreement.  Please contact your source and request that they
  316.           obtain the complete evaluation package before distributing it.
  317.  
  318.           Installation is simply a matter of copying REF.EXE (DOS) and/or
  319.           REFP.EXE (OS/2) to appropriate working directories. We suggest
  320.           that you keep REF in the same directory as the DOS or OS/2
  321.           versions of your compiler or assembler (or perhaps with CodeView
  322.           and other language tools).  For example:
  323.  
  324.                COPY REF.EXE C:\C\BINB
  325.                           COPY REFP.EXE C:\C\BINP
  326.  
  327.                NOTE: the DOS and OS/2 versions of REF 1.00 were
  328.                released as REFDOS.EXE and REFOS2.EXE respectively.
  329.                You may have renamed these as REF.EXE and REFP.EXE.
  330.  
  331.           Copy the remaining files to a convenient working directory for
  332.           review (you do not need them to run REF).  Please print and
  333.           review REGISTER.DOC for registration information, LICENSE.DOC for
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.                                                     1.3: Getting started  5
  342.  
  343.           license information, and WARRANTY.DOC for warranty information.
  344.           The DEMO*.* files contain a simple demonstration program that is
  345.           used for many of the report samples in the User's Guide.
  346.  
  347.           2 Preparing for REF
  348.  
  349.           2.1 Manual preparation
  350.  
  351.           Before using REF, you must prepare a database containing
  352.           information about the project at hand.  This is handled entirely
  353.           by the language processor (compiler and/or assembler) and by
  354.           PWBRMAKE.  If you use the PWB, note that preparing the browser
  355.           database is the same as preparing the REF database: preparing for
  356.           the browser also prepares for REF, and vice versa.
  357.  
  358.           Two steps are involved:
  359.  
  360.           First, compile or assemble source modules using the option switch
  361.           that prepares "source browser" information for the PWB.
  362.           Normally, this is the /FR option (you can use /Fr for a more
  363.           limited browser database).  For example:
  364.  
  365.                cl /FR file1.c file2.c
  366.                ml /FR filea.asm fileb.asm
  367.  
  368.           This creates a raw browser information file for each module,
  369.           using the name module.SBR (e.g., FILE1.SBR and FILE2.SBR in the
  370.           first example).
  371.  
  372.           Second, create a browser database from the raw files using
  373.           PWBRMAKE.  The basic syntax you will use is:
  374.  
  375.                PWBRMAKE /o output-name input-name(s)
  376.  
  377.           For example:
  378.  
  379.                PWBRMAKE /o test file1.sbr file2.sbr
  380.  
  381.           This creates the database TEST.BSC from the two raw files created
  382.           in the first example.  Note that PWBRMAKE truncates the raw
  383.           (.SBR) files to zero length.  They are not needed after PWBRMAKE
  384.           has been run, and you can erase them if you wish.  However, if
  385.           you do this, you will not be able to build the database
  386.           incrementally you'll have to recompile every module every time.
  387.           See the next section for one technique that allows incremental
  388.           database building.
  389.  
  390.           You can use wildcards:
  391.  
  392.                PWBRMAKE /o test test?.sbr
  393.  
  394.           or
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.                                             2.1: Preparing your projects  6
  403.  
  404.                PWBRMAKE /o test *.sbr
  405.  
  406.           The latter command, of course, processes ALL of the .SBR files in
  407.           the current directory.
  408.  
  409.           If you plan to search for unreferenced symbols (those which are
  410.           defined but never used), add the /Iu option:
  411.  
  412.                PWBRMAKE /Iu /o test *.sbr
  413.  
  414.           See your online help for more information about PWBRMAKE.
  415.  
  416.  
  417.           2.2 Using NMAKE
  418.  
  419.           You may find it easier to use "make" files for maintaining the
  420.           REF/browser database.  Essentially, all you have to do is:
  421.  
  422.                1. Add /FR to the compilation or assembly commands.
  423.                2. Run PWBRMAKE after linking.
  424.                3. Optionally, deal with the problem of PWBRMAKE's desire to
  425.                truncate the raw data files.
  426.  
  427.           Consider the following simple makefile that creates MYPROG from
  428.           MOD1.C, MOD2.C, and MODA.ASM.  It manages compiling, assembling,
  429.           linking, and creating the database; all you have to do is type
  430.           "NMAKE":
  431.  
  432.                # -----------------------------------------
  433.                # Makefile for MYPROG
  434.                #
  435.  
  436.                # Inference rules
  437.                .c.obj:
  438.                     cl /c /FR $*.c
  439.  
  440.                .asm.obj:
  441.                     ml /c /Cx /FR $*.asm
  442.  
  443.                 # Primary target--link and run PWBRMAKE,
  444.                 # creating the database MYPROG.BSC.
  445.                 myprog.exe: mod1.obj mod2.obj moda.obj
  446.                     link mod1+mod2+moda,myprog;
  447.                     copy *.sbr *.sbx
  448.                     pwbrmake /Iu /o myprog *.sbx
  449.                     erase *.sbx
  450.  
  451.                 # Subsidiary targets
  452.                 mod1.obj: mod1.c
  453.  
  454.                 mod2.obj: mod2.c
  455.  
  456.                 moda.obj: moda.asm
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.                                                                                                2.2: Using NMAKE  7
  465.                                             2.1: Preparing your projects  7
  466.  
  467.           Note how the make file handles PWBRMAKE's truncation of the SBR
  468.           files: just before PWBRMAKE runs, we duplicate all of the SBR
  469.           files, using the extension SBX.  Then we run PWBRMAKE using the
  470.           duplicate (SBX) files; these are truncated, and we erase them but
  471.           the original files remain intact.  The point of this is to
  472.           maintain the raw data files so that we can build the database
  473.           incrementally, i.e., to avoid have to recompile every module
  474.           every time.
  475.  
  476.           See your documentation and online help for more information about
  477.           NMAKE.
  478.  
  479.  
  480.  
  481.  
  482.  
  483.                                                         3.1: REF services 8
  484.  
  485.           3 Using REF
  486.  
  487.           3.1 REF services
  488.  
  489.           REF provides the following information about a project that has
  490.           been prepared as described above.  In the list below, note that a
  491.           "symbol" can be almost any symbolic name (a function or
  492.           procedure, constant, typedef, structure, union, macro, whatever);
  493.           REF can provide information about any specific symbol(s) or about
  494.           ALL symbols in the database.
  495.  
  496.           Also note that the word "function" is used to mean a named
  497.           section of code, i.e., a subroutine.  In some languages these may
  498.           be called procedures, PROCs, etc.; however, REF always refers to
  499.           these as "functions."
  500.  
  501.           The available information is:
  502.  
  503.                CALLS and CALLED-BY: all of the functions that a function
  504.                calls directly, and all of the functions that call a
  505.                function directly.
  506.  
  507.                CALL TREE and REVERSE CALL TREE: complete call trees showing
  508.                how a function is called (e.g., main() calls foo(), which
  509.                calls fun1(), which calls fun2(), etc.).
  510.  
  511.                CROSS-REFERENCES: cross-reference information for any
  512.                symbol(s) in the database.  The cross reference lists the
  513.                source file name and line number where each symbol is
  514.                defined and where it is referenced.
  515.  
  516.                DUMP: a comprehensive "dump" of all information contained in
  517.                the database (can be voluminous for larger projects!).
  518.  
  519.                OUTLINE: a listing of modules included in the database and
  520.                the symbols that are contained in each module.
  521.  
  522.                UNREFERENCED SYMBOLS: all of the symbols that are defined
  523.                but not used anywhere.
  524.  
  525.                MODULES: a simple list of the modules included in the
  526.                database.
  527.  
  528.                USES and USED-BY: all of the symbols that a function uses,
  529.                and all of the functions that use a symbol.
  530.  
  531.           All REF output is sent to the screen.  It can be redirected or
  532.           piped, of course, if desired:
  533.  
  534.                REF > xref.txt
  535.  
  536.                REF | MORE
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.                                 3.2: Symbol types, attributes, instances  9
  545.  
  546.           3.2 Symbol types, attributes, instances
  547.  
  548.           Before we finally get into the mechanics of running REF, we
  549.           should briefly discuss "symbols".  A symbol is the name of some
  550.           object in your program.  It could belong to any of a dozen or so
  551.           different classes of symbols: functions, variables, constants,
  552.           structures and unions, parameters, etc.  These classes of symbols
  553.           are called "symbol types".
  554.  
  555.           Each symbol, in addition to belonging to one of the supported
  556.           types, has one or more "attributes": public, local, static, etc.
  557.  
  558.           A single combination of a name + type + attributes is called an
  559.           "instance".  Examine the following code:
  560.  
  561.  
  562.                int intvar;
  563.  
  564.                func1()
  565.                {
  566.                int intvar;
  567.                     ...
  568.                 }
  569.  
  570.                 func2()
  571.                 {
  572.                 int intvar;
  573.                     intvar = 1;
  574.                 }
  575.  
  576.                 func3()
  577.                 {
  578.                     intvar = 1;
  579.                 }
  580.  
  581.           There are three definitions but only two instances of the
  582.           variable intvar.  This is because the intvars in func1() and
  583.           func2() are identical: they are both of type VARIABLE, with
  584.           attribute LOCAL, and the name intvar.  These constitute one
  585.           instance of intvar.  The global intvar is a second instance it is
  586.           also a VARIABLE named intvar, but it has the PUBLIC attribute
  587.           rather than LOCAL.
  588.  
  589.           Unfortunately, the browser database does not provide much
  590.           information to distinguish between multiple occurrences of an
  591.           instance.  In the above example, REF does NOT know whether the
  592.           assignment to intvar in func2() is a reference to func1()'s
  593.           intvar or to func2()'s intvar.  It DOES know, however, that the
  594.           assignment in func3() is a reference to the global intvar and not
  595.           to either of the local ones.
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.                                                        3.3: Running REF  10
  604.  
  605.           3.3 Running REF
  606.  
  607.           3.3.1 Syntax
  608.  
  609.           The basic syntax for running REF is:
  610.  
  611.                REF [/?] [/HELP] [/Ifile] [options] [symbols] [/actions]
  612.                    [/Ffilters] [/Aattribute-filters]
  613.  
  614.           The syntax for REFP (the OS/2 version) is identical except that
  615.           the name of the program is REFP rather than REF.  Examples in
  616.           this manual refer to "REF", but use "REFP" for OS/2.
  617.  
  618.           The /? option displays a brief help screen.  All other options
  619.           are ignored if /? is present.
  620.  
  621.           The /HELP option (which can be abbreviated /H) displays hypertext
  622.           help for REF using Microsoft's QuickHelp program (QH.EXE).  If
  623.           REF cannot find QH.EXE or its own help file (REF.HLP), it
  624.           displays the brief help screen.  All other options are ignored if
  625.           /HELP is present.  This option is available only in the
  626.           registered version.
  627.  
  628.           The file parameter specifies the name of the reference database.
  629.           If no file is specified, REF uses the first .BSC database in the
  630.           current directory.
  631.  
  632.           The options are miscellaneous options that affect this run of
  633.           REF.
  634.  
  635.           The symbols are the specific symbols in which you're interested.
  636.           If no symbols are listed, REF assumes you mean "all qualifying
  637.           symbols."
  638.  
  639.           The actions specify the information that you want to see (call
  640.           tree, cross reference, etc.).  You can specify as many actions as
  641.           you want per run.  If no actions are specified, REF assumes that
  642.           you want a cross-reference.
  643.  
  644.           The filters specify the kinds of symbols you are interested in.
  645.           In most cases, REF defaults to functions, variables, and macros,
  646.           but you can specify any kinds of symbols you want.
  647.  
  648.           The attribute filters allow you to include objects with certain
  649.           attributes (for example, local objects such as variables declared
  650.           within functions) that REF would normally ignore.  If no
  651.           attribute filters are specified, REF suppresses information on
  652.           local symbols and on symbols that are declared but not defined.
  653.  
  654.           All of the parameters are optional.  If no parameters at all are
  655.           specified, REF prepares a cross reference for all non-local
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.                                                        3.3: Running REF  11
  664.  
  665.           functions, macros, and variables for the first .BSC file in the
  666.           current directory.  This is equivalent to:
  667.  
  668.                REF /X /Ffmv /Iname.bsc
  669.  
  670.           where NAME.BSC is the first .BSC file shown in an unsorted
  671.           directory listing.
  672.  
  673.           The REF command line is non-positional: arguments may be
  674.           specified in any order.  Switches are not case-sensitive in the
  675.           current version; however, we reserve the right to make them case-
  676.           sensitive in future versions.  We suggest that you use the
  677.           switches exactly as shown in the document.  Switches may be
  678.           introduced by either '/' or '-' and may be concatenated or listed
  679.           separately; however, each switch must have its own switch
  680.           character (/ or -):
  681.  
  682.                /C/T   /C /T   -C -T    -C-T
  683.  
  684.           Detailed information about each of the arguments follows.
  685.  
  686.  
  687.           3.3.2 Specifying the input file
  688.  
  689.           Use the /I switch to specify the name of the input database file.
  690.           The name must follow the switch immediately, with no intervening
  691.           spaces.  Include a drive and path if the database is not in the
  692.           current drive/directory.  If no extension is supplied, .BSC is
  693.           assumed.  Examples:
  694.  
  695.                REF /Imyproj.bsc
  696.                REF /Id:\c\source\myproj.bsc
  697.                REF /Imyproj             [assumes MYPROJ.BSC]
  698.  
  699.           If no input filename is specified, REF assumes that you mean the
  700.           first file with a .BSC extension in the current database.
  701.  
  702.           REF always lists the database filename when it runs.
  703.  
  704.  
  705.           3.3.3 Specifying options
  706.  
  707.           The current release of REF supports two options.
  708.  
  709.  
  710.           3.3.3.1 File suppression (/Ex)
  711.  
  712.           The /Ex option suppresses information from specified modules.
  713.           The format is:
  714.  
  715.                /Ex[(extension[,extension])]
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.                                                        3.3: Running REF  12
  724.  
  725.           This option affects only the /N (unreferenced symbols) action; it
  726.           suppresses information about unreferenced symbols contained in
  727.           files that match the specified extensions.  /Ex is intended
  728.           primarily to suppress reports about unreferenced symbols defined
  729.           in header files.
  730.  
  731.           For example, the command
  732.  
  733.                REF /N /Ex(H,INC)
  734.  
  735.           would not display information about unreferenced symbols that are
  736.           defined in files with .H and .INC extensions.
  737.  
  738.           No spaces may occur anywhere in the option.  If no extension is
  739.           specified, the extension .H is assumed.
  740.  
  741.  
  742.           3.3.3.2 Standard format (/S)
  743.  
  744.           The standard (or "Microsoft") format affects only the cross
  745.           reference report.  When you use the /S option:
  746.  
  747.                REF /S /X
  748.  
  749.           REF's output is generated in "Microsoft standard" format.  A
  750.           cross reference might look like this:
  751.  
  752.                d:\c\include\stdio.h(199) : definition : printf (macro)
  753.  
  754.           This format is useful for interaction with other products, such
  755.           as text editors, that "understand" how to parse the filename and
  756.           line number.  See section 4.1 for further information.
  757.  
  758.  
  759.           3.3.4 Specifying symbol names
  760.  
  761.           REF assumes that any arguments that do not begin with a switch
  762.           character (/ or -) are the names of symbols about which you want
  763.           information.  These can be the names of symbols of any supported
  764.           types, which are:
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.                                                        3.3: Running REF  13
  773.  
  774.                Functions or procedures (PROCs, in assembler)
  775.                Variables
  776.                Macros
  777.                Structure names
  778.                Union names
  779.                Function parameters
  780.                Named constants
  781.                Type definitions
  782.                Enumerated type names ("enumnam")
  783.                Enumerated type members ("enummem")
  784.                Segments
  785.                Groups
  786.  
  787.           For the /O option only, the symbols should be module names (i.e.,
  788.           the names of source files).
  789.  
  790.           You can specify up to 40 symbol names, if you have room on the
  791.           command line.
  792.  
  793.           Symbol names are case sensitive if the underlying module is case
  794.           sensitive (e.g., C symbols are case sensitive, but assembler
  795.           symbols may not be).
  796.  
  797.           If no symbols are specified, REF assumes that you mean all
  798.           qualifying symbols, i.e., all symbols in the database that meet
  799.           the filter criteria (see below).
  800.  
  801.           Example:
  802.  
  803.                REF main myvar mymacro MYCONST /Iproject.bsc
  804.  
  805.           The example prepares cross reference information for the symbols
  806.           main, myvar, mymacro, and MYCONST.  The database is PROJECT.BSC.
  807.  
  808.  
  809.           3.3.5 Specifying actions
  810.  
  811.           Actions specify the type(s) of information you want. Further
  812.           details about the format of each of these reports are given in
  813.           separate secions below.
  814.  
  815.           Valid action options are:
  816.  
  817.                /C   Calls: display all functions that the specified symbols
  818.                     call.  The symbols you specify should, of course, also
  819.                     be functions.  If no symbols are specified, REF assumes
  820.                     "all functions", so you will see a listing of all
  821.                     functions in the database along with a list of the
  822.                     functions that each one calls.
  823.  
  824.                /Cx  Called by: display all functions that call the
  825.                     specified symbols.  The symbols you specify should, of
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.                                                        3.3: Running REF  14
  834.  
  835.                     course, also be functions.  If no symbols are
  836.                     specified, REF assumes "all functions", so you will see
  837.                     a listing of all functions in the database along with a
  838.                     list of the functions that call each one.
  839.  
  840.                /D   Dump: a complete dump of all information in the
  841.                     database.  Any symbols given on the command line are
  842.                     ignored.
  843.  
  844.                /M   Modules: display a list of the modules included in the
  845.                     database.
  846.  
  847.                /N   Unreferenced symbols: display a list of symbols that
  848.                     are defined/declared but never used.  Any symbols given
  849.                     on the command line are ignored.
  850.  
  851.                /O   Outline: display an outline of the modules contained in
  852.                     the database, i.e., a list of all symbols and their
  853.                     types for each module.  Symbols on the command line, if
  854.                     present, should be module names.
  855.  
  856.                /T   Call tree: display a "tree" of calls descending from
  857.                     each specified symbol.  The symbols specified should,
  858.                     of course, be functions.
  859.  
  860.                /Tx  Reverse call tree: display a "reverse tree" of calls
  861.                     ascending from each specified symbol, i.e., all
  862.                     possible paths of execution to reach a particular
  863.                     function.
  864.  
  865.                /U   Uses: display a list of all symbols that each of the
  866.                     specified symbols uses, i.e., references.  The
  867.                     specified symbols should be functions.
  868.  
  869.                /Ux  Used by: display a list of all functions that use,
  870.                     i.e., reference, each of the specified symbols.
  871.  
  872.                /X   Cross-reference: display a cross-reference for each
  873.                     specified symbol, i.e., a list of each definition of
  874.                     the symbol and each reference to the symbol.
  875.  
  876.           Up to twenty actions can be specified per run (that's enough to
  877.           use all of the possible actions, some more than once). If no
  878.           actions are specified, /X is assumed.  If multiple actions are
  879.           requested, reports are displayed in the order the action options
  880.           appear on the command line.
  881.  
  882.           Examples:
  883.  
  884.                REF /C func1
  885.                Displays a list of all functions that func1 calls
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.                                                        3.3: Running REF  15
  894.  
  895.                REF /Cx func1 func2
  896.                Displays a list of all functions that call func1 or func2
  897.  
  898.                REF /C/Cx func1
  899.                Displays both lists for func1
  900.  
  901.                REF /C/U
  902.                Displays call lists and and "uses" information for all
  903.                symbols.
  904.  
  905.  
  906.           3.3.6 Specifying symbol-type filters
  907.  
  908.           The browser database contains information about a dozen different
  909.           symbol types.  By default, REF displays only information about
  910.           functions, variables, and macros when generating the uses/used-
  911.           by, cross-reference, and outline reports.
  912.  
  913.           If you want information about the other types, you can obtain it
  914.           by specifying a "filter" with the /F option.  This option is
  915.           followed by a list of one or more type codes, which are:
  916.  
  917.                f    Functions or procedures (PROCs, in assembler)
  918.                v    Variables
  919.                m    Macros
  920.                s    Structure names
  921.                u    Union names
  922.                p    Function parameters
  923.                c    Named constants
  924.                t    Type definitions
  925.                e    Enumerated type names ("enumnam")
  926.                n    Enumerated type members ("enummem")
  927.                x    Segments
  928.                g    Groups
  929.                *    All of the above
  930.  
  931.           The default filter is /Fmvf (macros, variables, functions). You
  932.           can specify that you want information about as many types as you
  933.           wish.  For example, the following command requests cross-
  934.           reference information about structures, unions, typedefs,
  935.           parameters, and constants:
  936.  
  937.                REF /X /Fsutpc
  938.  
  939.           To obtain cross reference information about ALL symbols:
  940.  
  941.                REF /X /F*
  942.  
  943.  
  944.           3.3.7 Specifying attribute filters
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.                                                        3.3: Running REF  16
  953.  
  954.           In the uses/used-by and cross-reference reports, REF normally
  955.           suppresses references to symbols with either or both of the
  956.           following attributes:
  957.  
  958.                Local: symbols that are defined within a local context such
  959.                as a function or procedure.  It's usually not necessary to
  960.                see cross reference information, for example, for strictly
  961.                local variables; the filter eliminates such information
  962.                (otherwise most C programmers would see a large volume of
  963.                reference information on common "counting" variables like
  964.                'i').
  965.  
  966.                Declaration-only: symbols that are only declared, not
  967.                defined.  The most common symbols with the "decl-only"
  968.                attribute are library functions and variables.  They are
  969.                declared in a header file, but the definition is located in
  970.                the library source which you may not have and which is
  971.                usually not included in the project database.
  972.  
  973.           If you wish to include symbols with local or declaration-only
  974.           attributes in your uses/used-by and cross-reference reports, use
  975.           the "attribute filter" switch, /A.  This switch is followed by
  976.           one or two characters, as follows:
  977.  
  978.                l    (letter L) include Local symbols
  979.                d    include Declaration-only symbols
  980.  
  981.           For example, this command includes local and decl-only symbols
  982.           with its cross-reference:
  983.  
  984.                ref /X /Adl
  985.  
  986.           Unlike the type filter (/F), which is exclusive, the attribute
  987.           filter is inclusive.  Symbols with the specified attributes are
  988.           added to the reports but symbols with other attributes are still
  989.           included.
  990.  
  991.  
  992.  
  993.  
  994.  
  995.                                                              4: Reports  17
  996.  
  997.  
  998.           4 Reports
  999.  
  1000.           This section describes all of the reports REF can generate.  Many
  1001.           of the report samples use the following do-nothing two-module C
  1002.           program.  For the sake of the brevity of the sample reports, we
  1003.           do not #include stdio.h.  Line numbers are shown in ():
  1004.  
  1005.                MODULE DEMO1.C:
  1006.  
  1007.                ( 1)  int j;
  1008.                ( 2)  extern void sub2(int);
  1009.                ( 3)  #define C 1
  1010.                ( 4)  static int sub1(void);
  1011.                ( 5)
  1012.                ( 6)  main ()
  1013.                ( 7)  {
  1014.                ( 8)  int i;
  1015.                ( 9)     sub1();
  1016.                (10)     i = 1;
  1017.                (11)     j = 2;
  1018.                (12)  }
  1019.                (13)
  1020.                (14)  static int sub1 ()
  1021.                (15)  {
  1022.                (16)  int i;
  1023.                (17)      i = 1;
  1024.                (18)      sub2(i);
  1025.                (19)  }
  1026.  
  1027.                MODULE DEMO2.C:
  1028.  
  1029.                (1)   #define inc(k) (++k)
  1030.                (2)   extern void fputchar(int);
  1031.                (3)   extern int j;
  1032.                (4)
  1033.                (5)   sub2(int i)
  1034.                (6)   {
  1035.                (7)      fputchar (inc(i) + '0');
  1036.                (8)   }
  1037.  
  1038.           The reference database was created by NMAKEing this simple
  1039.           makefile (DEMO.MAK; make via "NMAKE /F DEMO.MAK"):
  1040.  
  1041.                # DEMO make
  1042.                     demo.exe:
  1043.                     cl /FR demo1.c demo2.c
  1044.                     \c\binb\pwbrmake /o demo demo?.sbr
  1045.                     erase demo?.sbr
  1046.  
  1047.           The resulting database is DEMO.BSC; in the examples, we assume
  1048.           that it is the first or only .BSC in the current directory, so we
  1049.           do not have to specify the /I (input file) argument.
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.                                               4.1: Cross-reference (/X)  18
  1058.  
  1059.           4.1 Cross-reference (/X)
  1060.  
  1061.           4.1.1 REF format
  1062.  
  1063.           To obtain a cross-reference in REF's text format, run REF with
  1064.           the /X option:
  1065.  
  1066.                REF /X
  1067.  
  1068.           (Because /X is the default option, we could simply type "REF"
  1069.           with no arguments.)  The following report is produced:
  1070.  
  1071.                Symbol cross-reference
  1072.                ----------------------
  1073.                inc (macro)
  1074.                   Def: demo2.c(1)
  1075.                   Ref: demo2.c(7)
  1076.                j
  1077.                   Def: demo1.c(1)
  1078.                   Ref: demo1.c(11)
  1079.                   Ref: demo2.c(3)
  1080.                main()
  1081.                   Def: demo1.c(7)
  1082.                sub1() (static)
  1083.                   Def: demo1.c(15)
  1084.                   Ref: demo1.c(4)
  1085.                   Ref: demo1.c(9)
  1086.                sub2()
  1087.                   Def: demo2.c(6)
  1088.                   Ref: demo1.c(2)
  1089.                   Ref: demo1.c(18)
  1090.  
  1091.           The report, which lists each instance in alphabetical order,
  1092.           shows that inc is a macro that is defined in line 1 of DEMO2.C
  1093.           and referenced in line 7 of the same file.
  1094.  
  1095.           Variable j is defined in line 1 of demo1.c.  We know that j is a
  1096.           variable because no type is shown for the symbol; functions are
  1097.           shown with "()", and anything else has a symbol type.  Variable j
  1098.           is referenced twice: once in line 12 of DEMO1.C and again in line
  1099.           3 of DEMO2.C.
  1100.  
  1101.           sub1() has the "static" attribute.
  1102.  
  1103.           Please remember that REF cannot distinguish between multiple
  1104.           occurrences of an instance.  Thus, if a symbol name is used
  1105.           multiple times in the same way (say, two local variables with the
  1106.           same name), there will be multiple DEF and possibly multiple REF
  1107.           lines for the symbol, and there is no way to determine which DEF
  1108.           each REF is referencing.
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.                                               4.1: Cross-reference (/X)  19
  1117.  
  1118.           On the other hand, if the same name is used for symbols with
  1119.           different types or attributes (say, a local variable and a global
  1120.           variable with the same name), then each is a separate instance
  1121.           and will have its own section of refs and defs.
  1122.  
  1123.           As an example of filtering, let's produce a cross reference that
  1124.           adds (1) constants and (2) symbols with the local or decl-only
  1125.           attributes:
  1126.  
  1127.                REF /X /Fmvfc /Ald
  1128.  
  1129.           When specifying ANY type filter, you must specify ALL desired
  1130.           types.  Thus, we must use /Fmvfc to see macros, variables,
  1131.           functions, and constants; if we used /Fc, we would see only
  1132.           constants.
  1133.  
  1134.           The expanded report is as follows:
  1135.  
  1136.                Symbol cross-reference
  1137.                ----------------------
  1138.                C (constant)
  1139.                     Def: demo1.c(3)
  1140.                     Ref: demo1.c(10)
  1141.                fputchar() (decl-only)
  1142.                     Def: <Unknown>(1)
  1143.                     Ref: demo2.c(2)
  1144.                     Ref: demo2.c(7)
  1145.                i (local)
  1146.                     Def: demo1.c(8)
  1147.                     Def: demo1.c(16)
  1148.                     Ref: demo1.c(10)
  1149.                     Ref: demo1.c(17)
  1150.                     Ref: demo1.c(18)
  1151.                inc (macro)
  1152.                     Def: demo2.c(1)
  1153.                     Ref: demo2.c(7)
  1154.                j
  1155.                     Def: demo1.c(1)
  1156.                     Ref: demo1.c(11)
  1157.                     Ref: demo2.c(3)
  1158.                main()
  1159.                     Def: demo1.c(7)
  1160.                sub1() (static)
  1161.                     Def: demo1.c(15)
  1162.                     Ref: demo1.c(4)
  1163.                     Ref: demo1.c(9)
  1164.                sub2()
  1165.                     Def: demo2.c(6)
  1166.                     Ref: demo1.c(2)
  1167.                     Ref: demo1.c(18)
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.                                               4.1: Cross-reference (/X)  20
  1176.  
  1177.           Note that locals, constants, and declaration-only symbols are now
  1178.           included (i, c, and fputchar(), for example).  Also note that i
  1179.           has two definitions and three references.  The browser database
  1180.           does not contain information about which definitions each of the
  1181.           references "belongs to."
  1182.  
  1183.           fputchar() is not defined in any of the database modules, hence
  1184.           its module is "unknown".
  1185.  
  1186.  
  1187.           4.1.2 Standard (/S) format
  1188.  
  1189.           "Standard" format refers to the format Microsoft products use for
  1190.           error messages and other information where line numbers and file
  1191.           names are useful.  A standard format report can be obtained by
  1192.           using the /S option:
  1193.  
  1194.                REF /S /X
  1195.  
  1196.           The standard format report for the demo project would look like
  1197.           this:
  1198.  
  1199.                demo2.c(1) : definition : inc (macro)
  1200.                demo2.c(7) : reference : inc (macro)
  1201.                demo1.c(1) : definition : j
  1202.                demo1.c(11) : reference : j
  1203.                demo2.c(3) : reference : j
  1204.                demo1.c(7) : definition : main()
  1205.                demo1.c(15) : definition : sub1() (static)
  1206.                demo1.c(4) : reference : sub1() (static)
  1207.                demo1.c(9) : reference : sub1() (static)
  1208.                demo2.c(6) : definition : sub2()
  1209.                demo1.c(2) : reference : sub2()
  1210.                demo1.c(18) : reference : sub2()
  1211.  
  1212.           For each definition and reference, REF prepares a line in this
  1213.           format:
  1214.  
  1215.                filename(line) : type : name (information)
  1216.  
  1217.           The filename (which may include a path if there is one in the
  1218.           database) is followed immediately by the line number in
  1219.           parentheses.  After this is a space-delimited colon and the
  1220.           "type", which will always be either "definition" or "reference".
  1221.           Following the type is another space-delimited colon and the
  1222.           objects name followed, in some cases, by the qualifiers in
  1223.           parentheses.
  1224.  
  1225.           This format is readily amenable to automated processing and, in
  1226.           fact, many text editors already "understand" text in this format.
  1227.           Macros can often be easily written that will automatically run
  1228.           REF and deal with the results in a useful way.  For example, a
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.                                               4.1: Cross-reference (/X)  21
  1237.  
  1238.           mouse click on a reference to an object could run REF and then
  1239.           lead to displays of the definition and additional references, in
  1240.           context.
  1241.  
  1242.           The standard format report does not show objects for which the
  1243.           module name is unknown.
  1244.  
  1245.  
  1246.           4.2 Call trees (/T, /Tx)
  1247.  
  1248.           4.2.1 Forward call trees (/T)
  1249.  
  1250.           Call trees specify the paths a program can take to reach a
  1251.           specific function.  Let's look at the call tree for main() in the
  1252.           demo:
  1253.  
  1254.                REF /T main
  1255.  
  1256.           The report is as follows:
  1257.  
  1258.                main
  1259.                └─sub1
  1260.                  └─sub2
  1261.                    └─fputchar?
  1262.  
  1263.           Function main() calls sub1(), which calls sub2(), which calls
  1264.           fputchar().  fputchar() is undefined (remember, it's declaration-
  1265.           only), so the report adds a question mark, indicating that it
  1266.           can't follow the call tree past fputchar().
  1267.  
  1268.           If main() also called sub3() and sub4(), and sub3() in turn
  1269.           called sub3a() and sub3b(), the report would look like this:
  1270.  
  1271.                main
  1272.                ├─sub1
  1273.                │ └─sub2
  1274.                │   └─fputchar?
  1275.                ├─sub3
  1276.                │ ├─sub3a
  1277.                │ └─sub3b
  1278.                └─sub4
  1279.  
  1280.           If a function is called more than once from another function, the
  1281.           number of such calls follows the name.  For example, if printf()
  1282.           were called three times by main(), it would look like this:
  1283.  
  1284.                main
  1285.                └─printf? (3)
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.                                               4.2: Call trees (/T, /Tx)  22
  1294.  
  1295.           4.2.2 Subtrees and levels
  1296.  
  1297.           The call tree for the main function of a large program can be
  1298.           extensive.  You can get subtrees by specifying lower level
  1299.           functions (the following command assumes the sub3() function,
  1300.           which is not in the "real" demo):
  1301.  
  1302.                REF /T sub1 sub3
  1303.  
  1304.                sub1
  1305.                └─sub2
  1306.                   └─fputchar?
  1307.  
  1308.                sub3
  1309.                ├─sub3a
  1310.                └─sub3b
  1311.  
  1312.           You can limit the number of levels shown by adding a number
  1313.           immediately following the /T (or /Tx) option.  For example, if
  1314.           you only want to see the functions directly called by main():
  1315.  
  1316.                REF /T1 main
  1317.  
  1318.           If you want to see the functions called by main() and the
  1319.           functions that those functions call (but no more):
  1320.  
  1321.                REF /T2 main
  1322.  
  1323.           The "2" indicates that you want to see the call tree to a maximum
  1324.           depth of two call levels past main().  REF supports reports of
  1325.           call nesting up to 250 levels.
  1326.  
  1327.  
  1328.           4.2.3 Recursion
  1329.  
  1330.           Directly or indirectly recursive functions are shown with "...".
  1331.           Consider the following skeleton program:
  1332.  
  1333.                main()
  1334.                {   sub1(); }
  1335.  
  1336.                sub1()
  1337.                {   sub2(); }
  1338.  
  1339.                sub2()
  1340.                {   sub1(); }
  1341.  
  1342.           Note that sub1() is indirectly recursive: it calls sub2(), which
  1343.           in turn calls sub1().  The call tree for main() would show as
  1344.           follows:
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.                                               4.2: Call trees (/T, /Tx)  23
  1353.  
  1354.                main
  1355.                └─sub1
  1356.                  └─sub2
  1357.                    └─sub1...
  1358.  
  1359.           The ellipsis ("...") shows that the call tree continues
  1360.           indefinitely from this point.
  1361.  
  1362.  
  1363.           4.2.4 Indirect calls
  1364.  
  1365.           What happens when a function is called indirectly, e.g., by
  1366.           address rather than by name?  Let's look at an example; we'll use
  1367.           assembler instead of C, since this is one case where assembler
  1368.           may be easier to read.
  1369.  
  1370.                proc1 proc
  1371.                mov ax,offset proc3 ; Put proc3's address in AX
  1372.                     call proc2
  1373.                     ...
  1374.  
  1375.                proc2 proc
  1376.                     call ax             ; Calls proc3 (indirectly)
  1377.                     ...
  1378.  
  1379.                proc3 proc
  1380.                     call foo
  1381.                     ...
  1382.  
  1383.           The call trees for proc1 and proc2 would look like this:
  1384.  
  1385.                proc1
  1386.                ├─proc3
  1387.                │ └─foo
  1388.                └─proc2
  1389.  
  1390.                proc2
  1391.  
  1392.           proc2's tree is empty, indicating that it doesn't make any calls
  1393.           at all even though it actually does.  This makes sense, since the
  1394.           call is dynamic; the call target isn't known until run time.  The
  1395.           assembler knows that there is a call, but it doesn't know what is
  1396.           being called and therefore can't provide a name for the reference
  1397.           database.
  1398.  
  1399.           But why is proc3's subtree shown under proc1, when proc1 never
  1400.           calls proc3?  Because the database does not actually distinguish
  1401.           between a reference to a function and a call to a function.  REF
  1402.           simply assumes that any reference to a function is in fact a
  1403.           call, since that is by far the most common case.  Thus, the
  1404.           reference to proc3 is assumed to be a call, and the proc3 call
  1405.           tree is displayed.
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.                                               4.2: Call trees (/T, /Tx)  24
  1414.  
  1415.           In practice, this is not really as bad a thing as might appear.
  1416.           If proc3 didn't appear under proc1, it wouldn't appear at all.
  1417.           At least we can tell that there is a path of execution by which
  1418.           proc3 can be reached from proc1.  proc2 is missing from the
  1419.           sequence, but this is better than nothing!
  1420.  
  1421.  
  1422.           4.2.5 Symbols required
  1423.  
  1424.           Unlike the other actions, call trees (and reverse call trees)
  1425.           require you to specify at least one symbol (function) name on the
  1426.           command line.  Otherwise, REF would produce a call tree for every
  1427.           function in the program; for anything larger than a trivial
  1428.           program, the volume of data produced would be massive.
  1429.  
  1430.  
  1431.           4.2.6 Reverse call trees
  1432.  
  1433.           Reverse call trees are similar to call trees, but reversed: the
  1434.           function(s) of interest are shown at the top of the tree rather
  1435.           than at the bottom:
  1436.  
  1437.                REF /Tx fputchar
  1438.  
  1439.                fputchar
  1440.                └─sub2
  1441.                  └─sub1
  1442.                    └─main
  1443.  
  1444.           This report can be extremely useful because it clearly shows the
  1445.           exact paths of execution by which a specific function can be
  1446.           reached.  In this case, fputchar() can only be reached via
  1447.  
  1448.                main() -> sub1() -> sub2() -> fputchar()
  1449.  
  1450.           If sub3a() also called fputchar(), the reverse tree would be:
  1451.  
  1452.                fputchar
  1453.                ├─sub2
  1454.                │ └─sub1
  1455.                │   └─main
  1456.                └─sub3a
  1457.                  └─sub3
  1458.                    └─main
  1459.  
  1460.           Now note that there are two paths to fputchar():
  1461.  
  1462.                main() -> sub1() -> sub2() -> fputchar()
  1463.                main() -> sub3() -> sub3a() -> fputchar()
  1464.  
  1465.           It is much easier to find all possible paths to a low level
  1466.           function in this manner than to examine a forward tree from
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.                                               4.2: Call trees (/T, /Tx)  25
  1475.  
  1476.           main().  The forward tree would show many paths that end in
  1477.           symbols that are of no interest, but the reverse tree shows only
  1478.           the paths of execution that lead to your function.
  1479.  
  1480.  
  1481.           4.3 Calls, Called-by (/C, /Cx)
  1482.  
  1483.           The calls and called-by reports are simpler than the call trees;
  1484.           they simply show lists of functions that directly call or are
  1485.           called by the function(s) of interest.  For example, assuming
  1486.           this program:
  1487.  
  1488.                main()
  1489.                {
  1490.                     sub1(); sub3();
  1491.                }
  1492.  
  1493.                sub1()
  1494.                {   sub2(); }
  1495.  
  1496.                sub2()
  1497.                {   }
  1498.  
  1499.                sub3()
  1500.                {   }
  1501.  
  1502.           a call report for the whole program (REF /C) would be
  1503.  
  1504.                Function         Calls
  1505.                --------         -----
  1506.                main()           sub1()
  1507.                                 sub3()
  1508.                sub1()           sub2()
  1509.  
  1510.           main() calls sub1() and sub3(); sub1() calls sub2().
  1511.  
  1512.           The called-by report (REF /Cx) would be:
  1513.  
  1514.                Function         Called by
  1515.                --------         ---------
  1516.                main()
  1517.                sub1()           main()
  1518.                sub2()           sub1()
  1519.                sub3()           main()
  1520.  
  1521.  
  1522.           4.4 Uses, used-by (/U, /Ux)
  1523.  
  1524.           These reports show all symbols that a function uses, or all
  1525.           functions that use a symbol.  The "uses" report is a superset of
  1526.           the "calls" report, and the "used-by" report is a superset of the
  1527.           "called by" report.  That is, a uses/used-by report contains all
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.                                            4.4: Uses, used-by (/U, /Ux)  26
  1536.  
  1537.           of the information that would be contained in the calls/called-by
  1538.           report for the same set of symbols.
  1539.  
  1540.           Running the "uses" report (REF /U) on the sample program produces the
  1541.           following report:
  1542.  
  1543.                Symbol                   Uses
  1544.                ------                   ----
  1545.                main()                   sub1()
  1546.                                         j
  1547.                sub1() (static)          sub2()
  1548.                sub2()                   inc (macro)
  1549.  
  1550.           Function main() uses function sub1() and variable j; function
  1551.           sub1() uses function sub2(); and function sub2() uses the macro
  1552.           inc.  We can get a more complete report by requesting information
  1553.           on local objects as well as additional symbol types:
  1554.  
  1555.                REF /U /Al /Ffmvc
  1556.  
  1557.           The new report adds constants and local variables:
  1558.  
  1559.                Symbol                   Uses
  1560.                ------                   ----
  1561.                main()                   i (local)
  1562.                                         sub1() (static)
  1563.                                         C (constant)
  1564.                                         j
  1565.                sub1() (static)          i (local)
  1566.                                         sub2()
  1567.                sub2()                   inc (macro)
  1568.  
  1569.           The used-by report provides the "inverse" information: which
  1570.           functions use each symbol (rather than which symbols are used by
  1571.           each function).  The full used-by report could be obtained via:
  1572.  
  1573.                REF /Ux /Al /Ffmvc
  1574.  
  1575.                Symbol                   Used by
  1576.                ------                   -------
  1577.                C (constant)             main()
  1578.                i (local)                main()
  1579.                                         sub1() (static)
  1580.                inc (macro)              sub2()
  1581.                j                        main()
  1582.                sub1() (static)          main()
  1583.                sub2()                   sub1() (static)
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.                                                       4.5: Modules (/M)  27
  1593.  
  1594.           4.5 Modules (/M)
  1595.  
  1596.           The /M action simply displays a list of modules that are included
  1597.           in the database.  For our simple demo, the command
  1598.  
  1599.                REF /M
  1600.  
  1601.           produces this list:
  1602.  
  1603.                Modules
  1604.                -------
  1605.                1: demo1.c
  1606.                2: demo2.c
  1607.  
  1608.  
  1609.           4.6 Unreferenced symbols (/N)
  1610.  
  1611.           This report shows any symbols that are defined but not
  1612.           referenced.  Consider this program:
  1613.  
  1614.                main()
  1615.                {
  1616.                int var1, var2;
  1617.                     var1 = 1;
  1618.                }
  1619.  
  1620.           Running REF /N on the database for this program produces the
  1621.           following report:
  1622.  
  1623.                Unreferenced symbols
  1624.                --------------------
  1625.                test.c(3) : var2 (local)
  1626.  
  1627.           The report shows that the local variable var2 is defined on line
  1628.           3 of TEST.C but is never referenced.
  1629.  
  1630.           The unreferenced symbols report is not foolproof.  Remember that
  1631.           REF can't distinguish between multiple occurrences of the same
  1632.           "instance" (a specific combination of name, type, and
  1633.           attributes).  If you do have multiple occurrences of an instance,
  1634.           a reference to any one of them will prevent the rest from
  1635.           appearing as unreferenced.  Consider this program:
  1636.  
  1637.                int var1;
  1638.  
  1639.                main()
  1640.                {
  1641.                int var1;
  1642.                }
  1643.  
  1644.                sub1()
  1645.                {
  1646.                int var1;
  1647.                     var1 = 1;
  1648.                }
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.                                          4.6: Unreferenced symbols (/N)  28
  1657.  
  1658.  
  1659.           There are three occurrences but only two instances of var1: one
  1660.           global instance and one local instance.  The local var1 in main()
  1661.           is unreferenced but will not appear in the reports because its
  1662.           "cousin" instance in sub1() is not unreferenced.
  1663.  
  1664.           On the other hand, the global instance of var1 will show as
  1665.           unreferenced: it is a separate instance, and there are no
  1666.           references anywhere in the program to a global var1.
  1667.  
  1668.           Of course, if you avoid duplicate names this will not represent a
  1669.           problem.
  1670.  
  1671.           Remember to include PWBRMAKE's /Iu option when you plan to search
  1672.           for unreferenced symbols, and that you can exclude information
  1673.           from header files using REF's /Ex option.
  1674.  
  1675.           By the way, PWBRMAKE's /Es and /Ei options are supposed to
  1676.           exclude from the database information that is derived from
  1677.           certain types of included files; we have never been able to get
  1678.           these to work reliably (PWBRMAKE version 1.10).  Perhaps you can.
  1679.  
  1680.  
  1681.           4.7 Outline (/O)
  1682.  
  1683.           The outline function displays an outline of the contents of the
  1684.           database, i.e., a list of all qualifying symbols defined in each
  1685.           module.  The outline for the demo program (REF /O) would be as
  1686.           follows:
  1687.  
  1688.                demo1.c
  1689.                     j              variable,public
  1690.                     main           function,public
  1691.                     sub1           function,static
  1692.  
  1693.                demo2.c
  1694.                     inc             macro
  1695.                     sub2            function,public
  1696.  
  1697.           All qualifying symbols (instances, really) are listed for each
  1698.           module, along with the symbol type and attributes.
  1699.  
  1700.           As usual, a more complete list can be obtained by changing the
  1701.           filters.  For example:
  1702.  
  1703.                REF /Fmcvfp /Al /O
  1704.  
  1705.                demo1.c
  1706.                    C              constant
  1707.                    i              variable,local
  1708.                    j              variable,public
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.                                                       4.7: Outline (/O)  29
  1717.  
  1718.                    main             function,public
  1719.                    sub1             function,static
  1720.  
  1721.                demo2.c
  1722.                    i                parameter,local
  1723.                    inc              macro
  1724.                    sub2             function,public
  1725.  
  1726.           You can also obtain outlines of specific modules by listing them
  1727.           as "symbols" on the command line.  To obtain an outline of
  1728.           DEMO1.C:
  1729.  
  1730.                REF /O demo1.c
  1731.  
  1732.           Some module names may include a drive and/or path in the database
  1733.           (use /M to check).  If you wish to name such a module on the
  1734.           command line, you must use the exact drive/path as listed by /M.
  1735.           For example, if a module is listed by /M as
  1736.           "c:\c\include\heap.h", you must use the same path with /O:
  1737.  
  1738.                REF /O c:\c\include\heap.h
  1739.  
  1740.           When specifying module names for /O, you can use the standard DOS
  1741.           * and ? wildcards.  To obtain both DEMO1.C and DEMO2.C (as well
  1742.           as any other modules in the database that match the filespec):
  1743.  
  1744.                REF /O demo?.c
  1745.  
  1746.           or
  1747.  
  1748.                REF /O demo*.c
  1749.  
  1750.           You can omit the drive/path if you use the * wildcard for the
  1751.           entire root name of a file.  For example, this command would
  1752.           include an outline of a module listed as "c:\c\include\heap.h"
  1753.  
  1754.                REF /O *.h
  1755.  
  1756.           If you do specify a path with a wildcard, it must be correct.
  1757.           This command would not work, because it's missing the drive
  1758.           letter:
  1759.  
  1760.                REF /O \c\include\*.h
  1761.  
  1762.  
  1763.           4.8 Dump (/D, /Dm, /Ds)
  1764.  
  1765.           The dump report simply dumps out most of the information in the
  1766.           database.  This report can be quite voluminous for large
  1767.           programs; it's over 100 lines long for the simple demo program,
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.                                                4.8: Dump (/D, /Dm, /Ds)  30
  1776.  
  1777.           The dump should be largely self-explanatory.  It is in two parts:
  1778.           a module list and a symbol list.  The module list is similar in
  1779.           contents to the /O (outline) report: it shows the module name and
  1780.           all symbols that are contained in the module.  This list differs
  1781.           slightly in format and is not affected by the filters (all
  1782.           modules and symbols are shown).
  1783.  
  1784.           Here is the listing for the DEMO1.C module:
  1785.  
  1786.                Module 1 of 2: demo1.c
  1787.                C              (constant)
  1788.                i              (variable:local)
  1789.                j              (variable:public)
  1790.                main           (function:public)
  1791.                sub1           (function:static)
  1792.  
  1793.           One of the "modules" is usually "<Library>". This is actually a
  1794.           dummy module that is used to contain objects that are declared
  1795.           but not defined anywhere that the database knows about.  For the
  1796.           most part, these will be functions and variables that are
  1797.           declared in header files but not defined within the program
  1798.           source: usually library functions and variables.
  1799.  
  1800.           The symbol list is a comprehensive, alphabetical list of all
  1801.           symbols known to the database.  For each symbol is shown:
  1802.  
  1803.                Symbol name, type, and attribute(s)
  1804.                Definitions (source file name and line number)
  1805.                References (source file name and line number)
  1806.                Uses information
  1807.                Used-by information
  1808.  
  1809.           Here is the symbol listing for the sub1() function:
  1810.  
  1811.                sub1             (function:static)
  1812.                  def:           demo1.c(14)
  1813.                  ref:           demo1.c(3)
  1814.                  ref:           demo1.c(8)
  1815.                  uses:          i (variable:local) [3]
  1816.                  uses:          sub2 (function:public)
  1817.                  used-by:       main (function:public)
  1818.  
  1819.           sub1() is a static function that is defined in line 14 of
  1820.           DEMO1.C.  It is referenced twice: once in line 3 of DEMO1.C and
  1821.           again in line 8.  sub1() uses the local variable i three times
  1822.           and calls the function sub2().  It is used by (called by) the
  1823.           function main().
  1824.  
  1825.           If you wish to see only one of the two lists, use /Dm to see the
  1826.           module list or /Ds to see the symbol list.
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.                                              Appendix A: Error Messages  31
  1834.  
  1835.  
  1836.           Appendix A: Error Messages
  1837.  
  1838.           REF displays the following error messages.  Messages with numbers
  1839.           RF1xxx are fatal; REF cannot continue and returns a nonzero
  1840.           errorlevel to the operating system.  Messages with numbers RF2xxx
  1841.           are informational in nature; REF continues proessing normally.
  1842.  
  1843.           RF1001: too many symbols (max=40)
  1844.                Only forty symbols may be specified on the command line.
  1845.  
  1846.           RF1002: too many actions (max=20)
  1847.                Only twenty actions may be specified per REF run.
  1848.  
  1849.           RF1003: too many exclude types (max=10)
  1850.                Only ten exclude headers may be specified with /Ex.
  1851.  
  1852.           RF1004: filename not specified, no .BSC files found
  1853.                You did not specify a filename on the command line, and REF
  1854.                did not find any .BSC databases in the current directory.
  1855.  
  1856.           RF1005: must specify at least one symbol name for /T, /Tx
  1857.                You must list at least one symbol (function) on the command
  1858.                line when using /T or /Tx.
  1859.  
  1860.           RF1006: can't open <filename>
  1861.                REF was unable to find or open a file with the specified
  1862.                name.
  1863.  
  1864.           RF1007: out of memory
  1865.                REF ran out of memory.
  1866.  
  1867.           RF2001: <symbol name> not found
  1868.                No symbol was found in the database with the specified name
  1869.                (which was given on the command line).  Check case and
  1870.                spelling.
  1871.  
  1872.           RF2002: decl-only instance of <symbol name> found
  1873.                When preparing a call tree, an instance of the named symbol
  1874.                is "declaration only", i.e., it is declared but not defined.
  1875.                Since the database has no information about calls it might
  1876.                make, it is not possible to display a call tree for this
  1877.                instance.
  1878.  
  1879.           RF2003: non-function instance of <symbol name> found
  1880.                When preparing a call tree, an instance of the named symbol
  1881.                was found not to be a function (and thus has no call tree).
  1882.