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