home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / REF.ZIP / REF.DOC < prev    next >
Text File  |  1991-07-15  |  66KB  |  1,706 lines

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