Overview
Run-time errors are primarily handled by module RuntimeErrors
. This includes errors caught be compiler-inserted checks, such as division by zero, or array index out of bounds, as well as faults triggered by the MCU hardware itself (hard fault, bus fault, etc.).
The Astrobe compiler uses the SVC system exception to signal a run-time error. The hardware uses the different corresponding system exceptions available in the MCU. Module RuntimeErrors
installs corresponding handlers at initialisation.
Separation of Error Handling and Output
Since a control program must be able to run unattended, that is, without any human operator present, possibly even without a terminal attached, RuntimeErrors
does not do any error message printing. Rather, the error and fault handlers collect the information in a data structure, which they will pass on to a user-installable handler.
That handler can then log the error and its data, print it (or both), or even attempt to recover from the error, eg. by resetting the offending processor, or both. Module RuntimeErrorsOut
provides a compatible handler that prints out the error information.
Data Structures
There can only occur one run-time error at any specific time – per core. Hence RuntimeErrors
has two corresponding data structures available per processor core, which it allocates at initialisation, one for run-time errors (SVC), and one for MCU faults.
Error Data
Which data is being collected upon errors can be configured from software in RuntimeErrors
:
- stacked registers
- current registers
- stack trace