From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 29-JUN-1989 00:56
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Re: problems with CMU-TEK V6.4

Message-Id:  <8906290446.AA14783@crdgw1.ge.com>
Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 28 JUN 89 19:04:58 PDT
Received: from VB.CC.CMU.EDU by KL.SRI.COM with TCP; Wed, 28 Jun 89 18:55:20 PDT
Date: Wed, 28 Jun 89 21:37:40
From: Marc Shannon <R602MS5U@VB.CC.CMU.EDU>
Subject: Re: problems with CMU-TEK V6.4
To: portal!cup.portal.com!Brian_C_McBee@UUNET.UU.NET
Cc: info-vax@KL.SRI.COM

Brian McGee brings up an important concept with his question about CMU
TCP/IP (which should be sent to CMU-TEK-TCP@CS.CMU.EDU, by the way :-) )
and that is the BugCheck which takes the system down doesn't actually
indicate why the system crashed in reality.

After taking VMS Internals last year, I wrote this command procedure
which helps offer some clues as to why the system crashed.  It does *NOT*
figure out all crashes as it depends on some clues in the system stack
which may or may not be present.  (It assumes, which is generally valid
for an INVEXCPTN, that on the stack there will be a '00000002' followed
by two addresses, one of which will contain the address of signal vector.)

Anyway, I thought that Brian, as well as others, might find this program
useful, so it is included below.  No warranties are either expressed or
implied, but I'm sure you all knew that already. :-)

Cheers!

--Marc

