From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  6-OCT-1989 11:04
To:	MRGATE::"ARISIA::EVERHART"
Subj:	PROCESS_DUMP (DUMP/PROCESS/IDENT=xxx utility) 4/4

Message-Id:  <8910061328.AA02343@crdgw1.ge.com>
Received: From NSFNET-RELAY.AC.UK by CRVAX.SRI.COM with TCP; Fri,  6 OCT 89 05:40:58 PDT
Received: from ncdlab.ulcc.ac.uk by NSFnet-Relay.AC.UK   via Janet with NIFTP
           id aa04110; 6 Oct 89 12:13 BST
Date:           Fri, 6 Oct 89  12:13 BST
From: Nick de Smith <"PSI%JANET.000000000040::NICK%ncdlab.ulcc.ac.uk"@NSFnet-Relay.AC.UK>
To: INFO-VAX <@NSFnet-Relay.AC.UK:INFO-VAX@crvax.sri.com>
Subject:        PROCESS_DUMP (DUMP/PROCESS/IDENT=xxx utility) 4/4

-+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+
X; Data on name of image dumper to use. This must not be moved.
X
XIMGDMP_NAM: .ascii "IMGDMP"`009`009`009; Name of the image dumper to use
X`009IMGDMP_LEN = . - IMGDMP_NAM
XDFLNAM_NAM: .ascii "SYS$SHARE:.EXE"`009`009; Defaults to use for the name
X`009DFLNAM_LEN = . - DFLNAM_NAM
XINADR:`009.long`009`094x200, <1@VA$V_P1>-1`009`009; Input mapping range (in
V P0)
X`012
X.subtitle`009HANDLER`009Exception handler for USER AST code
X;++
X; HANDLER`009Exception handler for USER mode code
X;
X; Ignore everything. We have to do something like this because we cannot unw
Vind
X; otherwise we will destroy registers. All major problems are likely to be
X; reported through the DEBUG interface above (to the accounting file).
X;--
XHANDLER:.word`009`094m<r4,r5>`009`009; Entry mask for exception handler
X
X`009movl`009#SS$_CONTINUE, r0`009; Just continue from anything!!!
X
X`009ret
X
XPROCESS_DUMP_LENGTH = . - PROCESS_DUMP`009; Length of USER mode AST code
XAST_LENGTH == . - AST_CODE`009`009; Length of all AST code (USER + KERNEL)
X`012
X.subtitle`009Data area for main program
X
X; Define extended AST Control Block
X
X`009$defini ACB, GLOBAL, ACB$K_LENGTH ; Must be global symbols, Get past nor
Vmal ACB fields
X`009$def ACB_L_SPID`009`009`009; Source PID
X`009`009.blkl`0091
X`009;++
X`009; Add your fields here
X`009;--
X`009$def ACB_T_AST_CODE
X`009`009.blkb`009AST_LENGTH`009; All AST code
X`009$def ACB_K_NEW_LENGTH`009`009; Symbol for extended length
X`009$defend ACB
X
X; The length of an ACB (like all NPAGE pool blocks) is stored in a word
X; The maximum length of the extended ACB is therefore 65535 bytes. Check thi
Vs.
X; (the check is rather academic, but we should be careful in case an error h
Vas
X; been made - non-paged pool could be consumed, never to re-appear!).
X
X.if greater <ACB_K_NEW_LENGTH-65535>
X .warn  ; Too much AST code specified.
X .print ; Some non-paged pool will be left allocated by this program.
X.endc
X
X`009.end
$ CALL UNPACK [.PDUMP]PDUMP.MAR;1 274366466
$ create/nolog 'f'
X.title`009PROCESS_DUMP - Generate a process dump file
X;++
X; PROCESS_DUMP
X;
X; Date  :`00905-May-87
X; Author:`009Nick de Smith
X;`009`009Applied Telematics Services, 7 Vale Avenue
X;`009`009Tunbridge Wells, Kent TN1 1DJ, England.
X;`009`009+44 892 511000, PSI%234213300154::NICK
X;
X; Copyright (c) 1987,1988 by Applied Telematics Group Limited and Nick de Sm
Vith.
X; This software is supplied for information only. No guarantee is supplied f
Vor
X; this software, and no liability will be accepted for any action resulting
V from
X; the use of this software or the information contained herein. Under no
X; circumstances may this software be used for commercial gain, including its
V sale,
X; lease or loan. This software may be copied only with the inclusion of this
X; copyright notice. The author is prepared to enter into correspondance with
X; interested parties, but will not necessarily maintain this software. Havin
Vg said
X; all that, enjoy it!`032
X;
X; Description:
X;
X; This routine invokes the VMS process dump facility to generate
X; a process dump file of the current process that can subsequently be
X; inspected with ANALYZE/PROCESS_DUMP.
X;
X; If the logical SYS$PROCDMP is defined in the context of the process activa
Vting
X; the image dumper, the translation of the logical is used to specify the di
Vrectory
X; and filename for the dump. Do not specify an extension, as ".DMP" is added
V to the
X; translated name. This can be done as a LNM$SYSTEM_TABLE or LNM$GROUP logic
Val so
X; that all dumps end up in the same directory (which would have to have W:RW
VE
X; protection).
X;
X; Note: Calling this routine at elevated access modes, in particular from KE
VRNEL
X;`009mode, can crash your system. Only call it at USER or EXEC. Note that if
V you
X;`009call it from EXEC, don't call it from an AST routine. If you do, it wil
Vl
X;`009never complete as the dump is written using RMS, and RMS uses EXEC mode
X;`009ASTs to signal completion of asynchronous events.
X;
X; Note:`009DUMP may have side effects, eg. it uses EFN 0 (and RMS) for I/O.
V I think
X;`009that this routine is "safe", but, as with all undocumented features, do
Vn't
X;`009walk in with blind faith.
X;
X; Edit`009Edit date`009By`009Why
X;  03`00922-Dec-88`009NMdS`009Tidy up for V5
X;  02`00909-Feb-88`009NMdS`009Flash up a bit to include real register/PSL va
Vlues
X;  01`00905-May-87`009NMdS`009First attempt
X;--
X`009.Ident`009/V01.03/
X
X.library`009"SYS$LIBRARY:LIB"
X
X`009$chfdef`009`009`009`009; Define condition handler values
X`009$iacdef`009`009`009`009; Image activator definitions
X`009$psldef`009`009`009`009; Process status definitions
X`009$sfdef`009`009`009`009; Define saved frame offsets
X`009$ssdef`009`009`009`009; Define system statii
X`009$vadef`009`009`009`009; Define virtual address offsets
X
X`009.psect`009$DATA`009Rd, Wrt, NoShr, NoExe, Pic, Long
X
XSIGARG:`009.blkb`009CHF$S_CHFDEF1+<1*4>`009; Signal array
XMCHARG:`009.blkb`009CHF$S_CHFDEF2`009`009; Mechanism array
X
XIMGDMP:`009.ascid "IMGDMP"`009`009`009; Name of the image dumper to use
XDFLNAM:`009.ascid "SYS$SHARE:.EXE"`009`009; Defaults to use for the name
XHDRBUF:`009.blkb`009512`009`009`009; Buffer to use for image header
XINADR:`009.long`009`094x200, 1@VA$V_P1-1`009; Input mapping range (in P0)
XRETADR:`009.long`0090, 0`009`009`009; Returned mapped range
X`012
X.subtitle PROCESS_DUMP - Generate a process dump file
X;++
X; PROCESS_DUMP - Generate a process dump file
X;
X; Call:`009`009status.wl = Process_Dump()
X;
X; Passed:
X;  lots of implicit inputs (your whole process environment)
X; Returns:
X;  status.wl (in R0)
X;`009Final system status of call
X;--
X`009.psect $CODE`009Rd, NoWrt, Shr, Exe, Pic, Long
X
X.entry`009PROCESS_DUMP, `094m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11> ; Must save a
Vll registers
X
X`009subl`009#CHF$S_CHFDEF, sp`009; Get some space for an argument list
X`009movl`009sp, ap`009`009`009; AP => fake argument list
X`009movzwl`009#2, (ap)`009`009; 2 arguments (signal and mechanism)
X;
X`009moval`009SIGARG, r2`009`009; R2 => Fake signal array
X`009movl`009r2, CHF$L_SIGARGLST(ap)`009; Save pointer in fake argument list
X`009movl`009#3, CHF$L_SIG_ARGS(r2)`009; Three arguments...
X`009movl`009#SS$_DEBUG, CHF$L_SIG_NAME(r2)`009; ...false signal is SS$_DEBUG
X`009movl`009SF$L_SAVE_PC(fp), CHF$L_SIG_ARG1(r2)`009; ...caller's PC
X`009movpsl`009CHF$L_SIG_ARG1+4(r2)`009; ...caller's PSL
X;
X`009moval`009MCHARG, r2`009`009; R2 => fake mechanism array
X`009movl`009r2, CHF$L_MCHARGLST(ap)`009; Save pointer in fake argument list
X`009movl`009#4, CHF$L_MCH_ARGS(r2)`009; Always 4 arguments in mechanism arra
Vy
X`009movl`009fp, CHF$L_MCH_FRAME(r2)`009; We are the establisher
X`009movl`009#0, CHF$L_MCH_DEPTH(r2)`009; No depth (no traceback)
X`009movl`009r0, CHF$L_MCH_SAVR0(r2)`009; Caller's R0 value
X`009movl`009r1, CHF$L_MCH_SAVR1(r2)`009; Caller's R1 value
X
X`009$imgact_s`009`009 -`009;
X`009`009name   = IMGDMP`009,-`009; Name of image dumper to use
X`009`009dflnam = DFLNAM`009,-`009; Name defaults to use
X`009`009hdrbuf = HDRBUF`009,-`009; Where to place header
X`009`009imgctl = #<IAC$M_MERGE!IAC$M_EXPREG>,- ; Merge and expand region
X`009`009inadr  = INADR`009,-`009; Where to map code (first free VA space)
X`009`009retadr = RETADR`009,-`009; Mapped addresses returned here
X`009`009ident  = 0`009,-`009; No ident specified
X`009`009acmode = #PSL$C_USER`009; Map at minimum access mode
X`009blbc`009r0, 10$`009`009`009; Check for any error
X`009$imgfix_s`009`009`009; Do any relocation fixups
X`009blbc`009r0, 10$`009`009`009; Check for any error
X
X`009movl`009RETADR, r1`009`009; Get load address
X`009movab`009@8(r1)`091r1`093,r1`009`009; Calculate the entry address
X
X`009jsb`009(r1)`009`009`009; Call the dump library
X
X10$:`009ret
X
X`009.end
$ CALL UNPACK [.PDUMP]PROCESS_DUMP.MAR;1 1244726983
$ v=f$verify(v)
$ EXIT

