home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / gnat-int < prev    next >
Encoding:
Text File  |  1994-06-01  |  46.0 KB  |  1,048 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                              GNAT DOCUMENTS                              --
  4. --                                I N T R O                                 --
  5. --                                                                          --
  6. --                                                                          --
  7. --                                                                          -- 
  8. --                                                                          --
  9. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  10. --                                                                          --
  11. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  12. -- terms  of the GNU  General  Public  License  as  published  by the  Free --
  13. -- Software  Foundation;  either version 2,  or (at your option)  any later --
  14. -- version.  GNAT is distributed  in the hope  that it will be useful,  but --
  15. -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT- --
  16. -- ABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public --
  17. -- License  for  more details.  You should have received  a copy of the GNU --
  18. -- General Public License along with GNAT;  see file COPYING. If not, write --
  19. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  20. --                                                                          --
  21. ------------------------------------------------------------------------------
  22.  
  23. Contents.
  24. ---------
  25.    Running GNAT.
  26.    A small example.
  27.    Gnatbl.
  28.    Using the binder.
  29.    Using gcc to compile.
  30.    Using gcc for syntax checking.
  31.    Using gcc for semantics checking.
  32.    Search Paths and the Run Time Library (RTL).
  33.    Options.  
  34.    Constraint Checking and Pragma Suppress
  35.    Order of Compilation Issues.
  36.    File Name Rules.
  37.    Compiling Files With Several Compilation Units.
  38.    Cross Reference Tool.
  39.    Implementation of Intrinsic Functions.
  40.    Getting Internal Debugging Information.
  41.    When GNAT crashes.
  42.    Using gdb.
  43.    Features supported/unsupported.
  44.    Files.
  45.    Copyright considerations.
  46.    How to get in touch with us.
  47.    Schedule.
  48.    A short gnat paper.
  49.    The GNAT development team.
  50. ------------------------------------------------------------------------------ 
  51.  
  52. Running GNAT.
  53. -------------
  54. Three steps are needed to create an executable file from an Ada source file:
  55. it must first be compiled, it then must go through the gnat binder, and then
  56. all appropriate object files it needs are then linked together to produce an
  57. executable.  A tool has been provided to combine the last 2 steps into one
  58. command.
  59.  
  60. A small example.
  61. ----------------
  62.  
  63. The file hello.adb contains the source of our modest version of the
  64. "Hello World" program.  Other components of this program are contained
  65. in the GNAT Runtime Library (RTL).  You needn't mention the files
  66. containing these other components but you can find the sources (io.ads,
  67. io.adb, and a-cio.c) in the RTL source directory (described below).
  68.  
  69. The file hello.adb can be found in the current distribution in the examples
  70. directory.  Here are the commands for building and running it (Since this
  71. documentation is for systems running Unix and also for those running
  72. IBM OS/2 2.x, in places where the instructions differ a prefix "Unix:" or
  73. "OS/2:" indicates what is relevant for each system):
  74.  
  75.             gcc -c hello.adb
  76.       Unix: gnatbl -o hello hello.ali
  77.       OS/2: gnatbl -o hello.exe hello.ali
  78.  
  79. create the executable called "hello" or "hello.exe" in your current directory.
  80. Typing
  81.  
  82.       hello
  83.  
  84. will allow you to verify that the system is alive and willing to enter into 
  85. a primitive dialogue.
  86.  
  87. The gcc switch -c indicates that we only want to compile, not link. The gnatbl
  88. step produces the executable by means of calling the GNAT binder, compiling
  89. its output, and calling gcc with the needed object files and libraries to
  90. link the executable.  The -o switch is passed to the linker to name the
  91. resulting executable file.
  92.  
  93. As the example suggests, the gcc command recognizes the extension .adb as
  94. an indication of an Ada source file and calls the appropriate programs
  95. to generate an object file (hello.o or hello.obj) and an Ada Library
  96. Information (ALI) file (hello.ali) containing dependency information used
  97. by the binder to verify consistency and determine order of elaboration.
  98. The "ali" extension is recognized by gnatbl as the ALI file of the main
  99. procedure or function, and gnatbl uses it to create a file called the
  100. bind file, and to gather all the needed object files for linking.
  101.  
  102.  
  103. Gnatbl
  104. -----
  105. The program gnatbl is being provided on a temporary basis to simplify
  106. binding and linking using the RTL in the most simple situations.  It will
  107. be replaced later by a more complete utility to build a complete Ada
  108. system.  Gnatbl calls gnatbind which creates a C file (b_hello.c in our
  109. simple example) containing calls to all of the elaboration routines.
  110. Gnatbind is described more fully below.  The typical use of GNAT (currently
  111. -- in the presence of gnatbl) to construct a program consisting of a mix
  112. of Ada and C sources is to compile all of the sources using "gcc -c" to
  113. generate object (.o or .obj) files.  In the case of Ada sources, ALI files
  114. with the extension .ali are also produced.  Then gnatbl is used to construct
  115. the executable.  All arguments to gnatbl are simply passed through to gcc
  116. to link the objects together, with the exception of a file name with the
  117. .ali extension.  Such an argument is presumed to be the ALI file of the
  118. main procedure of the program.  When gnatbl sees a .ali file it calls gnatbind
  119. to create the bind file, compiles the bind file, extracts a list of needed
  120. object files from the bind file, and replaces the .ali argument with the
  121. a list of object files (the result of compiling the bind file and the list
  122. extracted from the bind file) in the gcc command it makes.  As a quick
  123. illustration consider a program comprising main.adb, foo.adb and bar.c.
  124. After compiling these sources into object files, the command (under Unix)
  125.  
  126. gnatbl -o main main.ali bar.o
  127.  
  128. would cause gnatbl to:
  129.   call "gnatbind main.ali", generating b_main.c
  130.   call "gcc -c b_main.c"
  131.   call "gcc -o b_main.o main.o foo.o bar.o (+ gnat library args)"
  132.  
  133. In the last step, the "main.ali" argument has been replaced by all of the
  134. object files needed by main (the binder file, main itself, and foo -- upon
  135. which main depends). All other gnatbl arguments are passed through unchanged
  136. to gcc.  Finally a -l and a -L argument are added to the end of the gcc call
  137. to point it to the gnatlib library.  (Under OS/2, the command line and
  138. behavior of gnatbl is similar.)
  139.  
  140. A current limitation of the very simplistic gnatbl is that the main program
  141. must be Ada and that it depends on all of the necessary library units.  In
  142. other words, there can be only one .ali file listed and it must be the
  143. main program.  This particularly restricts gnatbl's use when a routine written
  144. in another language calls an Ada subprogram which is not also called from
  145. Ada.
  146.  
  147.  
  148. Using the Binder.
  149. -----------------
  150.  
  151. In the "Hello World" example, if gnatbl were not used, the second step
  152. would have been to call the binder directly with the command:
  153.  
  154.        gnatbind hello.ali
  155.  
  156. This command generates a file named b_hello.c which needs to be compiled and
  157. linked together with hello.o (or hello.obj).  The file b_hello.c contains
  158. a program which contains calls to all of the elaboration routines of all
  159. of the units required by the subprogram whose ALI file is given on the command
  160. line.  Then it calls the Ada subprogram itself.  By default, this C function
  161. is called "main".  (For other options, see the section on options below.)
  162. The program gnatbind works by recursively processing the ALI files of all
  163. of the units that are needed.  These ALI files are found using the search
  164. path mechanism described below.  Since object and ALI files are always
  165. kept together, the object files needed for linking are found at the same
  166. time and are listed in a comment at the end of the bind file.  This is where
  167. gnatbl finds the list of object files required.
  168.  
  169. Using gcc to compile.
  170. ---------------------
  171.  
  172. In the usual procedures for using GNAT, Ada source programs are compiled into
  173. object files using the driver program 'gcc' with the option '-c' (compile
  174. only). Gcc recognizes the ada filename extensions .ads and .adb (discussed
  175. more thoroughly below) and calls the actual compiler, 'gnat1' to compile
  176. the source file.  Gcc has many switches which you will need your gcc
  177. documentation to learn about.  In addition, gcc passes gnat1 switches
  178. through to gnat1.  These (with a couple of exceptional abbreviations) are
  179. spelled on the gcc command line by "-gnatXXX".  Thus
  180.  
  181.         gcc -c -gnata foo.adb
  182.  
  183. causes gcc to call the Ada compiler gnat1 with gnat1's '-a' switch; the '-c'
  184. is understood by gcc to mean that it is done after producing the object file
  185. (it won't try to link).  The output of this command is the object and ALI
  186. files for foo.
  187.  
  188. In the future, the gcc and the GNAT-specific switches will be more fully
  189. integrated.  At this time, there is the "-gnatXXX" mechanism for passing
  190. switches through to gnat1.  Some of these switches are described in
  191. specific sections of this document; a more complete discussion is in the
  192. options section below.  Note that gcc passes these switches to gnat1
  193. with the "gnat" prefix, where it is stripped off.  This means that
  194. when gnat1 is executed the "gnat" prefix is required; but in all of the
  195. documentation the switches are described without the prefix.
  196.  
  197. Three gcc options are translated to gnat1 arguments when seen on the gcc
  198. command line.  These are "k8" (file name limit), "83" (Ada83 syntax) and
  199. "w" (warning mode). Thus, the following commands are identical:
  200.  
  201.      gcc -ws -k8 file.adb
  202.      gcc -gnatws -gnatk8 file.adb
  203.  
  204. i.e., both of them suppress warning messages from GNAT, and expect file names
  205. to be 8 characters long at most (see below for usage).
  206.  
  207. In addition, the following gcc switches are passed through and recognized by 
  208. gnat1 with the same effects as in cc1 (as for C files): "-g*" (other than
  209. "-gnat*"); "-O*"; "-p"; "-pg"; "-f*"; "-d*"; "-S".  For example, 
  210.  
  211.       gcc -c -g math.adb
  212.  
  213. will generate debugging information that can be used with the debugger gdb
  214. (see below).
  215.  
  216. The other flags that control gcc itself (notably -B and -c) and the 
  217. assembler, behave as usual. Please consult your GCC documentation for details.
  218.  
  219.  
  220. Using gcc for syntax checking
  221. ------------------------------
  222.  
  223. The current release of GNAT implements the full Ada 9X grammar as described in 
  224. annotated Ada Reference Manual for Ada 9X (AARM, version 4.0). We think the
  225. parser gives excellent error messages (try it and see!) and is pleasantly 
  226. fast (again, try and see!).
  227.  
  228. To run GNAT in syntax checking only mode, use the switch "s",
  229. that is to say, enter the command:
  230.  
  231.     gcc -c -gnats file
  232.  
  233. where file is the name of the file to be checked. (Under Unix, wild cards can
  234. be used to check a set of files, as in *.adb.)  Note that the 'compile only'
  235. flag has to be given for gcc, as well as the 'syntax only' flag, which is
  236. GNAT-specific.  We will remove this redundancy in subsequent releases. 
  237.  
  238. The syntax checker is complete, and quite robust. If you manage
  239. to blow it up, or if it fails to diagnose an error, or lets a syntactically
  240. invalid program through, definitely let us know (see separate section below). 
  241. If you find an error message you think could be improved, let us know as well. 
  242. Of course, no compiler can ever have perfect error messages (that would involve
  243. mind reading), but we are committed to doing as well as possible, so we are
  244. happy to get suggestions in this department.
  245.  
  246. Using gcc for semantics checking
  247. --------------------------------
  248.  
  249. The command to perform semantic checking is:
  250.  
  251.     gcc -c -gnatc file
  252.  
  253. To operate in this mode, since WITH'ed files must be accessed, the GNAT
  254. semantic restrictions on file structuring must be followed:
  255.  
  256.      o    The needed source files must be accessible.  See the section
  257.         below on search paths.
  258.  
  259.      o    Each file must contain only one compilation unit.
  260.     See the section below on file name rules.
  261.  
  262.      o    The file name and unit name must match as described below, under
  263.         File name rules.
  264.  
  265. Note that the use of search paths and the flexibility of the File name
  266. rules will increase in the future as described in the sections on these
  267. facilities.
  268.  
  269. The coverage of semantic checks is still incomplete, and the system
  270. is not very robust in the presence of semantically illegal programs.
  271. Nevertheless, this release supports many more features of Ada9X than the
  272. previous one, and semantic checking is correspondingly more extensive. 
  273.  
  274. When you run in this mode, you may get "not implemented yet" messages,
  275. blowups, undetected semantic errors, etc. Don't bother to tell us about any
  276. of these -- we know only too well what still needs to be worked on! 
  277.  
  278. Here, use of the 'report errors immediately' switch ("-e", i.e., "-gnate" on
  279. the gcc command line) will help pinpoint the source of the trouble if the
  280. system misbehaves. 
  281.  
  282. Search paths and the Run Time Library (RTL)
  283. -------------------------------------------
  284.  
  285. With GNAT's source based library system, the compiler must be able to find
  286. source files for units that are needed by the unit being compiled.  Also,
  287. during binding, ALI files are needed to do the required checking of
  288. compilation order and to determine elaboration requirements.  Both the
  289. compiler and the binder use search paths to locate the files that they need.
  290. The rules are straightforward.
  291.  
  292. The compiler compiles one source file whose name must be givien explicitly
  293. on the command line (i.e. there is no searching done for this file).  All
  294. other source files that are needed (the most common being the specs of
  295. WITH'ed units) are found by looking in the following directories: 
  296.  
  297.    o The first directory searched is the directory containing the source
  298.      file of the main unit being compiled (the file name on the command
  299.      line).
  300.  
  301.    o (UNIMPLEMENTED SO FAR) Next, the compiler looks in each directory
  302.      named by a "-I" option given to gcc (in the order given on the
  303.      command line).
  304.  
  305.    o Then the compiler looks in each of the directories listed in the value
  306.      of the ADA_INCLUDE_PATH environment variable.  This value is constructed
  307.      exactly as the PATH environment variable -- a list of directory names
  308.      separated by ':' or ';' (Unix or OS/2, respectively) characters. Under
  309.      OS/2, this mechanism is used to locate the RTL source files in place of
  310.      the default location described next for Unix.
  311.  
  312.    o (Unix only) Finally the compiler looks in the default location for
  313.      the GNAT Run Time Library (RTL) source files that is determined at the
  314.      time that GNAT is built and installed on your system.
  315.  
  316. The compiler outputs its object files and ALI files in the current working
  317. directory (NOTE: the object file can be redirected with the -o option;
  318. however, gcc and gnat1 have not been coordinated on this so the ALI file
  319. will not go to the right place -- DON'T DO THIS).
  320.  
  321. The binder takes the name of an ALI file as its argument and needs to locate
  322. other ALI files in its recursive processing.  These are found in the
  323. following directories:
  324.  
  325.    o First, the current working directory is searched.
  326.  
  327.    o (UNIMPLEMENTED SO FAR) Next, the binder looks in directories named
  328.      in "-L" options on the gnatbind command line (in the order given).
  329.  
  330.    o Next, the binder looks in each of the directories listed in the value
  331.      of the ADA_OBJECTS_PATH environment variable.  This value is constructed
  332.      exactly as the PATH environment variable -- a list of directory names
  333.      separated by ':' or ';' (Unix or OS/2, respectively) characters. Under
  334.      OS/2, this mechanism is used to locate the RTL object files in place of
  335.      the default location described next for Unix.
  336.  
  337.    o (Unix only) Finally the binder looks in the default location for
  338.      the GNAT Run Time Library (RTL) object files that is determined at the
  339.      time that GNAT is built and installed on your system.
  340.  
  341. The binder generates the bind file (a C language source file) in the
  342. current working directory.
  343.  
  344. The packages Ada, System, and Interfaces and their children make up the GNAT
  345. Run Time Library, togther with the simple IO package used in the "Hello
  346. World" example.  The sources for these units are needed by the compiler
  347. and are kept together in one directory (not all of the bodies are needed,
  348. but all of the sources are kept together anyway).  The ALI files and object
  349. files generated by compiling the RTL are needed by the binder and the linker,
  350. and are kept together in one directory (typically different from the
  351. directory containing the sources).  In a normal installation, the user will
  352. not need to specify these directory names when compiling or binding (or
  353. binding and linking with gnatbl -- though the call to the linker contains
  354. explicit pathnames of the object files).  Either the environment variables
  355. (OS/2) or the builtin defaults will cause these files to be found.
  356.  
  357. Besides the assistance in using the RTL, a major use of search paths is
  358. in compiling sources from multiple directories.  This can make development
  359. environments much more flexible.
  360.  
  361. The user might use the search paths to experiment with alternative RTLs, or
  362. to create new libraries (not the technical Ada meaning here).
  363.  
  364.  
  365. Options.
  366. --------
  367.  
  368. Error reporting, as well as other aspects of the behavior of the system,
  369. are controlled by the following flags. All of these must be entered with
  370. the prefix '-gnat'. For example, '-gnatv83' specifies verbose mode for
  371. output, and Ada83 syntax checking. 
  372.  
  373.   a      Assertions enabled. Pragma Assert and Debug to be activated.
  374.   b      Generate brief messages to stderr even if verbose mode set.
  375.   c      Check syntax and semantics only (no code generation attempted)
  376.   e      Error messages generated immediately, not saved up till end
  377.   f      Full errors. Normally only the first error on each line is reported.
  378.   g      GNAT style checks enabled - col alignment, spacing, capitalization.
  379.       See any source file for examples.
  380.   ix      Identifier char set (x=1/2/3/4/p/f/n/w) default = i1 (Latin-1)
  381.         1-4 = Latin 1-4, p = IBM PC, f/n = full/no, upper w=wide_character
  382.   knnn      Limit file names to k characters (k = krunch)
  383.   l      Output full source listing with embedded error messages
  384.   mnnn      Limit number of detected errors to nnn (1-999)
  385.   n      No inlining of subprograms (ignore pragma Inline)
  386.   p      Automatic suppression of all run-time checks mentioned in LRM 11.7
  387.   r      Reference manual column layout required
  388.   s      Syntax check only
  389.   t      Do semantic processing even if there are syntax errors.
  390.   u      List units for this compilation
  391.   v      Verbose mode. Full error output with source lines to stdout.
  392.   wx      Warning mode. s = suppress, e = treat as error
  393.   83      Enforce Ada 83 restrictions
  394.   sfile      Source file names (wild cards allowed for multiple files)
  395.  
  396. Some of these options are explained in more detail elsewhere in this document.
  397. For full information, refer to file usage.adb in this distribution.
  398.  
  399. For first-time users, and for first-compilation attempts, the following mode
  400. of operation is recommended:
  401.  
  402.       gcc -c -gnatc lets_try_this.adb
  403.  
  404.  
  405.  
  406. Constraint Checking and Pragma Suppress
  407. ---------------------------------------
  408. In the current version there are some checks performed that are mentioned in
  409. the LRM in section 11.7. These are:
  410.  
  411. range checks on signed integer and enumeration types
  412.   (assignment, in parameters and initial values in object declarations)
  413. index checks
  414. access checks
  415.  
  416. Since this is relatively new, there might still be some cases where exceptions
  417. are raised where they shouldn't. To disable constraint checks, compile the
  418. program with the "-gnatp" option. This is equivalent to having Pragma suppress
  419. applied to everything. Gdb can be used to find where the exception was raised.
  420. See the section on  "Using gdb" for further information.
  421.  
  422. Order of Compilation Issues.
  423. ----------------------------
  424.  
  425. If, in our example, there were a spec for the hello procedure, it would
  426. be contained in the file "hello.ads"; yet this file would not need to be
  427. explicitly compiled.  This is the result of the model we chose to implement
  428. library management. Details of the model can be found in file gnote1. Some of
  429. the unexpected consequences of the model (unexpected from the point of view
  430. of existing Ada compiler systems) are the following: 
  431.  
  432.      o    There is no point in compiling generics or specifications (except for
  433.     package specifications with no bodies), since these are compiled as
  434.     needed by clients. If you do attempt a useless compilation, you will
  435.     get a warning message. It is also useless to compile subunits in this
  436.     mode, since they are compiled as needed by the parent.
  437.  
  438.      o    There are no order of compilation requirements, and performing a
  439.     compilation never obsoletes anything. The only way you can obsolete
  440.     something and require recompilations is if one of the relevant source
  441.     files is modified.
  442.  
  443.      o    There is no library as such, apart from the .ali files, whose format 
  444.     is also described in libfmt.ads. For now, we find it convenient to
  445.     create separate .ali files, but eventually the information therein may
  446.     be incorporated into the object file directly.
  447.  
  448.      o    When you compile a unit, the source files for the specs of all 
  449.     units that it WITH's, all its subunits, and the bodies of any
  450.     generics it instantiates must be around (findable by the search
  451.         paths mechanism described above), or you will get a fatal error
  452.     message.
  453.  
  454. The above may seem surprising. Just to provide one immediate assurance,
  455. all of this does not mean that we are violating Ada's strict consistency 
  456. rules; they are enforced instead by the binder. 
  457.  
  458. File Name Rules
  459. ---------------
  460.  
  461. The current version of GNAT requires that file names match compilation unit
  462. names. The matching rules are as follows:
  463.  
  464.      o    The file name is obtained by replacing dots in the unit name with
  465.     minus signs, and adding a suffix distinguishing bodies and specs.
  466.     The suffix for specs is ".ads" and for bodies is ".adb".
  467.  
  468.     For example, the unchecked deallocation files would be called:
  469.  
  470.         unchecked_deallocation.ads
  471.         unchecked_deallocation.adb
  472.  
  473.     in a modern system with no arbitrary file name length restrictions 
  474.     (most systems that support GCC are in this category, e.g., most
  475.     Unixes, OS/2, NT, Nextstep).
  476.  
  477.      o    When running under primitive systems (like OS/2 under FAT) which
  478.     permit only short file names, the file name itself gets crunched
  479.     to 8 characters.  The exact details of the crunching algorithm
  480.     are in the full documentation. You can always find out the name
  481.     it expects by compiling it (since it warns you if it's wrong).
  482.     Briefly:
  483.  
  484.       Only the first and last components of a subunit name are retained
  485.  
  486.       If there are no - or _ characters in the result, it is merely
  487.       truncated to 8 characters.
  488.  
  489.       If there are - or _ characters, then each piece is truncated to
  490.       the same length so that the total is 8 characters, favoring later
  491.       components if there is a character left over.
  492.  
  493.     In OS/2 under FAT, the unchecked deallocation files names would be
  494.     abbreviated:
  495.  
  496.         unc_deal.ads
  497.         unc_deal.adb
  498.  
  499. Of course the DOS-like limitations end up restricting the choice of unit names,
  500. since file names must be unique. As noted earlier, the final system will also
  501. have the option of providing a centralized file name directory (a kind of
  502. vestigial library) to avoid these restrictions, and allow complete freedom
  503. in choice of file names.
  504.  
  505. Compiling Files With Several Compilation Units.
  506. -----------------------------------------------
  507.  
  508. GNAT can only deal with files that contain a single Ada compilation unit.
  509. However, since it is an established style for certain types of programs
  510. to contain more than one compilation in a file, such as in test suites,
  511. a simple utility program, "gnatsplit", is provided to preprocess the file
  512. and split it several other files, one for each compilation unit.
  513. gnatsplit takes a filename with an extension of either "ads" or "adb".
  514. This name can basically be anything.
  515.  
  516. Usage : gnatsplit [-ksw] filename [directory]
  517.  
  518.   k         limit filenames to 8 characters
  519.   s         generate a compilation script
  520.   w         overwrite existing filenames
  521.   filename  source file with .ads or .adb extension
  522.   directory directory to place split files (default is the current directory)
  523.  
  524. For example, assume archive.adb contains package spec part1, package body
  525. part1, package spec part2, package body part2.adb and subprogram part3 in
  526. any sequence.
  527.  
  528. "gnatsplit archive.adb" will create five files in the current directory called
  529. part1.ads, part1.adb, part2.ads, part2.adb, part3.adb. The optional directory
  530. argument places all the split files in that directory rather than the current
  531. directory. The directory must already exist otherwise gnatsplit will reject it.
  532.  
  533. If at least one of the files to be split already exists, gnatsplit will issue a
  534. message and exit unless the -w flag is used to overwrite existing files.
  535.  
  536. The -s flag generates a script which can be used to compile all the units
  537. contained in the original source file.
  538.  
  539. The -k flag krunches the names of the units to be 8 characters followed by the
  540. ads or adb extension.
  541.  
  542. Under OS/2, if you want to specify more than one flag, you need to specify them
  543. separately.  For example, if you want to split archive.adb and specify both the
  544. -s and the -w flags, type "gnatsplit -s -w archive.adb" instead of
  545. "gnatsplit -sw archive.adb".
  546.  
  547. Cross Reference Tool.
  548. ---------------------
  549.  
  550. The GNAT system provides a standalone tool, gnatf, which allows for
  551. syntax and semantics checking without any code generation. This is
  552. somewhat faster than using "gcc -gnatc". However, the real point of
  553. gnatf is that it contains a cross reference (xref) tool.
  554.  
  555. The goal of the xref tool is:
  556.  
  557.  1. Give precise information about all declared entities
  558.     (where they are defined and where they are used).
  559.  
  560.  2. Emit warnings if an entity is defined but never used or
  561.     a with clause is unnecessary, misplaced or redundant
  562.     (more on this later).
  563.  
  564. Usage : gnatf [-x[1-4]] filenames
  565.  
  566.         The -x[1-4] flags controls the amount of information given
  567.         by the xref tool. Flags -x1 and -x2 control the level of
  568.         warnings generated. These warnings are both output on the
  569.         screen and in the xref file, if it's requested with the
  570.         options -x3 or -x4.
  571.  
  572.         Note: the standard gnat options that do not concern code
  573.               generation are still available in gnatf. However,
  574.               they should not be preceeded by -gnat, so to do syntax
  575.               only checking with gnatf, use``gnatf -s file.adb'', not
  576.               ``gnatf -gnats file.adb''.
  577.  
  578. Flags usage:
  579.  
  580.   x1        issues warnings for unnecessary, misplaced or redundant
  581.             ``with'' clauses. Specifically, a warning message is
  582.             generated in the following cases:
  583.               - A compilation unit which is withed but never used.
  584.  
  585.               - A compilation unit which is withed in a body (resp.
  586.                 subunit) if the same with clause already appears in
  587.                 the spec (resp. spec or body for subunits).
  588.  
  589.               - A compilation unit which is withed within a spec
  590.                 but is used only by the body or a subunit.
  591.  
  592.   x2        issues warnings on unused entities, that is entities that
  593.             are declared but never used. Note that we give *no*
  594.             warnings for unreferenced entities like:
  595.               - Record fields, since they could be referenced indirectly
  596.                 by an aggregate.
  597.  
  598.               - Enumeration entities, since they could be referenced
  599.                 indirectly by enumeration ranges:
  600.                      for i in Color'First .. Color'Last
  601.  
  602.               - Loop parameters
  603.                     for i in 1 .. 80 loop
  604.                        Put ('x');
  605.                     end loop;
  606.  
  607.   x3   
  608.   x4        generate a cross-reference table. The only difference between
  609.             -x3 and -x4 is that the option -x4 gives the entity kind for
  610.             every entity appearing in the xref. When the switches -x3 or
  611.             -x4 are activated a cross reference file is created. The name
  612.             of the xref file is ``X.ref''.
  613.  
  614.   filenames is a list of Ada source files. Full GNAT compatibility
  615.             is preserved: For instance, to create the xref for
  616.             a full Ada program it's sufficient to call gnatf with the
  617.             .adb files (bodies), the required specs and subunits are 
  618.             loaded automatically. Likewise, to create the xref for a
  619.             chunk of the program, it suffices to list the appropriate
  620.             .adb files. If you are interested in the xref of a few
  621.             package specs in the program, then "filenames" should consist
  622.             of those specs. Only other withed specs will be loaded and no
  623.             bodies will be examined. 
  624.  
  625.  
  626. Cross reference file structure:
  627.  
  628.   The xref file is divided into various sections. There is one section
  629.   for each compilation unit explicitly requested in ``filenames''. We
  630.   call these units, the RUs, short for requested units.  There is also
  631.   one section for each AU, short for auxiliary unit, that is, those
  632.   compilation units that get implicitly loaded by the compiler, but
  633.   whose compilation has not been explicitly requested by the user.
  634.   Specs of withed packages are typical auxiliary units.
  635.  
  636.   All entities belonging to RUs appear in the xref file. However, only the
  637.   entities defined in AUs that are used in RUs apper in the xref file.
  638.   Their order is the order of declaration in the source files.
  639.  
  640.   The sections in the xref referring to RUs and AUs are respectively denoted:
  641.  
  642.             %%% unit %%%   for a RU.
  643.  
  644.             --- unit ---   for an AU.
  645.  
  646.   Note: An entitiy defined inside a generic and used through a generic
  647.   instantiation, is listed under the xref section of the generic unit.
  648.  
  649.   Example: Follows a list of files and the corresponding cross reference.
  650.   ^^^^^^^
  651.                         test.adb
  652.                         ^^^^^^^^
  653.             01  with Part1;  --  unused
  654.             02  with Part2; use Part2;
  655.             03  procedure Test is
  656.             04
  657.             05     Variable: Number;
  658.             06     type Client is record
  659.             07        Number : Integer;
  660.             08        State  : Boolean;
  661.             09     end record;
  662.             10     type Color is (Red, Green);  -- unused
  663.             11     My_Client : Client;
  664.             12
  665.             13  begin
  666.             14     My_Client.Number := 1;
  667.             15     My_Client.State  := True;
  668.             16     Variable := 20;
  669.             17     Variable := Variable + Variable;
  670.             18  end;
  671.                       part1.ads
  672.                       ^^^^^^^^^
  673.             01  package Part1 is
  674.             02     type Useless is new Integer;
  675.             03  end;
  676.                       part2.ads
  677.                       ^^^^^^^^^
  678.             01  package Part2 is
  679.             02     type Number is new Integer range 1 .. 1000;
  680.             03     The_Number : constant := 42;
  681.             04  end;
  682.  
  683.   The result of invoking ``gnatf -x3 test.adb'' is the following
  684.   (just skim the X.ref, explanations follow):
  685.  
  686.                     Warnings on the screen
  687.                     ^^^^^^^^^^^^^^^^^^^^^^
  688.              "test.adb", line 1(6): warning: "Part1" withed but unused
  689.              "test.adb", line 3(11): warning: "Test" unused
  690.              "test.adb", line 10(9): warning: "Color" unused
  691.  
  692.                            X.ref
  693.                            ^^^^^
  694.              01 %%%% procedure /test/ SPEC & BODY: test.adb %%%%
  695.              02 /test/ 3 >>> Warning: unused <<<
  696.              03 /test#variable/ 5 
  697.              04      test.adb {16 17}
  698.              05 /test#client/ 6 
  699.              06      test.adb {11}
  700.              07 /test#client.number/ 7 
  701.              08      test.adb {14}
  702.              09 /test#client.state/ 8 
  703.              10      test.adb {15}
  704.              11 /test#color/ 10 >>> Warning: unused <<<
  705.              12 /test#red/ 10 
  706.              13 /test#green/ 10 
  707.              14 /test#my_client/ 11 
  708.              15      test.adb {14 15}
  709.              16
  710.              17 ---- package /part1/ SPEC: part1.ads ----
  711.              18 >>> Warning: withed but unused in test.adb <<<
  712.              19 /part1/ 1 
  713.              20      test.adb {1}
  714.              21
  715.              22 ---- package /part2/ SPEC: part2.ads ----
  716.              23 /part2/ 1 
  717.              24      test.adb {2}
  718.              25 /part2.number/ 2 
  719.              26      test.adb {5}
  720.  
  721.   Explanations:
  722.   ^^^^^^^^^^^^
  723.   File ``test'' is the only RU (requested unit). AUs (auxiliary
  724.   units are packages ``part1'' and ``part2''. Entry
  725.  
  726.              03  /test#variable/ 5
  727.              04       test.adb {16 17}
  728.  
  729.   means that ``Variable'' is an entity defined in ``Test'' not visible
  730.   outside the scope of ``Test'' (hence the ``#''). ``Variable'' is
  731.   defined in line 5 and used in lines 16 and 17 in file ``test.adb''.
  732.   When an entity is visible outside its scope the xref puts a ``.''
  733.   instead of a ``#''. For instance
  734.  
  735.              25 /part2.number/ 2 
  736.              26      test.adb {5}
  737.  
  738.   means that ``Number'' is defined in package ``Part2'' at line 2, it's
  739.   visible outside of ``Part2'' and it's used in file ``test.adb'' at
  740.   line 5. Note that entity ``Number'' could be used in units other than
  741.   ``Test'' but that information is not contained in the Xref since it
  742.   was not requested.
  743.  
  744. Implementation of Intrinsic Functions.
  745. --------------------------------------
  746. GNAT version 1.79 begins to implement intrinsic functions. In particular,
  747. the shift functions predefined in Interfaces are now implemented.
  748.  
  749. The implementation is quite general. You can define shift operations (i.e.
  750. one of the five operations, Shift_Left, Shift_Right, Shift_Right_Arithmetic,
  751. Rotate_Left, Rotate_Right) on any integer type, signed or unsigned, whose
  752. Size is 8, 16, 32 or 64 bits, and then provide an appropriate pragma Import
  753. Intrinsic, and everything will work.
  754.  
  755. In other words, the package Interfaces is not using any special magic, and
  756. you can do exactly what it does to make shift operations available for any
  757. integer types that meet the size criteria (shift operations for wierd-sized
  758. integers seem too marginal to worry about!)
  759.  
  760. Example:
  761.  
  762.    type My_Type is new Integer;
  763.  
  764.    function Shift_Left (Val : My_Type; Count : Natural) return My_Type;
  765.    pragma Import (Intrinsic, Shift_Left);
  766.  
  767. The exact requirements on the pragma Import are as follows:
  768.  
  769.   The function must have one of the five standard names
  770.  
  771.   There must be two arguments
  772.  
  773.   The first argument can be of any integer type with a size of 8, 16, 32, 64
  774.   either signed or unsigned.
  775.  
  776.   The return type must be the same as the first argument type
  777.  
  778.   The second argument (the shift count), can be of any integer type
  779.  
  780. Getting Internal Debugging Information.
  781. ---------------------------------------
  782.  
  783. Most compilers have secret internal debugging switches and modes. GNAT is
  784. no exception, except that nothing about GNAT is secret. A summary and full
  785. description of all the compiler/binder debug flags can be found in the file
  786. debug.adb. You will have to get the sources of the compiler to see the full
  787. detailed effects of these, but feel free to experiment with them.
  788.  
  789. The switches that print the source of the program (reconstructed from the
  790. internal tree) are of general interest, as are the options to print the full
  791. internal tree, and the entity table (that is to say, the symbol table
  792. information). 
  793.  
  794. When GNAT crashes. 
  795. ------------------
  796.  
  797. There are several things you can do when GNAT does the unexpected while
  798. compiling your Ada program, such as aborting with a segmentation fault
  799. or illegal memory access, raising an internal exception, or otherwise
  800. terminating abnormally. The following lines of action are of course
  801. palliatives that will become unecessary as the system becomes more complete
  802. and robust. The following strategies are presented in increasing order of
  803. difficulty, corresponding to the sophistication of the user, and her
  804. curiosity about the functioning of the compiler.
  805.  
  806.   1. run gcc with the -gnatf and -gnate switches.
  807.      The 'f' switch causes all errors on a given line to be reported. In
  808.      its absence, only the first error on a line is displayed. 
  809.  
  810.      The 'e' switch causes errors to be displayed as soon as they are 
  811.      encountered, rather than after compilation is terminated.
  812.  
  813. Often this will be enough to identify the construct that produced the crash.
  814.  
  815.   2. run gcc with -v (verbose) switch. In this mode, gcc produces ongoing 
  816.      information about progress of the compilation and in particular the name 
  817.      of each procedure as it begins to generate code for it. This switch
  818.      allows you to find which Ada procedure it was compiling when it ran into 
  819.      a code generation problem. 
  820.  
  821.   3. run gcc with the -gnatdc switch. This is a GNAT-specific switch that
  822.      does for the front-end what -v does for the back-end. The system prints
  823.      the name of each unit, either compilation unit or nested unit, as it
  824.      is being analyzed. 
  825.  
  826.   4. On systems that have gdb available (like most Unix systems), you can run
  827.      gdb directly on the gnat1 executable. Gnat1 is the front-end of
  828.      GNAT, and can be run independently (normally it is just called from gcc).
  829.      You can use gdb on gnat1 as you would on a C program (but see below for
  830.      caveats). The "where" command is the first line of attack; the variable
  831.      "lineno"  (seen by "print lineno") used by the second phase of gnat1
  832.      and by the gcc back-end, indicates the source line at which the execution
  833.      stopped, and "input_filename" the name of the source file.
  834.  
  835. Using gdb on systems that provide it (currently not available under OS/2)
  836. -------------------------------------------------------------------------
  837.  
  838. Gdb awaits modifications to handle Ada properly, and for now can only be
  839. used as it would be for a c program. (Someone is working on the proper
  840. extensions, and these will appear in subsequent releases.) In the meantime,
  841. the following naming conventions will allow you to find the Ada entities
  842. defined in your program:
  843.  
  844. a)  The names of all entities (variables, subprograms, etc.) are converted to
  845.     lower case. 
  846.  
  847. b)  Entities that appear in library package declarations have the name
  848.     package_name__subprogram_name (Note the two underscores separating 
  849.     package name from subprogram name). 
  850.  
  851. Exceptions can be caught by breaking in the "catch_except" routine and then
  852. doing a "bt" or "where" command.
  853.  
  854. Features supported/unsupported
  855. ------------------------------
  856. A full listing of features supported/unsupported is available separately in
  857. the file "features" included in the distribution. Note that this usually
  858. changes with each distribution, so read often.
  859.  
  860. Files.
  861. ------
  862.  
  863. If you want to examine the workings of the GNAT system, the following
  864. haiku-like description of its organization might be of minimal use:
  865.  
  866. File with prefix "sc" contain the lexical scanner.
  867.  
  868. All files prefixed with "par" are components of the parser. The numbers 
  869. correspond to chapters of the Ada83 LRM (or the corresponding sections of 
  870. the Ada9X LRM).  For example, parsing of select statements can be found 
  871. in par-ch9.
  872.  
  873. All files prefixed with "sem" perform semantic analysis. Same numbering scheme.
  874. For example, all issues involving context clauses can be found in sem_ch10.
  875.  
  876. All files prefixed with "exp" perform AST normalization and expansion. 
  877. For example, the construction of record initialization procedures is 
  878. done in exp_ch3.
  879.  
  880. The files prefixed with "bind" implement the binder, which verifies the
  881. consistency of the compilation, determines an order of elaboration, and
  882. generates the bind file.
  883.  
  884. The file atree details the low-level data structures used by the front-end.
  885. The file sinfo details the structure of the AST as produced by the parser.
  886. The file einfo details the attributes of all entities, computed during
  887. semantic analysis.
  888.  
  889. Library management issues are dealt with in files with prefix "lib".
  890.  
  891. Files with prefix a- are GNAT-specific C files. They are the components of
  892. Gigi (gnat-to-gnu), the program that translates the Ada AST into gcc tree 
  893. fragments. Gigi makes use of C versions of atree, einfo and sinfo, called 
  894. a-atree.[ch], a-einfo.[ch] and a-sinfo.h respectively.
  895.  
  896. All the other .c files are modifications of common GCC files. 
  897.  
  898. Happy browsing!
  899.  
  900.  
  901. Copyright Considerations
  902. ------------------------
  903.  
  904. For now, everything is copyrighted by NYU, using the GNU public license. This
  905. means that you can copy everything freely, but you can't incorporate the code
  906. directly into a commercial program. For more information on the GNU license,
  907. see the file header. One important note is that it will be possible
  908. to use GNAT to generate software that is not itself covered by the GNU license.
  909. Eventually the copyright will be transferred to the Free Software Foundation,
  910. so that GNAT can be distributed directly by FSF under the same restrictions (or
  911. what we like to think of as lack of restrictions!).
  912.  
  913. How to Get in Touch with Us
  914. ---------------------------
  915.  
  916. To get on our external INTERNET mailing list, send a message to:
  917.  
  918.     gnat-request@cs.nyu.edu
  919.  
  920. SUBMITTING BUG REPORTS
  921.  
  922. We welcome bug reports, they are of course a vital part of the process of
  923. getting GNAT into solid shape. You will help us (and make it more likely
  924. that you receive a timely response) if you follow these guidelines.
  925.  
  926. We only receive bug reports by internet, addressed to gnat-report@cs.nyu.edu.
  927. At the moment we cannot process bug reports from any other source.
  928.  
  929. Please put one bug in a message, and add a short but specific subject (a
  930. general subject like "GNAT bug" is not so useful, a title like "bug in
  931. visibility with generics" is more useful).
  932.  
  933. Please include full sources. We can't duplicate errors without the full
  934. sources. Include all sources in the single email message with appropriate
  935. indications in the multiple file cases, see below.
  936.  
  937. Please send all sources in plain ASCII form, we can't process compressed,
  938. uuencoded etc. messages in our current form (they have to go through extra
  939. steps, and easily get lost, separated from the author etc during this process).
  940.  
  941. Please include COMPLETE identification of the version of the system you are
  942. running.
  943.  
  944. To be maximally helpful, for a report that contains multiple separate
  945. compilation units, and hence multiple files, submit them in the form of
  946. a single file that is acceptable input to gnatsplit, i.e. contains no
  947. non-Ada text. If you use banners to separate the files, make sure they
  948. are composed entirely of blank lines or Ada comments.
  949.  
  950. If you want to be maximally helpful, try to reduce your example to a simple one
  951. but DON'T spend too much time doing this. Especially when you are reporting
  952. a blow up during compilation, rather than bad code generated, we can in 
  953. practice work with big sources if you have trouble narrowing things down.
  954.  
  955. When we receive a bug report, we take a preliminary look to categorize it
  956. into one of the following:
  957.  
  958.    1.  Pilot error, documentation problems, installation problems etc.
  959.  
  960.    2.  Interesting comment, suggestion etc, but not a bug
  961.  
  962.    3.  Bug that we already know about
  963.  
  964.    4.  Bug that is already fixed in our development version
  965.  
  966.    5.  Obvious bug that we correct immediately in our development version
  967.  
  968.    6.  Real genuine new unfixed bug.
  969.  
  970. In the first 5 cases, you will get a message telling you the status. In the
  971. 6th case only, we assign a bug tracking number of the form mmdd-nnn, where
  972. mmdd is the date of receipt, and nnn is a serial number (highest value so
  973. far 005, but you never know!) In this case, the release notes will tell you
  974. what the status of the bug is, and also we will send you a message when it
  975. is fixed.
  976.  
  977. To send reports to us on the system, or ask questions, send messages to
  978.  
  979.     gnat-report@cs.nyu.edu
  980.  
  981. To contact team members, send messages to:
  982.  
  983.     dewar@cs.nyu.edu
  984.     schonberg@cs.nyu.edu
  985.  
  986. To obtain electronically the latest version of the system, FTP from:
  987.  
  988.     cs.nyu.edu (directory pub/gnat)
  989.  
  990. This FTP directory also includes full sources for the system, full
  991. documentation and technical notes, as well as executables of the system
  992. for several targets. We are sorry that our limited resources do not allow
  993. us to distribute the system through other media.
  994.  
  995. We trust that this information will be mirrored at other FTP sites around 
  996. the world (we encourage such mirroring to occur), which will make it easier
  997. for users in other continents to obtain the GNAT system without heavy
  998. communication uncertainties.
  999.  
  1000. Schedule.
  1001. ---------
  1002. We will make available new releases of GNAT at 2 or 3 week intervals for the
  1003. time being. Please recall that releases of the system are still only snapshots
  1004. of work in progress. We hope that it will be of some use in the work of others,
  1005. even in its current embryonic form. 
  1006.  
  1007. A short gnat paper
  1008. ------------------
  1009. A TeX file of a short paper describing something about the GNAT project is
  1010. included under the name gnat-paper.tex.
  1011.  
  1012. The GNAT development team.
  1013. ---------------------------
  1014.  
  1015.     New York University
  1016.  
  1017.          Bernard Banner (*)
  1018.          Cyrille Comar (*)
  1019.          Robert Dewar (*)
  1020.          Sam Figueroa (*)
  1021.          Richard Kenner (*)
  1022.          Bruno LeClerc (*)
  1023.          Brett Porter (*)
  1024.          Gail Schenker (*)
  1025.          Edmond Schonberg (*)
  1026.  
  1027.     Florida State University (Tasking runtime work)
  1028.  
  1029.          Ted Baker
  1030.          Ted Giering (*)
  1031.          Frank Muller
  1032.  
  1033.     Ecole Nationale Superieure de Telecommunications
  1034.  
  1035.          Franco Gasperoni (*)
  1036.          Yvon Kermarrec
  1037.          Laurent Pautet
  1038.  
  1039.     Elsewhere
  1040.  
  1041.          Paul Hilfinger (*) (University of California, Berkeley)
  1042.          Jean Pierre Rosen (*) (Paris)
  1043.          Richard Stallman (Free Software Foundation)
  1044.  
  1045. (*) partially supported by the NYU GNAT project
  1046.     (ARPA, USAF, AJPO, Ada 9X project office)
  1047. 
  1048.