5.1.8 Raising Exceptions

Raising General Exceptions

A thread may raise a general exception in its own context by calling a system library routine defined as follows:

RtlRaiseException( ExceptionRecord )

Arguments

ExceptionRecord  

The address of a primary exception record.

Function Value

None

Remarks

RtlRaiseException() sets ExceptionAddress to the address of the invoking call instruction.

If RtlRaiseException() detects that the exception record passed via the first argument is not a valid exception record, it raises the exception STATUS_INVALID_EXCEPTION.

Raising General Exceptions Using GENTRAP

The Alpha System Reference Manual defines a GENTRAP PALcall, which provides a means for software to raise hardware-like exceptions at minimum cost.

This mechanism is suitable for use in low levels of the operating system or during bootstrapping when only a limited execution environment may be available. In a constrained environment, the GENTRAP can be handled directly via the SCB Vector by which the trap is reported. In a more complete environment, the GENTRAP parameter is transformed into a corresponding exception code and reported as a normal hardware exception. Because of this, low-level software can use this mechanism to report exceptions in a way that is independent of the execution environment. Compiled code may also use this means to raise common generic exceptions more cheaply than making a full procedure call to RtlRaiseException.

The PALcall is defined as follows:

GENTRAP( EXPT_CODE )

Arguments

EXPT_CODE  

Code for the exception to be raised.

Remarks

If the EXPT_CODE value is one of the small negative values shown in the following table, then that value is mapped to a corresponding Windows NT for Alpha Systems exception code as shown. Otherwise, STATUS_ALPHA_GENTRAP is raised with the unmapped value included in the exception record as the (first and only) qualifier value. Note that there is no means to associate any parameters with an exception raised using GENTRAP.

GENTRAP sets ExceptionAddress to the address of the PALcall instruction.

EXPT_ CODE
Symbol

Status code
-1 GENTRAP_INTEGER_OVERFLOW STATUS_INTEGER_OVERFLOW
-2 GENTRAP_INTEGER_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
-3 GENTRAP_FLOATING_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
-4 GENTRAP_FLOATING_OVERFLOW STATUS_FLOAT_OVERFLOW
-5 GENTRAP_FLOATING_UNDERFLOW STATUS_FLOAT_UNDERFLOW
-6 GENTRAP_FLOATING_INVALID_OPERAND STATUS_FLOAT_INVALID_OPERATION
-7 GENTRAP_FLOATING_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
-14   STATUS_STACK_OVERFLOW
-18   STATUS_ARRAY_BOUNDS_EXCEEDED

Raising Unwind Exceptions

The mechanism used to raise an unwind exception is described in Section 5.2, Unwinding.