$! ................... Cut between dotted lines and save. ...................
$!...........................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.10 7-FEB-1989.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user R602MS5U
$! on 28-JUN-1989 21:35:51.43.
$!
$! It contains the following 1 file:
$!        REBOOT-MAIL.COM
$!
$!============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.10 7-FEB-1989 requires VMS V4.4 or higher."
$ EXIT 44 ! SS$_ABORT
$VERSION_OK:
$ GOTO START
$!
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "{Errors}" ); i_errors 
:= 0; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN 
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); LOOP EXITIF SEARCH( SPAN( ' ' )@r_trail 
& LINE_END, FORWARD) = 0; POSITION( r_trail ); ERASE( r_trail ); ENDLOOP
; POSITION( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK
( NONE ) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 )
; IF s_x = '+' THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip 
<> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF
; ENDIF; IF s_x = '-' THEN r_skip := SEARCH( pat_end, FORWARD, EXACT )
; IF r_skip <> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip 
:= MARK( NONE ); r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip 
<> 0 THEN POSITION( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET )
; MOVE_VERTICAL( 1 ); MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part 
) ); ENDIF; ERASE( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = 'V' THEN s_x := ''; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1
; MOVE_VERTICAL( 1 ); ENDIF; IF s_x = 'X' THEN s_x := ''; IF i_append_line 
<> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF
; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> '' THEN i_errors 
:= i_errors + 1; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE
; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL
( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH
( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER
( 1 ); COPY_TEXT( ASCII( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDLOOP
; IF i_errors = 0 THEN SET( NO_WRITE, b_errors, ON ); ELSE POSITION
( BEGINNING_OF( b_errors ) ); COPY_TEXT( FAO
( "The following !UL errors were detected while unpacking !AS", i_errors
, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" )
; ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!!,passed." )
$ RETURN
$!
$START: 
$ FILE_IS = "REBOOT-MAIL.COM"
$ CHECKSUM_IS = 194497
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ OldVerify = F$Verify(0)
X$!
X$!  REBOOT-MAIL.COM
X$!
X$!  Created 24-FEB-1989 by Marc Shannon <R602MS5U@VB.CC.CMU.EDU>
X$!
X$!  This procedure attempts to read the system crash-dump to obtain
X$!  some useful information about why the system actually crashed.
X$!
X$!  It should not be used to replace the system manager poking around
X$!  the dump, but it might assist him (or her) in finding the offending
X$!  code, routine, or (:-)) user.
X$!
X$ MyNode = F$GetSYI("NodeName")
X$ BootTime = F$GetSYI("BootTime")
X$!
X$! Make initial header...
X$!
X$ Open/Write Info Info.Txt
X$ Write Info "''MyNode' has been rebooted."
X$ Write Info ""
X$ Write Info "This machine came up at ''BootTime'.  A log from the crash"
X$ Write Info "dump analysis follows.  (Note that if the machine was rebooted"
V$ Write Info "by an operator or a system manager there will be no information
X"
X$ Write Info "in the dump file.)"
X$ Write Info ""
X$ Write Info "[This dump has been saved in xxxxx.DMP]"
X$ Write Info ""
X$!
X$ True = 1
X$ False = 0
X$!
X$ Define/User Sys$Output Stack.Lis
X$ Analyze/Crash Sys$System:SysDump.Dmp
XShow Stack
X$!
X$ Open/Read Stack Stack.Lis
X$ FoundSP = False
X$ReadAgain:
X$ Read/End=NoInfo Stack FindSP
X$ If F$Extract(0, 9, FindSP) .EQS. "`009 SP =>  " Then FoundSP = True
X$ If .Not. FoundSP Then Goto ReadAgain
X$!
X$! Check for signal arguments...
X$!
X$ If F$Extract(12, 8, FindSP) .NES. "00000002" Then Goto ReadAgain
X$! We assume we found our argument count
X$ Read/End=NoInfo Stack SignalBlock
X$ SignalStack = F$Extract(12, 8, SignalBlock)
X$!
X$! Now, process get the signal arguments
X$!
X$SignalRead:
X$ Read/End=NoInfo Stack FindCount
X$ If F$Extract(2, 8, FindCount) .NES. SignalStack Then Goto SignalRead
X$! Aha!  The signal!
X$ SignalCount = 'F$Extract(12, 8, FindCount)
X$ ArgsRead = 0
X$ArgRead:
X$ ArgsRead = ArgsRead + 1
X$ Read/End=NoInfo Stack ArgLine
X$ Addr = F$Extract(12, 8, ArgLine)
X$ Args_'ArgsRead' = Addr
X$ ArgLabel_'Addr' = F$Extract(21, F$Length(ArgLine)-19, ArgLine)
X$ If ArgsRead .Lt. SignalCount Then Goto ArgRead
X$!
X$! Since we're finished with the stack...
X$!
X$ Close Stack
X$ Delete Stack.Lis;*
X$!
X$! Process the error message
X$!
X$ ErrorFAO = F$Message(%X'Args_1')
X$ Goto Get_Text_'SignalCount'
X$Get_Text_5:
X$ ErrorText = F$FAO(ErrorFAO, %X'Args_2', %X'Args_3', %X'Args_4', %X'Args_5')
X$ Goto Got_Text
X$Get_Text_4:
X$ ErrorText = F$FAO(ErrorFAO, %X'Args_2', %X'Args_3', %X'Args_4')
X$ Goto Got_Text
X$Get_Text_3:
X$ ErrorText = F$FAO(ErrorFAO, %X'Args_2', %X'Args_3')
X$ Goto Got_Text
X$Get_Text_2:
X$ ErrorText = F$FAO(ErrorFAO, %X'Args_2')
X$ Goto Got_Text
X$Get_Text_1:
X$ ErrorText = ErrorFAO
X$!
X$Got_Text:
X$!
X$! Tell user why it crashed
X$!
X$ Write Info "Crash was caused by:"
X$ Write Info "  ''ErrorText'"
X$ PCLoc = F$Locate("PC=", ErrorText)
X$ CodeAvail = False
X$ If PCLoc .Eq. F$Length(ErrorText) Then Goto Get_Dump
X$!
X$! Goodie, we've got a PC
X$!
X$ CodeAvail = True
X$ CodeAddr = F$Extract(PCLoc+3, 8, ErrorText)
X$!
X$ SDA_Addr = ArgLabel_'CodeAddr'
X$ If SDA_Addr .Eqs. "" Then SDA_Addr = CodeAddr
X$!
X$ Write Info ""
X$ Write Info "(PC is at location ''SDA_Addr'.)"
X$ Write Info ""
X$ Goto Get_Dump
X$!
X$! In the event we can't get any useful information
X$!
X$NoInfo:
X$ CodeAvail = False
X$!
X$! Print out code segment
X$!
X$Get_Dump:
X$ Open/Write SDACommands Commands.SDA
X$ Write SDACommands "$ Define/User Sys$Output Dump.Txt"
X$ Write SDACommands "$ Analyze/Crash Sys$System:SysDump.Dmp"
X$ If CodeAvail Then -
X`009Write SDACommands "Examine/Instruction ''CodeAddr'-18:''CodeAddr'+18"
X$ Write SDACommands "Show Crash"
X$ Write SDACommands "Show Process/PCB/PHD"
X$ Write SDACommands "Show Summary"
X$ Write SDACommands "$ Exit"
X$ Close SDACommands
X$!
X$ @Commands.SDA
X$!
X$! Now that file is no longer needed...
X$!
X$ Delete Commands.SDA;*
X$!
X$! Assemble the file
X$!
X$ Close Info
X$ Copy Info.Txt+Dump.Txt Mail.Txt
X$ Delete Info.Txt;*
X$ Delete Dump.Txt;*
X$!
X$! Now mail it to the System-Crash mailing list
X$!
X$ Mail Mail.Txt R602SS00/Subject="''MyNode' crash information"
X$!
X$! And delete the remaining file
X$!
X$ Delete Mail.Txt;*
X$!
X$ If OldVerify Then Set Verify
X$ Exit
$ GOSUB UNPACK_FILE
$ EXIT

