HP Pascal/iX Programmer's Guide (31502-90023)
11- 10
XLIBTRAP stores the address of the Library Trap Handler (
plabel
) so that
the library routines can find the routine to call if an error occurs.
The old value of PLabel is returned in the parameter OldPLabel.
The only ways to leave a trap handler is by a normal return or by an
escape
. Your library trap handler cannot execute a nonlocal
goto
(a
goto
whose destination is outside the procedure).
NOTE This routine is available on the MPE/iX and HP-UX operating
systems. On MPE/iX, it expects an MPE-style
plabel
; on HP-UX, it
expects
plabel
to be the actual address of the Library
Trap Handler. To make your program portable, use
baddress
(
Library_Trap_Handler_name
) as
plabel
.
NOTE The result record will be different if the trap has been raised
outside of the Pascal run time library.
The user's trap handler must be declared this way:
TYPE
PStkMrk = RECORD {Stack Marker}
users_PCS : integer; {space id of users code space}
users_PCO : integer; {program counter offset within the
code space}
users_SP : integer; {stack pointer of the user's
routine that called the library
routine where the error occurred}
users_DP : integer; {data pointer for the above routine}
{future implementations may have further fields to return
more information to the user's trap handler. If so, they
will not affect existing code that uses the above fields.}
END;
PROCEDURE My_Library_Trap_Handler (VAR StkRec : PStkMrk;
VAR ErrorCode : Integer;
VAR AbortFlag : Integer
);
BEGIN {My_Library_Trap_Handler}
.
.
.
END; {My_Library_Trap_Handler}
Where
StkRec A structure, as described above, passed by reference. Any
changes to the fields of this structure are not reflected in
the actual contents of the machine registers, when and if the
program resumes normal execution.
ErrorCode 32-bit integer, passed by reference, which contains the error
code. For a complete list of error codes generated by the
Pascal run-time library, see the file PASESC.PUB.SYS (on
MPE/iX) or /usr/include/pasesc.ph (on HP-UX). Either of these
files can be directly included in a user program.
AbortFlag 32-bit integer, passed by reference. If AbortFlag is zero
when the Library Trap Handler is exited, the program continues