Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (A-B)
Guardian Procedure Calls Reference Manual522629-013
2-40
ARMTRAP Procedure
(Superseded by SIGACTION_INIT_ Procedure )
or trap bit of the trap ENV variable at ‘L’[-1]. Such resumption is valid only for trap
2 (arithmetic overflow) or trap 4 (loop timeout). An attempt to resume at the point
of any other trap typically causes the same trap to occur again on a TNS system;
on a native system, such an attempt causes the process to abend.
Resuming at another point in the program
To resume execution at some other point in the program, you need to change the P
register value at ‘L’[-2], the space index at ‘L’[-5], and, if necessary, the library
space bit in ENV at ‘L’[-1] to reflect the new location within your program. You also
need to set appropriate values for the S register at ‘L[-3] and the L register at ‘L’[0]
and the appropriate environment state in ENV at ‘L’[-1]: The RP field
(ENV.<13:15>) should be set to 7 if the resumption point is the beginning of a
statement; ENV.<0> should be set to 0.
Traps in protected code
If the trap occurs in system code or system library and the trap handler is in user
code or user library, or if the trap occurs in a licensed user library and the trap
handler is in user code, the reported program location and process state (space ID,
P, ENV, and L) indicate the point of the user call to one of these protected code
regions and S is reported as -1.
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. The
following rules should be observed:
Trap P variable
The TNS trap P variable is only approximate for a process running in accelerated
mode. You should not use it to inspect the code area and determine the failing
instruction.
You should 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 “Resuming at another point in the program” in “Considerations.”