Trailing-Edge
-
PDP-10 Archives
-
BB-FB49A-RM
-
sources/snttrc.b36
There are no other files named snttrc.b36 in the archive.
%title 'SNT Trace Module'
module SNTTRC (ident = 'Version 1.05') =
begin
! Copyright (c) 1984, 1985 by
! DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts
!
! This software is furnished under a license and may be used and copied
! only in accordance with the terms of such license and with the
! inclusion of the above copyright notice. This software or any other
! copies thereof may not be provided or otherwise made available to any
! other person. No title to and ownership of the software is hereby
! transferred.
!
! The information in this software is subject to change without notice
! and should not be construed as a commitment by Digital Equipment
! Corporation.
!
! Digital assumes no responsibility for the use or reliability of its
! software on equipment which is not supplied by Digital.
!++
! FACILITY: DECnet/SNA Gateway Protocol Trace Utility Trace Collector.
!
! ABSTRACT: This module provide routines to execute the Trace command
! from the command parser.
!
! ENVIRONMENT: TOPS-20 Operating Systems, user mode.
!
! AUTHOR: Dennis Brannon, CREATION DATE: January 17, 1984
!
! MODIFIED BY:
!
! D. Brannon, 11-Oct-84 : VERSION 1.00
!
! 1.01 D. Brannon, 25-Oct-84
! Uncommented the check for conflicting qualifiers (SNT$_CONFQUAL)
! and removed external definition for TRC$TERMINATE_TRACE.
!
! 1.02 D. Brannon, 29-Oct-84
! Uncommented the call to FIL$PURGE.
!
! 1.03 D. Brannon, 29-Oct-84
! Removed SNT$_EXSIZE and SNT$_EXENTRIES from TRC$LOOP and replace
! them with $TRUE.
!
! 1.04 D. Brannon, 31-Jan-84
! Fixed dot bug on the ST[ST_OUTPUT_FILE] used in the SNT$_OPENOUT
! error message so that it will correctly display the file it could
! not open.
!
! 1.05 D. Brannon, 13-Mar-85
! Changed the default to /PU (physical) trace from /CIRCUIT trace.
!--
%sbttl 'Declarations'
!
! REQUIRED FILES
!
library 'MONSYM'; ! Monitor symbols
library 'SYS:TXTLIB'; ! Text definitions
library 'SNTDEF'; ! SNT common definitions
library 'SNTLIB'; ! SNT protocol definitions
!library 'SNARJB'; ! BLISS interface to Access Routines
library 'DBGTRB'; ! Debugging interface to Access Routines
require 'JSYS'; ! TOPS-20 JSYS declarations
FORWARD ROUTINE
TRC$TRACE,
TRC$SET_DEFAULTS,
TRC$FILELOOP,
TRC$START,
TRC$LOOP,
TRC$STOP,
TRC$CTRLZ_TRAP : NOVALUE;
!
! EXTERNAL REFERENCES:
!
EXTERNAL
ST: SNTBLOCK,
WORK_AREA: vector [1000];
external
CONTROL: GLOBAL_CONTROL_BLOCK;
external routine ! GALAXY routines
GLXLIB_ROUTINES;
EXTERNAL ROUTINE
FIL$BUILD_HEADER_RECORD,
FIL$OPEN_OUTPUT_FILE,
FIL$CLOSE_OUTPUT_FILE,
FIL$OPEN_TRACE_FILE,
FIL$CLOSE_TRACE_FILE,
FIL$WRITE_HEADER_RECORD,
FIL$WRITE_RECORD,
FIL$TERMINATE_TRACE,
FIL$PURGE,
MSG$WRITE_HEADER_RECORD,
MSG$WRITE_RECORD,
PSI$TTY_INIT : novalue,
PSI$TTY_RESTORE : novalue,
PSI$ENABLE_INTERRUPTS : novalue,
PSI$DISABLE_INTERRUPTS : novalue,
SNT$MSGHANDLER,
REX$TRACE,
REX$SERVICE_REQUEST,
TXT$WRITE,
USP$ERROR_MESSAGE: novalue;
%sbttl 'TRC$TRACE'
%global_routine ('TRC$TRACE') =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine performs the trace operation.
!
! FORMAL PARAMETERS:
!
! none
!
! IMPLICIT INPUTS:
!
! ENTRIES
! FILESIZE
! MAXFILES
! MOD
! SESSION
! CIRCUIT
! NODE
!
! IMPLICIT OUTPUTS:
!
! NONE
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! SNT$_NORMAL
!
! SIDE EFFECTS:
!
! NONE
!
!--
begin
local
STATUS,
STATUS2;
!
! Enable condition handler.
!
ENABLE
SNT$MSGHANDLER;
PSI$TTY_INIT (CTRLZ_TRAP,TRC$CTRLZ_TRAP); ! Set up CTRL/Z (^Z) TRAP
ST[STOP_TRACE] = $FALSE;
!
! Set up all initial parameter values.
!
TRC$SET_DEFAULTS ();
!
! Attempt to start the trace.
!
STATUS = TRC$START (.ST[ST_GATEWAY],
.ST[ST_CIRCUIT_ID]);
if not .STATUS
then
return .STATUS;
!
! Signal the start.
!
if (not .ST[SW_ANALYZE]) or .ST[SW_OUTPUT]
then
$SNT_INFO (SNT$_BEGIN, 1, 0);
!
! Tell them about the ^Z because RSX and VMS use ^C to stop tracing
!
jsys_psout (ch$asciz(%CHAR($CR,$LF),'Type ^Z to stop tracing',%CHAR($CR,$LF,$CR,$LF)));
!
! Trace until files are exhausted.
!
STATUS = TRC$FILELOOP (.ST[ST_GATEWAY],
.ST[ST_OUTPUT_FILE],
.ST[ST_CIRCUIT_ID]);
!
! Signal the end.
!
$SNT_INFO (SNT$_ENDED, 1, 0);
!
! Stop the trace.
!
STATUS = TRC$STOP ();
PSI$TTY_RESTORE ();
RETURN SNT$_NORMAL;
end; ! End of TRC$TRACE
%sbttl 'TRC$SET_DEFAULTS'
%routine ('TRC$SET_DEFAULTS') =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine sets up the parameters for the trace operation.
!
! FORMAL PARAMETERS:
!
! none
!
! IMPLICIT INPUTS:
!
! ST[ST_ENTRIES]
! ST[ST_FILESIZE]
! ST[ST_MAXFILES]
! ST[ST_MOD]
! ST[ST_SESSION]
! ST[ST_SIZE]
! ST[ST_CIRCUIT_ID]
! ST[ST_GATEWAY]
!
! IMPLICIT OUTPUTS:
!
! ST[ST_TYPE]
! ST[ST_ANALYZE]
! ST[ST_ENTRIES]
! ST[ST_FILESIZE]
! ST[ST_MAXFILES]
! ST[ST_SESSION]
! ST[SIZE]
! ST[WIDE]
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! SNATRACE$_CONFQUAL
! SNATRACE$_NORMAL
!
! SIDE EFFECTS:
!
! NONE
!
!--
begin
local
STATUS;
!
! Determine type of trace from parsing flags.
!
if (.ST[SW_SESSION] +
.ST[SW_PU] +
.ST[SW_CIRCUIT]) gtru 1
then
$SNT_ERROR (SNT$_CONFQUAL, 0);
if .ST[ST_TYPE] eqlu 0
then
if .ST[SW_SESSION] then
ST[ST_TYPE] = FCT_SESSION_K$TRAPRO ! Session trace
else if .ST[SW_PU] then
ST[ST_TYPE] = FCT_PU_K$TRAPRO ! PU trace
else if .ST[SW_CIRCUIT] then
ST[ST_TYPE] = FCT_CIRCUIT_K$TRAPRO ! Circuit trace
else
ST[ST_TYPE] = FCT_PU_K$TRAPRO; ! Default is PU trace
!
! Determine the session id.
!
if not .ST[SW_SESSION]
then
ST[ST_SESSION] = 0;
!
! Determine the maximum trace data size.
!
if .ST[SW_SIZE]
then
begin
ST[ST_SIZE] = SIZE_MIN_K$SNTCOM + .ST[ST_SIZE];
!
! If this is a circuit trace then add two bytes for the SDLC header.
!
if .ST[ST_TYPE] eql FCT_CIRCUIT_K$TRAPRO
then
ST[ST_SIZE] = .ST[ST_SIZE] + 2;
end
else
!
! Let the server provide the default.
!
ST[ST_SIZE] = SIZE_DEF_K$SNTCOM;
!
! Determine the buffering level for the server.
!
if not .ST[SW_BUFFERS]
then
!
! Let the server supply the default.
!
ST[ST_BUFFERS] = BUFFERS_DEF_K$SNTCOM;
!
! Set up stopping criteria.
!
if not .ST[SW_ENTRIES]
then
ST[ST_ENTRIES] = ENTRIES_DEF_K$SNTCOM;
if not .ST[SW_SIZE]
then
ST[ST_FILESIZE] = FILESIZE_DEF_K$SNTCOM;
!
! Set the maximum files count.
!
if not .ST[SW_VERSION_LIMIT]
then
ST[ST_MAXFILES] = MAXFILES_DEF_K$SNTCOM;
!
! Set up output file.
!
if not .ST[SW_OUTPUT]
then
begin
if .ST[SW_ANALYZE]
then
ST[SW_OUTPUT] = $FALSE
else
ST[SW_OUTPUT] = $TRUE;
end;
! return SNATRACE$_NORMAL
return $TRUE;
end; ! End of TRC$SETDEFAULTS
%sbttl 'TRC$FILELOOP'
%routine ('TRC$FILELOOP', NODE, FILE, CIRCUIT) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine controls file operations for the trace.
!
! FORMAL PARAMETERS:
!
! NODE Gateway node specification.
! FILE Trace output file specification.
! CIRCUIT Circuit specification.
!
! IMPLICIT INPUTS:
!
! ST[ST_TYPE]
! ST[ST_ANALYZE]
! ST[ST_OUTPUT]
! ST[STOP_TRACE]
!
! IMPLICIT OUTPUTS:
!
! NONE
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! SNT$_CONFQUAL Conflicting qualifiers.
! SNT$_NORMAL Success.
!
! SIDE EFFECTS:
!
! NONE
!
!--
begin
local
DEFFILE,
EXITSTATUS,
FILECOUNT : INITIAL (0),
HEADERBUF : BLOCK [BUFLEN_DEF_K$SNTCOM],
HEADERDSC : VECTOR [2],
HEADERLEN,
STATUS,
STATUS2;
!
! Initialize the file allocation size.
!
ST[ST_ALQ] = 0;
!
! Set up default file name.
!
! if .ST[SW_ANALYZE]
! then
! DEFFILE = CH$ASCIZ ('SNT.LIS')
! else
! DEFFILE= CH$ASCIZ ('SNT.DAT');
!
! Read the Trace Started message returned in response to
! the Init Trace.
!
STATUS = REX$SERVICE_REQUEST();
if .STATUS NEQ SNT$_NORMAL
then $SNT_ERROR (SNT$_START, 0);
!
! Loop until stopping conditions are satisfied.
!
while 1 do
begin
!
! Increment the file count.
!
FILECOUNT = .FILECOUNT + 1;
!
! Check for CTRL/Z
!
if .ST[STOP_TRACE]
then
EXITLOOP;
!
! Open the output file.
!
if .ST[SW_OUTPUT]
then
begin
STATUS = FIL$OPEN_OUTPUT_FILE(.ST[ST_FILENUM]);
if not .STATUS
then
$SNT_ERROR (SNT$_OPENOUT,
ST[ST_OUTPUT_FILE],
.STATUS);
!
! Purge output files down to the required limit.
!
if .ST[ST_MAXFILES] GTR 1
then
FIL$PURGE (.ST[ST_OUTPUT_JFN], .ST[ST_MAXFILES] - 1);
end
else
begin
STATUS = FIL$OPEN_OUTPUT_FILE(0);
if not .STATUS
then
$SNT_ERROR (SNT$_OPENOUT,
ST[ST_OUTPUT_FILE],
.STATUS);
end;
!
!
! Build and write the header record.
!
STATUS = FIL$BUILD_HEADER_RECORD ();
if not .STATUS
then
$SNT_ERROR (.STATUS, 0);
!
! Format and output the header. If an output file was specified
! then write to the file.
!
if .ST[SW_ANALYZE]
then
begin
STATUS = MSG$WRITE_HEADER_RECORD (.ST[ST_OUTPUT_JFN],
.ST[ST_HEADER]);
if not .STATUS
then
$SNT_ERROR (SNT$_WRITEERR,
ST[ST_OUTPUT_FILE],
.STATUS);
end
else
begin
STATUS = FIL$WRITE_HEADER_RECORD (.ST[ST_OUTPUT_JFN],
.ST[ST_HEADER]);
if not .STATUS
then
$SNT_FATAL (SNT$_WRITEERR,
ST[ST_OUTPUT_FILE],
.STATUS);
end;
!
! Request trace data.
!
EXITSTATUS = TRC$LOOP ();
!
! Close the output file.
!
if .ST[SW_OUTPUT]
then
begin
STATUS = FIL$CLOSE_OUTPUT_FILE (.ST[ST_OUTPUT_JFN], .STATUS2);
if not .STATUS
then
$SNT_FATAL (SNT$_CLOSEOUT,
ST[ST_OUTPUT_FILE],
.STATUS);
end;
!
! If an error occurred collecting data or only one file was
! specified then exit.
!
IF (NOT .EXITSTATUS) OR (.ST[ST_MAXFILES] LEQ 1)
THEN
RETURN .EXITSTATUS;
END;
RETURN $TRUE;
END; ! End of SNT_FILELOOP
%sbttl 'TRC$START'
%routine ('TRC$START', NODE, CIRCUIT) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine starts the trace operation with the server program.
!
! FORMAL PARAMETERS:
!
! NODE Descriptor of node id string.
! CIRCUIT Descriptor of circuit id string.
!
! IMPLICIT INPUTS:
!
! ST[ST_BUFFERS] Buffering level.
! ST[ST_SESSION] Session number (if applicable).
! ST[ST_TYPE] Type of trace function.
!
! IMPLICIT OUTPUTS:
!
! NONE
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! NONE
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
LOCAL
STATUS,
STATUS2;
!
! Attempt to start the trace.
!
STATUS = REX$TRACE();
if (not .STATUS)
then
$SNT_ERROR (SNT$_INIT, 0, .STATUS, 0, .STATUS2);
return $TRUE;
END; ! End of TRC$START
%sbttl 'TRC$LOOP'
%routine ('TRC$LOOP') =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine receives and records trace data entries.
!
! FORMAL PARAMETERS:
!
! NONE
!
! IMPLICIT INPUTS:
!
! ST[ST_TYPE] Type of trace being performed.
! ST[ST_ALQ] File allocation size.
! ST[ST_ENTRIES] Maximum number of entries allowed in this file.
! ST[ST_FILESIZE] Maximum size of file.
! ST[ST_WIDE] Width of analyzed output line.
!
! IMPLICIT OUTPUTS:
!
! ST[STOP_TRACE] Modified.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! NONE
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
LOCAL
BLOCK_COUNT,
BUFDSC : $DSC INITIAL (0, 0),
ENTRY_COUNT,
MSGDSC : $DSC INITIAL (0, 0),
STATUS,
STATUS2;
!
! Set up stopping criteria.
!
ENTRY_COUNT = .ST[ST_ENTRIES];
BLOCK_COUNT = .ST[ST_FILESIZE];
!
! Read trace data until stopping criteria are satisfied.
!
WHILE 1 DO
BEGIN
IF .ST[STOP_TRACE]
THEN
RETURN SNT$_NORMAL;
WHILE 1 DO
BEGIN
IF .ST[STOP_TRACE]
THEN
RETURN SNT$_NORMAL;
!
! Read trace data.
!
STATUS = REX$SERVICE_REQUEST();
if .STATUS EQL SNT$_NODATA
then
EXITLOOP;
if (not .STATUS)
then
$SNT_ERROR (.STATUS);
!
! Update stopping criteria.
!
ENTRY_COUNT = .ENTRY_COUNT - 1;
!
! Check stopping criteria.
!
IF (NOT .ST[STOP_TRACE])
THEN
BEGIN
IF .ENTRY_COUNT EQLU 0
THEN
RETURN SNT$_NORMAL;
IF .ST[ST_ALQ] GTRU .BLOCK_COUNT
THEN
RETURN SNT$_NORMAL;
END;
END;
END;
RETURN SNT$_NORMAL
end; ! End of TRC$LOOP
%sbttl 'TRC$STOP'
%routine ('TRC$STOP') =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine stops the trace operation.
!
! FORMAL PARAMETERS:
!
! NONE
!
! IMPLICIT INPUTS:
!
! NONE
!
! IMPLICIT OUTPUTS:
!
! NONE
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! NONE
!
! SIDE EFFECTS:
!
! NONE
!
!--
begin
local
STATUS,
STATUS2;
!
! Stop tracing.
!
STATUS = FIL$TERMINATE_TRACE (STATUS2);
if not .STATUS
then
$SNT_ERROR (.STATUS2, 0);
RETURN SNT$_NORMAL
end; ! End of TRC$STOP
%sbttl 'TRC$CTRLZ_TRAP'
%global_routine ('TRC$CTRLZ_TRAP') : NOVALUE =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine processes the Trap generated by typing CTRL/Z (^Z) to
! the terminal.
!
! FORMAL PARAMETERS:
!
! NONE
!
! IMPLICIT INPUTS:
!
! NONE
!
! IMPLICIT OUTPUTS:
!
! ST[STOP_TRACE] is set to TRUE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
! NONE
!
! SIDE EFFECTS:
!
!
!--
begin
!
! Set the stop indicator flag.
!
ST[STOP_TRACE] = $TRUE;
return;
end; ! End of TRC$CTRLZ_TRAP
end ! End of module
Eludom