A number of aids to fault finding are included in the compiler. A broad outline of the structure of the program is output on output stream 0, together with details 0f syntactic and semantic faults detected by the compiler, if any. Faults found during execution whether by the Supervisor, extracodes, hardware, or the compiled program itself produce, besides the standard Supervisor printing when appropriate, an error trace of activated blocks and procedures with the values of certain variables and parameters.
The first few lines of each output stream are produced by the Supervisor; details can be found in section 3.4. On output stream 0 there follows the name and date of the compiler used, thus:
ALGOL 9 APR 1965
and a brief outline of the program, with details of faults found during compiling. After that comes output, if any, from the compiled program, and finally more Supervisor printing (see section 3.4 again).
Program faults detected by the compiler fall roughly into two categories - faults of syntax, and failures to obey the semantic rules and restrictions of the language. An Algol program is read, and its syntactic structure analysed, by using compiler compiler techniques. Any violation of syntactic rules will result in failure to recognize a valid structure at some point in the program; if such a failure occurs the type of fault and the basic symbols of the program from the point of failure up to the next semicolon or end symbol are noted and output at the appropriate point in the monitor outline (see 3.1.1.3). Compilation is continued from the semicolon or end symbol onwards: in this way further faults in the program will be detected.
Faults of this type are monitored in the form
<syntactic unit> NOT RECOGNISED <error>
(see section 3.1.2).
After the syntactic analysis, compilation proceeds. During this second stage, certain monitoring information is printed: in particular a broad outline of the program is produced, in the form of a note of the beginning and end of each block, procedure and compound statement. Serially allocated reference numbers are associated with each block and procedure; they are used in the error trace after a fault during execution (see section 3.4). Details of any semantic faults in the program are printed as they are found, together with syntactic faults detected in the previous stage, and by comparing the monitor outline with the original program the programmer should be able to locate the faults rapidly.
A typical monitor outline for a short program is as follows:
6920 BEGIN BLOCK : 21 PROCEDURE SIMPSON : 22 BEGIN BLOCK : 23 BEGIN COMPOUND STATEMENT END OF COMPOUND STATEMENT END OF BLOCK END OF PROCEDURE BEGIN BLOCK : 24 BEGIN COMPOUND STATEMENT UNDECLARED IDENTIFIER AT LEVEL 3 K END OF COMPOUND STATEMENT STATEMENT NOT RECOGNISED DELTA = 0 END OF BLOCK END OF BLOCK PROGRAM FAULTY
The number '6920' appearing at the head of the monitor outline is the size of the analysis record in half-words.
The monitor outline ends with 'PROGRAM FAULTY' if faults are found, in which case the job is ended, and with 'PROGRAM ENTERED' otherwise.
The next section contains a list of possible messages for faults detected by the compiler, with references to the sections of the revised report (in parentheses) or of this manual (no parentheses) where the rule which has been broken can be found.
Reference Monitor Printing 2.3.4,(4.7.5) ACTUAL PARAMETER DOES NOT CORRESPOND TO FORMAL PARAMETER <identifier> OF PROCEDURE <identifier> (5.2.1) ARRAY DECLARATION NOT RECOGNISED <error> (3.1.4) ARRAY <identifier> APPEARS WITH WRONG NUMBER OF SUBSCRIPTS (3.4.1) BOOLEAN EXPRESSION NOT RECOGNISED <error> (3.1.4) BOOLEAN IDENTIFIER IN SUBSCRIPTED ELEMENT 4.1 CODE INSTRUCTION NOT RECOGNISED <error> (5) DECLARATION NOT RECOGNISED <error> 2.4.1 DYNAMIC OWN ARRAY (4.6.1) FOR LIST NOT RECOGNISED <error> 2.4.4 FORMAL PARAMETER, WHICH IS A PROCEDURE, HAS NO ACTUAL PARAMETER WHICH MAY BE SUBSTITUTED FOR IT 2.4 IDENTIFIER <identifier> DEFINED TWICE 2.4 IDENTIFIER <identifier> ALREADY DEFINED IS NOW USED AS A LABEL IDENTIFIER <identifier> NOT AMONGST FORMAL PARAMETERS (3.5.3) IDENTIFIER <identifier> OUT OF CONTEXT IN DESIGNATIONAL EXPRESSION IDENTIFIER <identifier> USED IN WRONG CONTEXT (3.3.4) IDENTIFIER OF WRONG TYPE IN ARITHMETIC EXPRESSION (3.4.4) IDENTIFIER OF WRONG TYPE IN BOOLEAN EXPRESSION (4.2.4) ILLEGAL IDENTIFIER IN LEFT PART LIST: <identifier> 2.4.5 (5.4.1) (5.3.5) ILLEGAL SPECIFICATION IN PROCEDURE <identifier> 4.1 LABEL NOT SET <code label> 4.1 LABEL SET TWICE <code label> (4.2.4) MIXED EXPRESSIONS IN LEFT PART LIST 2.4.5 NO ASSIGNMENT TO FUNCTIONAL PROCEDURE (4.1.1) PROCEDURE NOT TERMINATED BY SEMI-COLON (4) STATEMENT NOT RECOGNISED <error> (5.3.1) SWITCH DECLARATION NOT RECOGNISED <error> 2.4.3 UPPER BOUND < LOWER BOUND IN OWN ARRAY (4.7.4) WRONG NUMBER OF ACTUAL PARAMETERS IN CALL FOR PROCEDURE <identifier>
Here <error> means the basic symbols of the program at the point of failure.
If the Algol program is successfully compiled, execution will begin. Certain faults during execution are detected by Atlas hardware, the Atlas supervisor program (including extracodes), or the compiled program itself; for instance, an attempt to find the logarithm of a negative number will cause a monitor message to be printed and the program to be suspended.
After a fault during program execution, diagnostic information is provided in the following order.
(a) Error message
(b) Contents of output buffer
(c) An 'error trace' of the sequence of activation of blocks and procedures backwards from the point of error. This brief information is now considered in more detail.
For faults detected by hardware or Supervisor, the error message is the standard Supervisor post mortem printing. This consists of a heading describing the fault, a print of the 3 Atlas instructions in the program at the point of failure with the values of B-lines mentioned in them, a print of the contents of the B-lines, and the positions of all magnetic tapes in use at the time of failure.
Full information on the standard Supervisor post mortem, and a complete list of fault headings, with explanations, can be found in CS348A, section 11.1. The list of headings is reproduced as Appendix 3. Most of these faults will generally occur in Algol programs only in code procedures, if at all; the others are described here.
Fault Reference Fault heading Division overflow: an attempt to 2.2.2, 2.2.5 DIV OVERFLOW divide by 0 Exponent overflow: an attempt to 2.2.6, 2.4.2 EXP OVERFLOW evaluate a real or integer expression with value out of range Call of sqrt(E) with 2.2.2 SQ RT -VE ARG E<0 Call of ln(E) with 2.2.2, 2.2.5 LOG -VE ARG E≤0 Attempt to read after the end of INPUT ENDED Input stream Attempt to exceed store allocation 1.3.6 EXCESS BLOCKS Computing time expired 1.3.5 C TIME EXCEEDED Call of select input(n) 5.2.1, 1.3.1 INPUT NOT DEFINED with n undefined Call of select output(n) 5.2.1, 1.3.2 OUTPUT NOT DEFINED with n undefined Too much output 1.3.1 OUTPUT EXCEEDED
The last 5 all refer to sections of the job description; see section 0.3.
Certain types of fault are found by the compiled program itself. In these cases the error message is a heading from the list below.
Fault Reference Monitor printing Illegal composite character in data 5.2.2 ILLEGAL COMPOSITE CHARACTER Array upper "bound less than lower 2.4.3 ARRAY UB<LB bound data Illegal data found by read 5.2.2.1 DATA FAULT CHARACTER = <character> Illegal assignment statement (4.2) ILLEGAL ASSIGNMENT Array bound exceeded (only if array 6.4 ARRAY BOUND EXCEEDED bound check compiled) Illegal data found by read Boolean 5.2.2.2 BOOLEAN DATA FAULT. CHAR. = <character>
Output is handled by the compiled program through a one-line buffer, the contents of which are passed to the output stream when a newline character is called for. Consequently, following a fault, an incomplete line of output will in general remain to be printed after the error message.
This trace refers to blocks and procedures by means of the serial numbers allocated by the compiler and printed as part of the monitor outline of the program (see section 3.1.1.3) and consists of the number of the block or procedure in which the fault occurred, followed by the number of the block or procedure from which that block or procedure was activated or called, and so on back to the outermost level of the program.
Following each block number the current values of the last set of integers and the last set of real quantities declared in the block head are output, in that order. (Values of array elements are not output.) Integer values, if any, are printed eight per line in an integer format and real values, if any, are printed seven per line in a standard floating point format.
It should be noted that only the last declarations of each type in the block head are considered. Thus if a fault occurs in a block whose heading is begin real a; integer k; real b, c; integer l, m, n; the values of l, m, n will be printed on one line, followed by the values of b, c on another, and values of k and a will not appear.
If a variable has no defined value at the time of the fault, the value printed is of no significance.
Following each procedure number the contents of information words, one of which corresponds to each actual parameter, are printed as if they were real numbers. The values are significant only in the case of expressions substituted for formal parameters called by value. If a parameter is of type Boolean then false will be represented by zero and true by a non-zero number.
In the case of standard faults (those listed in Appendix 3) when it is possible for a few instructions beyond the faulty one to have been obeyed before the program is halted, there is a chance that the block in which the fault occurred will be left. In that case, information relating to the block is lost.
The standard functions and input/output procedures are declared in a block of permanent material enclosing the program. The serial numbers currently assigned to these listed in Appendix 4.
As an example, consider the following skeleton program (a corrected version of the program that gave the monitor printing in section 3.1.1.3)
begin real delta; real procedure Simpson (x0, x1, f, C); value xO, xl, X; real x0, xl; real procedure f; Boolean C; comment Simpson integrates the real function f from x0 to x1, unless C if false when Simpson is set to zero. Step length delta is global; begin real x, y; integer i; Boolean B; ........ x:=xQ; B:=true; ........ for i:=0, i+delta while B do begin ......... y:=f(x); .......... end; ........ end Simpson; ............. begin real X0,X1; integer i; real K; .......... for i:=l step 1 until 10 do begin ......... X0:=3-i; X1:=3+i; K:=Simpson (X0,X1, sqrt, X0≠Xl); newline (l); print (1,2,0); print (K,0,4); ......... end; ............ end; ......... end
The program will be monitored during the 4th call of Simpson, when X0=-1. The output following the monitor outline is as follows.
1 3.4477 2 6.7869 SQ RT -VE ARG INSTR 565 113,0 ,2 ,2 B2 = 262181 INSTR 566 1710,0 ,2 ,4 B2 = 262181 INSTR 567 356,0 ,2 ,3 B2 = 262181 B1 = 262161 B2 = 262181 B3 = 262150 B4 = 262170 B69 = 1 B71= 3357 B72 = 1897 B73 = 535114 B74 = 525013 B75= 279 B76 = 524984 B77 = 1 B79 = 737 B80= 0.4 B82 = 4 B83 = 0.4 B84 = 2.4 B85= 1062 B86 = 1 B89 = 1064.4 B90 = 262186 B91= 2.4 B92 = 1728.2 B93 = 1728.2 B94 = 394.4 B95= 4 B96 = 1044754 B97 = 130560.1 B98 = 2549.4 B99= 5 3 -9.7980 3 -1.00000000 ; 23 0 -1.00000000 ; 0.00000000α 0; 22 -1.00000000 ; 7.00000000 ; 8.53275299α -1 ; 2.44140625α -4; 24 4 9.79795897 ; 21 1.00000000α -3;
The meaning of the lines of output are as follows
Lines 1, 2 output from program line 3 fault heading lines 4 to 6 last 3 Atlas instructions lines 7 to 14 contents of B-lines line 15 contents of output buffer line 16 serial number of procedure sqrt line 17 value of actual parameter x line 18 Serial number of first inner block line 19 value of local variable i line 20 values corresponding to x (its value) and y (meaningless, no value) line 21 serial number of procedure Simpson line 22 values corresponding to actual parameters X0, X1 (their values), sqrt (meaningless), and X0≠X1 (non-zero signifying true) line 23 serial number of second inner block line 24 value of local variable i line 25 value of local variable K line 26 serial number of outer block
At the head of each output stream the Supervisor prints
<supervisory number>/<date> <time> OUTPUT <stream number> <job title>
Each item on the first line is 3 2-digit numbers separated by full stops.
At the foot of output stream 0 the Supervisor prints
<job title> DATE <date> TIME <time> SERIAL NUMBER <serial number> REQUESTED USED COMPILE INSTRUCTION INTERRUPTS <interrupts requested> <total interrupts> <interrupts in compiling> COMPILE STORE <blocks requested> <blocks used> EXECUTION STORE <blocks requested> <blocks used> DECKS BLOCKS WAITING MAGNETIC TAPES <decks reserved> <blocks transferred> <seconds waiting> IBM MAGNETIC TAPES <decks reserved> <blocks transferred> <seconds waiting> STORE TIME DRUM TIME DECK TIME <blocks x seconds> <seconds> <decks x seconds> COMPILER NUMBER <compiler number> FAILURE NUMBER <failure number> INPUT <stream number> <blocks of well> BLOCKS <reader> (one line above for each input stream) OUTPUT <stream number> <amount> <equipment> (one line above for each output stream)
Here each syntactic unit is an unsigned integer except <job title>, <date> and <time> which are as above, <reader> which is followed by an octal number giving the particular input peripheral used, <amount> which is as <output limit> in 6.1.2.2, <equipment> which is as in 6.1.2.2, and <failure number> which can have a 1-digit octal fraction.
If an output stream is broken into n parts (n > 1) then n SECTIONS appears after <equipment> on the appropriate OUTPUT line. If no 1" or ½" magnetic tapes are used the appropriate line or lines do not appear. The fault number is the contents of B91 on entering the Supervisor monitor routine, in decimal (see Appendix 3).
This Supervisory output is repeated on the next page of output stream 0; the 2nd page is used for administrative purposes. Local variations, especially additional statistics, are possible at each installation.
The last line of each output stream, including stream 0, is
END OUTPUT <blocks output> BLOCKS
The job description is outline in 1.3.8 and 3.1.4 with one output stream only, gives the following Supervisor printing.
At the head of output 0:
00.00.20/ 03.09.65 23.01.18 OUTPUT 0 F5025 SJD ICT PP SIMPSON TEST 2
Followed by the name and date of the compiler, size of analysis record, and monitor outline (see sections 3, 3.1.1.3). At the foot output appears:
F5025 SJD ICT PP SIMPSON TEST 2 DATE 03.09.65 TIME 22.58.46 SERIAL NUMBER 170267 REQUESTED USED COMPILE INSTRUCTION INTERRUPTS 200 173 107 COMPILE STORE 54 54 EXECUTION STORE 15 12 STORE TIME DRUM TIME DECK TIME 53 4 0 COMPILER NUMBER 12 FAILURE NUMBER 2.4 INPUT 0 1 BLOCKS READER 161 OUTPUT 0 104 RECORDS LINE PRINTER
This output is repeated on the next page, followed by several blank lines and
END OUTPUT 1 BLOCKS