.title TEST_PROGRAM - testing for STD_HANDLER and SIGVEC .sbttl FIGURE_4 - TEST_PROGRAM mudule listing ; ; **** USED BY PERMISSION OF THE VAX PROFESSIONAL TECHNICAL JOURNAL **** ; **** USED BY PERMISSION OF THE VAX PROFESSIONAL TECHNICAL JOURNAL **** ; **** USED BY PERMISSION OF THE VAX PROFESSIONAL TECHNICAL JOURNAL **** ; ;Disclaimer: ; This code was published in the VAX Professional technical journal of ; October 1991, Volume 13, 1991, number 5 in an article entitled ; 'Using LIB$SIGNAL To Call SYS$PUTMSG'. The code presented here is ; distributed by permission of the VAX Professional technical journal and ; may not be published or used for profit in *ANY* form without the express ; written consent of both the VAX Professional and the author. ; ; I would also like to expressly thank the editorial staff of the VAX ; Professional technical journal for both their consideration in publishing ; the original article, and for their permission to include it in this ; DECUS release. ; ; For license information, please refer to the licensing information in ; SIGVEC.MAR or the 000READ.ME file. ; ;Program: TEST_PROGRAM.MAR ; This program provides some samples of signals generated through the ; STD_HANDLER and SIGVEC routines. You may step through these routines ; in the debugger to see how program flow occurs. Please note though that ; LIB_SIGNAL is sensitive to the PSL at the time of the CALLx instruction. ; This means that you *cannot* STEP over the CALLS to LIB_SIGNAL. The way ; to do the equivalent operation is to SET BREAK %LINE where ; is the number of the line immediately following the CALLS. This problem ; occurs only if STD_HANDLER issues a SS$_CONTINUE in response to the ; signalled condition. ; $ssdef ;include system status names .EXTRN LIB_SIGNAL ;external access to SIGVEC module .EXTRN STD_HANDLER ;external access to STD_HANDLER .EXTRN USR_MSGOK ;external access to user ok message .EXTRN USR_MSGBAD ;external access to user bad message .psect s$$data,noexe,wrt,noshr retmsg: .ascid /Subroutine returned and did not SYS$UNWIND/ abomsg: .ascid /Subroutine aborted using SYS$UNWIND/ barmsg: .ascid /---------------/<^x0d><^x0a> retdok: .long 0 .psect s$$code,exe,nowrt,shr,pic ; ; The routine accvio calls LIB_SIGNAL with the code SS$_ACCVIO. The ; first argument passed to accvio is OR'd into the code SS$_ACCVIO so ; that the caller can control the severity of the signal. .entry accvio, ^m<> ;does a LIB_SIGNAL(SS$_ACCVIO,1,6) pushl #6 ;fake reasoncode movzbl #1,-(SP) ;1 fao argument pushl #SS$_ACCVIO ;fake access violation bisl 4(AP),(SP) ;insert passed severity calls #3,g^LIB_SIGNAL ;do the signal ret ;return for case of continuation ; ; This routine simply executes an instruction guaranteed to cause a fault. .entry xhalt, ^m<> halt ;cause a fault ret ;return in case of continuation ; ; This routine provides a 'shell' that can be used to establish the ; STD_HANDLER condition handler. The address of the routine to call ; is the first argument, and all subsequent arguments are simply ; passed verbatim to the target routine. If the target routine returns ; for any reason, a message is printed saying so. .entry vec, ^m<> ;provides a routine to continue from movaw g^STD_HANDLER,(FP) ;set handler clrl retdok ;indicate routine did not return movl 4(AP),r0 ;get target routine address subl3 #1,(AP)+,(AP) ;remove routine from arglist callg (AP),(r0) ;Call routine w/arglist minus target incl retdok ;change 'did not return' to 'did return' ret ;back to perpetrator ; ; This subroutine is called using BSBx or JSB. It prints the results of the ; last call through the VEC procedure. endvec: ;print last operation status & separator pushaq retmsg ;message indicating no $UNWIND tstl retdok ;did a return occur in last VEC call? bneq 10$ ;yes... don't change message text movaq abomsg,(SP) ;change message text to print 10$: calls #1,g^LIB$PUT_OUTPUT ;issue the status message pushaq barmsg ;address of separator bar text calls #1,g^LIB$PUT_OUTPUT ;print a separator bar rsb ;go back to caller ; ; This is the main routine that generates all signals and displays the results. .entry main, ^m<> ;test for STD_HANDLER and SIGVEC pushaw xhalt ;execute a HALT instruction calls #1,vec ;set up handler & call bsbw endvec ;print break and final status pushl #1 ;set severity success pushaw accvio ;signal an access violation calls #2,vec ;set up handler & call bsbw endvec ;print break and final status pushl #0 ;set severity error pushaw accvio ;signal an access violation calls #2,vec ;set up handler & call bsbw endvec ;print break and final status pushl #SS$_BADPARAM ;signal bad parameter last pushl #0 ;no arguments for user message pushl #USR_MSGBAD ;Signal a user fatal message pushaw g^LIB_SIGNAL ;signal routine calls #4,vec ;set up handler & call bsbw endvec ;print break and final status pushl #SS$_ABORT ;signal an abort last pushl #99 ;second parameter in message pushl #88 ;first parameter in message pushl #2 ;two arguments for user message pushl #USR_MSGOK ;Signal a user informational message pushaw g^LIB_SIGNAL ;signal routine calls #6,vec ;set up handler & call bsbw endvec ;print break and final status movl #SS$_NORMAL,r0 ;return a normal completion ret ;back to DCL w/ok status .end main