5.1.5 Exception Records

The fundamental data structure for describing exceptions is the exception record.

Exception records can form a linked list. Each record in a list describes one exception.

The first exception record in the list describes the primary exception. Additional secondary exceptions may be specified by additional exception records in the list. Secondary exceptions qualify or elaborate the primary exception; they may be raised at the same time as the primary exception, or a handler may add new secondary exceptions to the list before handling or reraising the exception.

Storage for exception records may be allocated in read-only memory. The exception record that is passed to a handler is a separate copy constructed from information in the original exception record augmented with additional information.

Exception records are defined as shown in Figure 5-2.

Figure 5-2   Exception Record Format

EXCEPTION_RECORD                                 longword-aligned
+---------------+---------------+---------------+---------------+
|                         ExceptionCode                         | :0
|                                                               |
+---------------+---------------+---------------+---------------+
|                         ExceptionFlags                        | :4
|                                                               |
+---------------+---------------+---------------+---------------+
|                        ExceptionRecord                        | :8
|                                                               |
+---------------+---------------+---------------+---------------+
|                        ExceptionAddress                       | :12
|                                                               |
+---------------+---------------+---------------+---------------+
|                        NumberParameters                       | :16
|                                                               |
+---------------+---------------+---------------+---------------+
|                      ExceptionInformation[0]                  | :20
|                                                               |
+---------------+---------------+---------------+---------------+
                             .......
+---------------+---------------+---------------+---------------+
|            ExceptionInformation[NumberParameters-1]           | :x
|                                                               |
+---------------+---------------+---------------+---------------+

sizeof(EXCEPTION_RECORD) == 80

ExceptionCode .

A status value5.1.4_Status_Values_and_Exception_Codes.

ExceptionFlags .

A bitfield of flags that further qualify the exception. These flag bits are significant only in the primary exception record; their state is unpredictable in secondary exception records. ExceptionFlags bits are divided into two groups. The first group (called detail flags) provide additional information about the exception. The second group (called environment flags) provide additional information about the environment in which the exception is being delivered.

Valid ExceptionFlags bits that give additional detail are:

  • EXCEPTION_NONCONTINUABLE   If 1, an exception handler must not return ExceptionContinueExecution.

  • EXCEPTION_EXIT_UNWIND   If 1, the exception handler is being invoked because of an unwind operation that will terminate execution of the thread.

  • EXCEPTION_UNWINDING   If 1, the exception handler is being invoked because of a general unwind operation (with the semantics of longjmp()).

Valid ExceptionFlags bits that give additional information about the environment at the time of exception delivery are:

  • EXCEPTION_NESTED_CALL   If 1, an exception or unwind is in progress at the time this exception is delivered.

  • EXCEPTION_STACK_INVALID   If 1, the stack is invalid.

    Note   This flag is for use by system software, and it will never be 1 in an exception record delivered to a normal handler.

  • EXCEPTION_TARGET_UNWIND   If 1, this is the target frame of an unwind operation. (This may be useful to allow a language-specific handler to perform proper handling for the last step of an unwind.)

  • EXCEPTION_COLLIDED_UNWIND   If 1, an unwind collision has occurred.

All flag bits other than those defined above must be zero.

ExceptionRecord  

Either zero or the address of the next exception record in the list.

ExceptionAddress  

The address of the instruction causing the exception.

For a hardware exception or asynchronous software exception, this is the address of the instruction at which the hardware exception or asynchronous exception interrupted execution of the thread.

For synchronous software exceptions and unwind exceptions, this is the address of the call instruction that invoked the library routine for raising the exception or starting the unwind, respectively.

This field is significant only in the primary exception record; its contents are unpredictable in secondary exception records.

NumberParameters  

The number of exception-specific qualifiers in the exception record.

ExceptionInformation[n]  

Each is a single longword that provides additional information specific to the exception, and may contain information intended for display in messages.

Exception Records for General Exceptions

Software-Caused Exceptions

The information in exception records for general and unwind exceptions may vary widely from a simple single exception value to a long chain of exceptions and exception qualifiers. This specification defines the conventions for constructing these exception records. A complete enumeration of all possible combinations is beyond the scope of this document.

Hardware-Caused Exceptions

All Alpha hardware exceptions have exception information associated with them. This information may be as little as the exception type and exception PC or as much as three additional registers worth of information. The specific information supplied with each exception type is defined in the Alpha System Reference Manual.

When a hardware exception occurs, the Windows NT for Alpha Systems operating system may handle the exception internally or it may cause the exception to be raised in user mode. When a hardware exception is raised in user mode, the exception record passed to exception handlers includes the exception information supplied by the operating system. This information is marshaled into the exception record to produce an exception record, typically as follows:

ExceptionCode  

An operating system–defined code unique to the exception condition.

ExceptionFlags  

As appropriate (see above).

ExceptionRecord  

Value of 0 (null)

ExceptionAddress  

The PC of the instruction that caused the hardware exception.

NumberParameters  

Contains additional information specific to the exception condition.

*ExceptionInformation[n] *

Contain additional information specific to the exception condition.

Details on the treatment of particular hardware exceptions are system defined.

Exception Records for Unwind Exceptions

Unwind exceptions are characterized by having at least one of the EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND or EXCEPTION_TARGET_UNWIND flags set to 1.

The reason code for the unwind as well as any supplied qualifiers is represented in the ExceptionCode flag in the same way as for general exceptions.