When a run-time error is detected, the system generates a numbered trap. The information included with the trap can be used to diagnose the problem. Especially useful is the module and procedure name and PC location where the trap occured. This allows a programmer to find the exact location in the source code using the \f option of the compiler. Here is an example of a trap viewer:
TRAP 7 Index out of range
TestHalt2.Index PC = 352
a = ""
i = 3
Oberon.Call PC = 4646
It can be interpreted as follows:
Trap numbers fall into the following ranges:
- Trap number 7 is an index out of range trap. This means some array index expression was out of range in the program. This could be the cause of incorrect input, or an error in the program. Well-written programs should not generate traps, but rather should check their input, display an informative message, and exit cleanly when a problem is found.
- The error occured in module "TestHalt2", procedure "Index", at offset 352 in the module. A programmer can use the command Compiler.Compile *\f to find the error in the source code of the module (TestHalt2.Mod).
- The values of some local variables in the procedure are displayed with the trap. This information may be useful to a programmer.
- A stack traceback is displayed. This shows how the procedure "TestHalt2.Index" was reached. In this case it was called from the procedure "Oberon.Call".
More detailed information about specific traps:
- Traps -39 to -32 are generated by the floating-point unit of the processor. By default floating-point checks are disabled and the special overflow and error values INF and NaN are generated (see module Reals).
- Traps -31 to 0 are generated by the processor.
- Traps 1 to 10 are generated by compiler-inserted checks.
- Traps 11 to 19 are generated by system modules.
- Traps 20 and above are generated by HALT or ASSERT statements.
26 Aug 2001 - Copyright © 2001 ETH Zürich. All rights reserved.
- TRAP -35 Floating-point stack fault: The floating-point unit made an incorrect memory reference.
- TRAP -34 Floating-point operation invalid: The floating-point stack overflowed or underflowed, or an invalid arithmetic operand was encountered (disabled by default).
- TRAP -33 Floating-point overflow: Caused by an arithmetic overflow (disabled by default).
- TRAP -32 Floating-point division by 0: Caused by an attempt to divide by 0 (disabled by default).
- TRAP -16 Floating-point error: Generic floating-point error.
- TRAP -14 NIL reference / Stack overflow / Page fault: An incorrect memory reference occured. This could be the result of a NIL pointer reference or a stack overflow.
- TRAP -13 General protection fault: This is a generic exception generated by the processor. Refer to the processor documentation for more information.
- TRAP -12 Stack overflow: An incorrect memory reference occured in a stack segment.
- TRAP -6 Invalid instruction: An invalid machine instruction was encountered. This could be the result of a corrupted module in the heap.
- TRAP -4 Overflow: An integer overflow. These checks are disabled by default and can be enabled with the \v switch of the compiler.
- TRAP 0 Division by zero: A DIV (or MOD) by 0 occured, or the result of a divide was too big for the destination type.
- TRAP 1 WITH guard failed: The type guard in a WITH statement failed (can be disabled with the \t compiler switch).
- TRAP 2 CASE invalid: A CASE expression evaluated to a value that has no label, and the CASE has no ELSE clause.
- TRAP 3 RETURN missing: A function procedure ended without a RETURN statement.
- TRAP 4 Overflow: See TRAP -4.
- TRAP 5 Implicit type guard failed: An implicit type guard generated as part of an assignment failed (can be disabled with the \t compiler switch).
- TRAP 6 Type guard failed: An explicit type guard failed (can be disabled with the \t compiler switch).
- TRAP 7 Index out of range: An array index was out of range (can be disabled with the \x compiler switch).
- TRAP 8 ASSERT failed: A programmed ASSERT statement failed (can be disabled with the \a compiler switch).
- TRAP 9 Array dimension error: A dynamically computed array dimension was incorrect (e.g. negative dimension in a NEW).
- TRAP 13 Keyboard interrupt: A keyboard interrupt was generated with Ctrl-Break.
- TRAP 14 Out of memory: The requested memory allocation (NEW) could not be fulfilled.
- TRAP 15 Bad sector number: An incorrect sector number was detected. This could be the result of an error with on-disk file system structures, or memory corruption.
- TRAP 16 Disk full: The disk is almost full. Reboot to have the disk garbage collector run during startup.
- TRAP 17 Disk error: The disk driver encountered a hardware error. The local variable "err" or "res" contains further information.
- TRAP 18 File too large: A file was generated that is too large for the file system.
- TRAP 19 Buffer overflow: Generated by Files.ReadBytes and WriteBytes if the supplied buffer is too small.
E-Mail: oberon-web at inf.ethz.ch