[mod.computers.vax] Getting tracebacks without signalling

jl%dac.triumf.cdn%ubc.CSNET@CSNET-RELAY.ARPA (John Lloyd) (02/03/86)

Does anyone know how to do this?  We want to get a traceback at any place
in a program without having to signal anything (otherwise, of course,
you just signal a Success value to get the traceback on SYS$ERROR).  The
problem is that within a condition handler in which you want to call
SYS$UNWIND, there is no obvious way to get the traceback information
as well as unwind the stack.  Hence, in recovering (i.e. unwinding) you
lose the information about what went wrong and the important stuff 
like where it went wrong.  Any ideas?

mike%vax1.acs.udel.edu@LOUIE.UDEL.EDU (PORTER) (02/03/86)

There is no supported way that I know of to get a traceback without
signalling an error.  What you can do is copy the code in the condition
handler established by SYS$IMAGSTA at image startup.  I have such a routine,
let me know if you would like sources (BLISS-32, or macro if you don't have
BLISS).

					Mike Porter

info-vax@ucbvax.UUCP (02/08/86)

[]

The following condition handler and message definition file should allow you
both to see a traceback and to do an unwind.  VMS V4 kindly displays the
original error message when it comes to HANDLE in the traceback.  With
previous versions of VMS, it was necessary to call SYS$PUTMSG to see the
cause of the original error.


	INTEGER*4 FUNCTION HANDLE( SIGARGS, MECHARGS )

	IMPLICIT INTEGER(A-Z)
	INTEGER*4 SIGARGS(2), MECHARGS(5)

	INCLUDE '($SSDEF)'
	INCLUDE '($STSDEF)'

	EXTERNAL FAC_TRABACFOL

	IF ( ( SIGARGS(2) .AND. STS$M_SEVERITY ) .LT. 4 ) THEN

C  For all except severe errors, use default handler to print traceback
C  and continue

	    HANDLE = SS$_RESIGNAL

	ELSE

C  Severe error ...
C  We signal a warning to get a traceback (from here).

	    CALL LIB$SIGNAL( FAC_TRABACFOL )

C  Now unwind to the caller of the establisher of this handler

	    CALL SYS$UNWIND( , )

	ENDIF

	RETURN
	END

*****

.TITLE	FACMSG.MSG	Message definition

.FACILITY	FACIL		101	/PREFIX=FAC_
!		^^^^^		^^^	        ^^^	Replace as appropriate

TRABACFOL/W	"error has occurred - traceback follows"

.END

--
Jim Richardson
Department of Pure Mathematics, University of Sydney, NSW 2006, Australia
UUCP:	...!seismo!munnari!summer.oz!jimr
ARPA:	jimr%summer.oz@seismo.arpa		CSNET:	jimr@summer.oz