Guardian Procedure Calls Reference Manual
• How to avoid writing over the application's data stack
If ‘L'[-3] (the value of ‘S' at the time of the trap) is -1, the trap handler should not resume from
the trap handler without first changing ‘L'[-3] to a more appropriate value. Otherwise, ‘G'[0]
through ‘G'[10] of the application's data stack are overwritten.
• When the trap handler is not invoked
Under some circumstances (for example, if system resources that are necessary to initiate trap
handling are not available), the trap handler specified though ARMTRAP might not execute.
In such a case, the process abends.
Additional Considerations for Native Systems
Special restrictions apply to trap handlers that execute on native systems. These rules should be
observed:
• Trap P variable
The TNS trap P variable is only approximate for a process running in accelerated mode. Do
not use it to inspect the code area and determine the failing instruction.
Do not increment the trap P variable and resume execution; doing so causes undefined results.
However, you can change the trap P variable to a valid TNS restart point. The restart point
would typically be a label in your program. See the “Resuming at the point of the trap” in
Considerations above.
• Invalid trap ENV fields
For a process running in accelerated mode, the ENV field RP is not valid and the fields N, Z,
and K are not reliable.
• Register stack R[0:7]
The contents of the TNS register stack are not valid in accelerated mode and are not
dependable in TNS mode. Never change the register stack when attempting to resume at the
point of the trap.
• Functions
A trap-handling procedure must not be a function returning a result value.
OSS Considerations
Do not use the ARMTRAP procedure in OSS processes.
CAUTION: Use of this procedure in an OSS process causes undefined results and might cause
severe side effects such as disabling signals completely or causing the calling process to receive
a fatal signal.
Example
In the following example, @TRAP is the label at the beginning of the Transaction Application
Language (TAL) trap-handling procedure where control is transferred if a trap occurs. The $LMIN
expression is the address of the local data area where the trap handler runs (its data area). The
second call to ARMTRAP is the return from the trap handler.
PROC TRAPPROC;
BEGIN
CALL ARMTRAP ( @TRAP, $LMIN ( LASTADDR , %77777 ) - 500 );
! setting the trap.
RETURN;
TRAP:
CODE (PUSH %777);
.
74 Guardian Procedure Calls (A-B)