HP OpenVMS Systemsask the wizard |
The Question is:
Using the OpenVMS Programming Concepts Manual as a guide to writing an
elemetary Exit Handler in VAX-11 BASIC, the code results in the following
VMS error:
$ run [.wrk]test
%SYSTEM-F-OPCDEC, opcode reserved to Digital fault at PC=7FDC72F6,
PSL=03C00000
Improperly handled condition, image exit forced.
Signal arguments Stack contents
Number = 00000003 00000000
Name = 0000043C 00000000
7FDC72F6 7FDC73E0
03C00000 7FDC73C4
8B65DCB8
00000000
00000001
00000000
00000000
00140000
Register dump
R0 = 7FDC72FC R1 = 00000001 R2 = 00000004 R3 = 7FEB2B0C
R4 = 00000004 R5 = 7FFE5EBC R6 = 7FFED188 R7 = 7FFED188
R8 = 7FFECA48 R9 = 7FFECC50 R10= 7FFED7D4 R11= 7FFE2BDC
AP = 7FDC7370 FP = 7FDC7330 SP = 7FDC73A4 PC = 7FDC72F6
PSL= 03C00000
The code follows:
program TEST
declare long EXIT_STATUS
record EXIT_DESCRIPTOR
long FORWARD_LINK
long ADDR
long ARG_COUNT
long STATUS_ADDRESS
end record EXIT_DESCRIPTOR
declare EXIT_DESCRIPTOR EXIT_HANDLER
external sub EXT_HANDLER (long by ref)
EXIT_HANDLER::ADDR = loc(EXT_HANDLER)
EXIT_HANDLER::ARG_COUNT = 0%
EXIT_HANDLER::STATUS_ADDRESS = loc(EXIT_STATUS)
call SYS$DCLEXH (EXIT_HANDLER by ref)
THE_END:
end
sub EXT_HANDLER (long EXIT_STATUS by ref)
print EXIT_STATUS
exit sub
end sub
thanks fred
The Answer is :
The OpenVMS Wizard will endevour to get the OpenVMS Programming
Concepts manual updated to include a BASIC example such as the
attached. The root problem in most of the cases of errors with
sys$dclexh is the scope of variable allocation, and the access
to variables and data structures when the main routine (and its
variables) has effectively exited and the exit handler(s) are
now operating...
Also see topic 3787.
--
program DCLEXH_EXAMPLE
option type = explicit
external long EXIT_HANDLER
external long function SYS$DCLEXH
external long function SYS$EXIT
external long function LIB$STOP
declare long RETURN_STATUS
record EXIT_DESCRIPTOR
long FORWARD_LINK
long HANDLER_ADDR
long ARG_COUNT
long CONDITION_VALUE_PTR
long RANDOM_EXAMPLE_VALUE
! borrow part of the record structure for data storage...
long CONDITION_VALUE
end record EXIT_DESCRIPTOR
! declare the exit handler block in non-volatile storage
common (SaveBlock) EXIT_DESCRIPTOR EXHBLK
PRINT
PRINT "DCLEXH_EXAMPLE initializing..."
PRINT
EXHBLK::FORWARD_LINK = 0%
EXHBLK::HANDLER_ADDR = loc(EXIT_HANDLER)
EXHBLK::ARG_COUNT = 2%
EXHBLK::CONDITION_VALUE_PTR = loc(EXHBLK::CONDITION_VALUE )
EXHBLK::RANDOM_EXAMPLE_VALUE = 303147%
PRINT "Calling SYS$DCLEXH..."
RETURN_STATUS = SYS$DCLEXH (EXHBLK by ref)
call LIB$STOP (RETURN_STATUS by value) if (RETURN_STATUS and 1%) = 0%
PRINT "SYS$DCLEXH called..."
PRINT "Calling SYS$EXIT..."
call SYS$EXIT(RETURN_STATUS by value)
end
function LONG EXIT_HANDLER(long CONDITION_VALUE, long RANDOM_VALUE by value)
! the exit handler gains control effectively after the main
! program module has exited. Direct access to (or otherwise
! sharing) variables used by the main routine requires explicit
! storage allocation control.
option type = explicit
print "EXIT_HANDLER invoked..."
print "CONDITION_VALUE: ", CONDITION_VALUE
print "RANDOM_VALUE: ", RANDOM_VALUE
PRINT
PRINT "DCLEXH_EXAMPLE done..."
PRINT
end function
|