|
HP OpenVMS systems documentation |
Previous | Contents | Index |
The signal procedure examines the two exception vectors first, then examines a system-defined maximum number of previous stack frames, and, if necessary, examines the last-chance exception vector. The exception vectors have three address locations per access mode.
As part of image startup, the system declares a default last-chance handler. This handler is used as a last resort when the normal handlers are not performing correctly. The debugger can replace the default system last-chance handler with its own.
On Alpha and I64 systems, note that the default catchall handler in user mode can be a list of handlers and is not in conflict with this standard.
On OpenVMS systems, in some frame before the call to the main program, the system establishes a default catchall condition handler that issues system messages. In a subsequent frame before the call to the main program, the system usually establishes a traceback handler. These system-supplied condition handlers use the condition-value argument to get the message and then use the remainder of the argument list to format and output the message through the SYS$PUTMSG system service.
If the severity field of the condition-value argument (bits <2:0>) does not indicate a severe error (that is, a value of 4), these default condition handlers return with SS$_CONTINUE. If the severity is a severe error, these default handlers exit the program image with the condition value as the final image status.
The stack search ends when the old frame address is 0 or is not accessible, or when a system-defined maximum number of frames have been examined. If a condition handler is not found, or if all handlers return with a SS$_RESIGNAL or SS$_RESIGNAL64, then the vectored last-chance handler is called.
If a handler returns SS$_CONTINUE or SS$_CONTINUE64, and LIB$STOP was not called, control returns to the signaler. Otherwise, LIB$STOP issues a message indicating that an attempt was made to continue from a noncontinuable exception and exits with the condition value as the final image status.
Figure 8-2 lists all combinations of interaction between condition handler actions, default condition handlers, types of signals, and calls to signal or stop. In this figure, "Cannot Continue" indicates an error that results in the following message:
IMPROPERLY HANDLED CONDITION, ATTEMPT TO CONTINUE FROM STOP. |
Figure 8-2 Interaction Between Handlers and Default Handlers
This section describes the properties of condition handlers for all
OpenVMS environments.
8.5.1 Condition Handler Parameters and Invocation
If a condition handler is found on a software-detected exception, the handler is called as follows:
(*handler)(signal_args, mechanism_args) |
Argument | OpenVMS Usage | Type | Access | Mechanism |
---|---|---|---|---|
signal_args | signal vector | structure | modify | by reference |
mechanism_args | mechanism | structure | modify | by reference |
Arguments:
signal_args
A 32-bit signal argument vector (see Section 8.5.1.1) |
|
mechanism_args
A mechanism argument vector (see Section 8.5.1.2) |
Function Value Returned:
One of the following status codes: SS$_CONTINUE, SS$_RESIGNAL, SS$_CONTINUE64, SS$_RESIGNAL64. This value is used by the Condition Handling Facility to determine how to proceed next in processing the condition. (See Section 8.6.) |
There are two forms of signal argument vector (or signal vector for short): one for use with 32-bit addresses and one for use with 64-bit addresses. The two forms are compatible in that the forms can be distinguished dynamically at run time and, except for the size and offset of fields, are identical in content and interpretation.
The 32-bit signal argument vectors are used on all OpenVMS systems. When used on Alpha or I64 systems, 32-bit signal argument vectors provide full compatibility with their use on VAX systems. The 64-bit signal argument vectors are used only on Alpha and I64 systems--they have no counterpart and are not recognized on VAX systems.
When a condition handler is called by the Condition Handling Facility (CHF) on Alpha or I64 systems, both forms of signal argument vector are available. The first argument is always a reference to a 32-bit form of signal argument vector. A handler that chooses to operate using the 64-bit form must obtain the address of the corresponding 64-bit signal argument vector from the CHF$PH_MCH_SIG64_ADDR field of the mechanism argument vector (see Section 8.5.1.2.2 and Section 8.5.1.2.3).
Both forms of signal vector include a length field, a condition value, zero or more parameters that further qualify the condition value, and finally a processor program counter (PC) and program status (PS). For hardware-detected exceptions, the condition value indicates which exception was taken. The PC value gives the address of the instruction that caused the exception or the address of the next instruction, depending on whether the exception was a fault or a trap. For software-detected conditions, the condition value and any associated parameters are copies of the parameters to the call of LIB$SIGNAL or LIB$STOP that initiated exception handling, while the PC is the return address to the caller of that routine.
Note that bits <2:0> of a condition value indicate severity and not what condition is being signaled. Therefore, a handler should examine only the condition identification, that is, condition value bits <27:3>, to determine the cause of the exception. The setting of severity bits <2:0> may vary from time to time even for the same condition. In fact, some handlers might only change the severity of a condition in the signal vector and resignal.
Generally, a handler may validly modify any field of a signal argument vector except for the CHF$L_SIG_ARGS length field or, in the case of a 64-bit signal vector, the CHF64$L_SIGNAL64 field. In particular, a modified signal vector is passed to a subsequent handler if the current handler completes by resignaling. (If the length is modified, the modification is ignored; CHF restores the original length.) It is invalid for a handler to modify both forms of signal argument vector---the effect of doing so is undefined.
The remainder of this section is organized as follows. First, the 32-bit form of signal argument vector is described. Second, the 64-bit form of signal argument is described. Finally, the relationship between the two forms is discussed.
Figure 8-3 shows the format of the 32-bit form of signal argument vector. The CHF$L_SIG_ARGS longword contains the argument vector count, which is the number of remaining longwords in the vector. The CHF$L_SIG_NAME longword contains the condition value. Next are 0 or more longwords that contain additional parameters appropriate to the condition. The remaining two longwords contain the PC and PS values.
Figure 8-3 Signal Argument Vector --- 32-Bit Format
On VAX systems, the value used for the PS is the contents of the VAX processor status longword (PSL).
On Alpha systems, the value used for the PS is the low half of the Alpha processor status register. Furthermore, CHF$IS_SIG_ARGS and CHF$IS_SIG_NAME are aliases for CHF$L_SIG_ARGS and CHF$L_SIG_NAME, respectively.
On I64 systems, the value used for the PS is the low half of a fabricated Alpha-like processor status register that contains IPL, CM, CSW, and IP fields.
Figure 8-4 shows the format of the 64-bit form of signal argument vector. The address of this form of signal argument is available only from the CHF$PH_MCH_SIG64_ADDR field of the mechanism argument vector (see Section 8.5.1.2.2 and Section 8.5.1.2.3). The CHF64$L_SIG_ARGS field is a longword that contains the number of remaining quadwords in the vector (following the CHF64$L_SIGNAL64 field). The CHF64$L_SIGNAL64 longword contains a special code named SS$_SIGNAL64 whose value is key to distinguishing between a 32-bit and 64-bit form of signal argument vector. The CHF64$Q_SIG_NAME quadword contains a sign-extended condition value. Next are zero or more quadwords that contain additional parameters appropriate to the condition. The remaining two quadwords contain the Alpha or I64 PC and PS values.
Figure 8-4 Signal Argument Vector --- 64-Bit Format
When a handler is called, the 32-bit and 64-bit signal argument vectors are closely related as follows:
Note that given a 64-bit signal vector, it is possible to create the corresponding 32-bit signal vector by fetching the low-order longword of each quadword of the 64-bit vector and packing the results together contiguously into a 32-bit vector; other than using the length, no interpretation of the contents is required.
Given the address of a signal argument vector that might be either the 32-bit or 64-bit form, either of the following equivalent tests may be used to distinguish which one is present:
The mechanism argument vector for the argument
mechanism_args contains information about the machine
state when an exception occurs or when a condition is signaled.
Therefore, the mechanism argument vector is highly specific to the
underlying machine architecture.
8.5.1.2.1 VAX Mechanism Vector Format
On VAX systems, the mechanism format for the argument vectors is shown in Figure 8-5. The first longword contains the argument vector count, which is the number of remaining longwords in the vector. The frame longword contains the contents of the FP in the establisher's context. If the restrictions described in Section 8.5.3.1 are met, the frame can be used as a base from which to access the local storage of the establisher.
The depth longword is a positive count of the number of procedure-activation stack frames between the frame in which the exception occurred and the frame depth that established the handler being called. (For more information about depth, see Section 8.5.1.3.)
The CHF$L_MCH_SAVR0 and CHF$L_MCH_SAVR1 longwords save the state of the R0 and R1 registers, respectively, at the time of the call to LIB$SIGNAL or LIB$STOP. If not modified by a handler during CHF processing, these values will become the values of those registers after completion of CHF processing (either by continuation or by unwinding). These two fields may be modified by a handler to establish different values to be used at CHF completion. Note that the contents of other registers are not available in the mechanism vector and can only be accessed by analysis of the stack. (See Section 8.7.1.)
CHF$L_MCH_SAVR0 and CHF$L_MCH_SAVR1 are the only fields of a VAX mechanism vector that can be validly modified by a handler. The effect of any other modification is undefined.
Figure 8-5 VAX Mechanism Vector Format
If the VAX vector hardware or emulator option is in use, then for hardware-detected exceptions, the vector state is implicitly saved before any condition handler is entered and restored after the condition handler returns. (Save and restore is not required for exceptions initiated by calls to LIB$SIGNAL or LIB$STOP, because there can be no useful vector state at the time of such calls in accordance with the rules for vector register usage in Section 2.1.2.) Thus, a condition handler can make use of the system vector facilities in the same manner as mainline code.
The VAX saved vector state is not directly available to a condition
handler. A condition handler that needs to manipulate the vector state
to carry out agreements with its callers can call the
SYS$RESTORE_VP_STATE service. This service restores the saved state to
the vector registers (whether hardware or emulated) and cancels any
subsequent restore. The vector state can then be manipulated directly
in the normal manner by means of vector instructions. (This service is
normally of interest only during processing for an unwind condition.)
8.5.1.2.2 Alpha Mechanism Vector Format
On Alpha systems, the 64-bit-wide mechanism array is the argument mechanism in the handler call. The array is shown in Figure 8-6. Table 8-5 lists and describes the fields.
The following table lists variable name equivalence for HP OpenVMS Version 8.2 and earlier and HP OpenVMS Version 8.2 and later. Although HP OpenVMS Version 8.2 and later offer backward compatibility, we recommend that you use the new names for that version of the operating system. |
HP OpenVMS Version 8.2 and earlier | HP OpenVMS Version 8.2 and later |
---|---|
MCH_SAVR0 | MCH_RETVAL |
MCH_SAVR1 | MCH_RETVAL2 |
MCH_SAVF0 | MCH_RETVAL_FLOAT |
MCH_SAVF1 | MCH_RETVAL2_FLOAT |
The CHF$IH_MCH_RETVALx and CHF$FH_MCH_RETVALx_FLOAT quadwords save the state of the nonpreserved general and floating registers, respectively, at the time of the call to LIB$SIGNAL or LIB$STOP. If not modified by a handler during CHF processing, these values will become the values of those registers after completion of CHF processing (either by continuation or by unwinding). These fields may be modified by a handler to establish different values to be used at CHF completion.
The CHF$IH_MCH_RETVALx and CHF$FH_MCH_RETVALx_FLOAT fields are the only fields of an Alpha mechanism vector that can be validly modified by a handler. The effect of any other modification is undefined. (See also Section 8.7.2.) Note that the contents of the normally preserved registers are not available in the mechanism vector and can only be accessed by analysis of the stack. (See Section 8.7.1.)
The recommended method for modifying return values in a procedure's invocation context (CHF$IH_MCH_RETVAL, CHF$IH_MCH_RETVAL2, CHF$IH_MCH_RETVAL_FLOAT, and CHF$IH_RETVAL2_FLOAT) is by using routine SYS$SET_RETURN_VALUE (see Section 8.7.2). The recommended method for modifying all other registers in a procedure's invocation context is by using routine LIB$PUT_INVO_REGISTERS ( Section 3.5.3.6).
Figure 8-6 Alpha Mechanism Vector Format
Field Name | Contents | ||
---|---|---|---|
CHF$IS_MCH_ARGS | Count of quadwords in this array starting from the next quadword, CHF$PH_MCH_FRAME (not counting the first quadword that contains this longword). This value is always 44. | ||
CHF$IS_MCH_FLAGS |
Flag bits <31:0> for related argument-mechanism information
defined as follows:
|
||
CHF$PH_MCH_FRAME | Contains the frame pointer in the procedure context of the establisher. | ||
CHF$IS_MCH_DEPTH | Positive count of the number of procedure activation stack frames between the frame in which the exception occurred and the frame depth that established the handler being called (see Section 8.5.1.3). | ||
CHF$IS_MCH_RESVD1 | Reserved to Hewlett-Packard. | ||
CHF$PH_MCH_DADDR | Address of the handler data quadword if the exception handler data field is present (as indicated by PDSC$V_HANDLER_DATA_VALID); otherwise, contains 0. | ||
CHF$PH_MCH_ESF_ADDR | Address of the exception stack frame (see the Alpha Architecture Reference Manual). | ||
CHF$PH_MCH_SIG_ADDR | Address of the 32-bit form of signal array. This array is a 32-bit wide (longword) array. This is the same array that is passed to a handler as the signal argument vector. | ||
CHF$IH_MCH_RETVAL | Contains a copy of R0 at the time of the exception. | ||
CHF$IH_MCH_RETVAL2 | Contains a copy of R1 at the time of the exception. | ||
CHF$IH_MCH_SAVR nn | Contain copies of the saved integer registers at the time of the exception. The following registers are saved: R16 through R28. Registers R2 through R15 are implicitly saved in the call stack. | ||
CHF$FH_MCH_RETVAL_FLOAT | Contains a copy of F0 at the time of the exception, or is unpredictable as described for the field CHF$IS_MCH_FLAGS. | ||
CHF$FH_MCH_RETVAL2_FLOAT | Contains a copy of F1 at the time of the exception, or is unpredictable as described for the field CHF$IS_MCH_FLAGS. | ||
CHF$FH_MCH_SAVF nn | Contain copies of the saved floating-point registers at the time of the exception, or are unpredictable as described at field CHF$IS_MCH_FLAGS. If the floating-point register fields are valid, the following registers are saved: F10 through F30. Registers F2 through F9 are implicitly saved in the call | ||
CHF$PH_MCH_SIG64_ADDR | Address of the 64-bit form of signal array. This array is a 64-bit wide (quadword) array. |
8.5.1.2.3 I64 Mechanism Vector Format
On I64 systems, the 64-bit-wide mechanism array is the
argument mechanism in the handler call. The array is shown in
Figure 8-7.
The CHF$IH_MCH_RETVAL and CHF$FH_MCH_RETVAL2 quadwords save the state of registers R8 and R9 at the time of the call to LIB$SIGNAL or LIB$STOP. The CHF$FH_MCH_RETVAL_FLOAT, CHF$FH_MCH_RETVAL2_FLOAT, and CHF$FH_MCH_SAVFnn octawords save the state of the floating-point registers at the time of the call to LIB$SIGNAL or LIB$STOP. If not modified by a handler during CHF processing (as described below), these values will become the values of those registers after completion of CHF processing (either by continuation or by unwinding).
The only supported method for modifying return values in a procedure's invocation context (CHF$IH_MCH_RETVAL, CHF$IH_MCH_RETVAL2, CHF$FH_MCH_RETVAL_FLOAT, CHF$FH_MCH_RETVAL2_FLOAT) is by using routine SYS$SET_RETURN_VALUE (see Section 8.7.2). The only supported method for modifying all other registers in a procedure invocation context is by using routine LIB$I64_PUT_INVO_REGISTERS ( Section 4.8.3.13).
Figure 8-7 I64 Mechanism Vector Format
.
Field Name | Contents | ||||
---|---|---|---|---|---|
CHF$IS_MCH_ARGS | Count of quadwords in this array starting from the next quadword, CHF$PH_MCH_FRAME (not counting the first quadword that contains this longword). This value is 73 if CHF$V_FPREGS2_VALID is clear, and 265 if CHF$V_FPREGS2_VALID is set. | ||||
CHF$IS_MCH_FLAGS |
Flag bits <31:0> for related argument-mechanism information
defined as follows:
|
||||
CHF$PH_MCH_FRAME | Contains the Previous Stack Pointer, PSP, (the value of the SP at procedure entry) for the procedure context of the establisher (see Section 4.5.1.) | ||||
CHF$IS_MCH_DEPTH | Positive count of the number of procedure activation stack frames between the frame in which the exception occurred and the frame depth that established the handler being called (see Section 8.5.1.3). | ||||
CHF$IS_MCH_RESVD1 | Reserved to Hewlett-Packard. | ||||
CHF$PH_MCH_DADDR | Address of the handler data quadword (start of the Language Specific Data area, LSDA, see Section A.4.1 and Section A.4.4) if the exception handler data field is present in the unwind information block (as indicated by OSSD$V_HANDLER_DATA_VALID); otherwise, contains 0. | ||||
CHF$PH_MCH_ESF_ADDR | Address of the exception stack frame. | ||||
CHF$PH_MCH_SIG_ADDR | Address of the 32-bit form of signal array. This array is a 32-bit wide (longword) array. This is the same array that is passed to a handler as the signal argument vector. | ||||
CHF$IH_MCH_RETVAL | Contains a copy of R8 at the time of the exception. | ||||
CHF$IH_MCH_RETVAL2 | Contains a copy of R9 at the time of the exception. | ||||
CHF$PH_MCH_SIG64_ADDR | Address of the 64-bit form of signal array. This array is a 64-bit wide (quadword) array. | ||||
CHF$FH_MCH_SAVF32_SAVF127 | Address of the extension to the mechanism array that contains copies of F32-F127 at the time of the exception. | ||||
CHF$FH_MCH_RETVAL_FLOAT | Contains a copy of F8 at the time of the exception. | ||||
CHF$FH_MCH_RETVAL2_FLOAT | Contains a copy of F9 at the time of the exception. | ||||
CHF$FH_MCH_SAVF nn | Contain copies of floating-point registers F2-F5 and F12-F31. Registers F6-F7 and F10-F11 are implicitly saved in the exception frame. | ||||
CHF$IH_MCH_SAVB nn | Contains copies of branch registers B1-B5 at the time of the exception. | ||||
CHF$IH_MCH_AR_LC | Contains a copy of the Loop Count Register (AR65) at the time of the exception. | ||||
CHF$IH_MCH_AR_EC | Contains a copy of the Epilog Count Register (AR66) at the time of the exception. | ||||
CHF$PH_MCH_OSSD | Address of the operating system-specific data area. | ||||
CHF$PH_MCH_INVO_HANDLE | Contains the invocation handle of the procedure context of the establisher (see Section 4.8.2.2) | ||||
CHF$PH_MCH_UWR_START | Address of the unwind region. | ||||
CHF$IH_MCH_FPSR | Contains a copy of the hardware floating-point status register (AR.FPSR) at the time of the exception. | ||||
CHF$IH_MCH_FPSS | Contains a copy of the software floating-point status register (which supplements CHF$IH_MCH_FPSR) at the time of the exception. |
Previous | Next | Contents | Index |