![]() |
A Callable Memory Dump Routine SimoSNAP - The COBOL Source Code http://www.simotime.com |
| When technology complements business | Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
This document describes the function and usage of the SimoSNAP module. A listing of the COBOL source code for the SimoSNAP routine is included. Additional information about this program may be obtained by sending an e-mail to: helpdesk@simotime.com
The SimoSNAP routine (or callable program) is a callable memory dump routine for a linear area of memory. Its primary purpose is to dump the working storage section of a program but may be used to dump other areas of memory or partial areas of working storage..
Two copy files are provided to define the "eye-catcher" fields in the COBOL Working Storage Section. The copy statements will create fields that will be used by the SimoSNAP routine to determine the start and stop addresses for the memory dump.
The first copy statement (STSNAPB1.CPY) should be the first statement in the COBOL Working Storage Section. The second copy statement (STSNAPB2.CPY) should be the last statement in the COBOL Working Storage Section.
WORKING STORAGE.
*The following should be the first statement in Working Storage.
COPY STSNAPB1
*...
*The User's Working Storage Definitions go here...
*...
*The following should be the last statement in Working Storage.
COPY STSNAPB2.
The coding to do the actual call to display and log the snap dump information information is as follows.
*****************************************************************
* The coding required to do the call to the File Status Routine.
* ------------------------------------------------------------
call 'SIMOSNAP' using STSNAP-START STSNAP-CEASE
The SimoSNAP program was created and tested on an intel system with Microsoft Windows/XP and Micro Focus Net Express. This packet uses members that are part of The SimoMODS Series of callable programs. Therefore, the SimoMODS packet should be installed prior to running programs that use SimoSNAP. The required prerequisite programs from the SimoMODS Series are SimoNOTE.CMD, SimoEXEC.EXE, SimoLOGS.DLL and SimoSNAP.DLL.
You may click here to view an example of a COBOL program that uses the callable SimoSNAP routine.
The following is the COBOL Source Code.
*set dialect(MF) assign(external) nooptional-file
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMOSNAP.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* SOURCE MODULE SIMOSNAP.CBL
*****************************************************************
* SIMOSNAP - Displays a message and does a GOBACK.
*
* DESCRIPTION
* -----------
* This program will display a message and force an ABEND with
* a GOBACK or STOP RUN. The RETURN-CODE will be set to 16.
*
*****************************************************************
* MAINTENANCE
* -----------
* 1999/03/89 Simmons, Created program.
* 1999/03/89 Simmons, No changes to date.
*
*****************************************************************
DATA DIVISION.
*****************************************************************
WORKING-STORAGE SECTION.
*
*****************************************************************
* Data-structure for Title and Copyright...
* ------------------------------------------------------------
01 SIM-TITLE.
05 T1 pic X(11) value '* SIMOSNAP '.
05 T2 pic X(34) value 'User callable memory dump routine' .
05 T3 pic X(10) value ' v10.06.08'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* SIMOSNAP '.
05 C2 pic X(20) value 'Copyright 1987-2010 '.
05 C3 pic X(28) value ' SimoTime Enterprises, LLC '.
05 C4 pic X(20) value ' All Rights Reserved'.
01 FLAGS-FOR-SNAPCALL.
05 FLAG-FOR-DISPLAY pic X value 'Y'.
05 FLAG-FOR-JOURNAL pic X value 'Y'.
05 FLAG-FOR-STACK pic X value 'N'.
05 FLAG-FOR-KEEP-OPEN pic X value 'Y'.
* O=Offset
* F-Flip
* N=Native
05 FLAG-FOR-ADDR-FMT pic X value 'O'.
* ------------------------------------------------------------
* Buffer used for posting dump information to the console.
01 DUMP-BUFFER.
05 DUMP-TEXT pic X(79).
* ------------------------------------------------------------
* Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* SIMOSNAP '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(68) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
01 SYSSNAP-OPEN-FLAG pic X value 'N'.
01 FIRST-TIME pic X value 'Y'.
01 MESSAGE-LENGTH pic 9(5) value 1024.
01 RMO-1 pic 9(7) value 0.
01 TWO-BYTES.
05 TWO-BYTES-01 pic X.
05 TWO-BYTES-02 pic X.
01 TWO-BYTES-BINARY redefines TWO-BYTES
pic S9(3) comp.
01 IX-0 pic 9999 value 0.
01 IX-1 pic 9999 value 0.
01 IX-2 pic 9999 value 0.
01 IX-3 pic 9999 value 0.
01 IX-4 pic 9999 value 0.
01 IX-5 pic 9999 value 0.
01 PT-1 pic 9999 value 0.
01 PT-2 pic 9999 value 0.
01 MEM-ADDR-OFFSET pic 9(7) value 0.
01 WA-5 pic X(5) value is SPACES.
01 BUFFER-LENGTH pic 9999 value 0.
01 LINE-LENGTH pic 9999 value 0.
01 MEM-ADDRESS.
05 MEM-ADDRESS-PTR usage POINTER.
01 MEM-ADDR-G-OFFSET.
05 MEM-ADDR-V-OFFSET pic S9(9) comp value 0.
01 SNAP-LINE.
05 filler pic X(10) value '@SimoSNAP '.
05 filler pic X(23) value 'by SimoTime Enterprises'.
05 filler pic X(46) value all '*'.
01 SNAP-LINE-02.
05 filler pic X(10) value '@SimoSNAP '.
05 filler pic X(20) value 'Dump Buffer Size is '.
05 WS-MEMORY-LENGTH pic 9(7) value 0.
01 DUMP-HEADER.
05 filler pic X value '@'.
05 H1 pic X(8) value 'Hex-Addr'.
05 filler pic X value ' '.
05 H2 pic X(35) value 'Hex..... ........ ........ ........'.
05 filler pic X value ' '.
05 H3 pic X(16) value 'ebcdic..........'.
05 filler pic X value ' '.
05 H4 pic X(16) value 'ascii...........'.
01 DUMP-LINE.
05 filler pic X value '@'.
05 D1 pic X(8) value 'aaaaaaaa'.
05 filler pic X value ' '.
05 D2 pic X(35) value 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'.
05 filler pic X value ' '.
05 D3 pic X(16) value '................'.
05 filler pic X value ' '.
05 D4 pic X(16) value '................'.
01 X-DUMP-LINE.
05 filler pic X value '@'.
05 X1 pic X(8) value 'aaaaaaaa'.
05 filler pic X value ' '.
05 X2 pic X(35) value 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'.
05 filler pic X value ' '.
05 X3 pic X(16) value '................'.
05 filler pic X value ' '.
05 X4 pic X(16) value '................'.
COPY HEXTABLE.
* ------------------------------------------------------------
* Uses COMP-5 for "Little Endian" format.
01 STSNAP-START-X.
05 STSNAP-START-PTR usage pointer.
01 STSNAP-START-5 redefines STSNAP-START-X.
05 STSNAP-START-CP5 pic S9(5) COMP-5.
01 STSNAP-CEASE-X.
05 STSNAP-CEASE-PTR usage pointer.
01 STSNAP-CEASE-5 redefines STSNAP-CEASE-X.
05 STSNAP-CEASE-CP5 pic S9(5) COMP-5.
*****************************************************************
LINKAGE SECTION.
01 STSNAP-START pic X.
01 STSNAP-CEASE pic X.
*****************************************************************
PROCEDURE DIVISION using STSNAP-START STSNAP-CEASE.
move SIM-TITLE to MESSAGE-BUFFER
perform Z-DISPLAY-MESSAGE-BUFFER
move SIM-COPYRIGHT to MESSAGE-BUFFER
perform Z-DISPLAY-MESSAGE-BUFFER
evaluate FLAG-FOR-ADDR-FMT
when 'F' move 'Hex-Addr' to H1
when 'O' move 'Hex-Disp' to H1
when 'N' move 'Hex-Addr' to H1
when other move 'Hex-Addr' to H1
end-evaluate
move SNAP-LINE to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT-79.
if STSNAP-START(1:16) not = 'STSNAP-START-TAG'
or STSNAP-CEASE(1:16) not = 'STSNAP-CEASE-TAG'
move '@SimoSNAP has received an invalid request'
to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT-79
GOBACK
end-if.
set STSNAP-START-PTR to address of STSNAP-START
set STSNAP-CEASE-PTR to address of STSNAP-CEASE
subtract STSNAP-START-CP5 from STSNAP-CEASE-CP5
giving WS-MEMORY-LENGTH
add 16 to WS-MEMORY-LENGTH
move SNAP-LINE-02 to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT-79.
move DUMP-HEADER to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT-79
perform DUMP-PROCESSING
GOBACK.
*****************************************************************
DUMP-PROCESSING.
add 1 to ZERO giving IX-0
add 1 to ZERO giving IX-1
add 1 to ZERO giving IX-5
add WS-MEMORY-LENGTH to ZERO giving BUFFER-LENGTH
if BUFFER-LENGTH greater than 15
add 16 to ZERO giving LINE-LENGTH
else
add BUFFER-LENGTH to ZERO giving LINE-LENGTH
end-if
set MEM-ADDRESS-PTR to address of STSNAP-START
move ZERO to MEM-ADDR-V-OFFSET
perform until BUFFER-LENGTH = 0
add 1 to ZERO giving PT-1
evaluate FLAG-FOR-ADDR-FMT
when 'F' add 7 to ZERO giving PT-2
when 'O' add 1 to ZERO giving PT-2
when 'N' add 1 to ZERO giving PT-2
when other add 1 to ZERO giving PT-2
end-evaluate
add 1 to ZERO giving IX-4
move X-DUMP-LINE to DUMP-LINE
perform 4 times
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
evaluate FLAG-FOR-ADDR-FMT
when 'F' move MEM-ADDRESS(PT-1:1) to TWO-BYTES-02
when 'O' move MEM-ADDR-G-OFFSET(PT-1:1)
to TWO-BYTES-02
when 'N' move MEM-ADDRESS(PT-1:1) to TWO-BYTES-02
when other move MEM-ADDRESS(PT-1:1) to TWO-BYTES-02
end-evaluate
add TWO-BYTES-BINARY to 1 giving IX-5
move TAB-X1(IX-5) to WA-5
move WA-5(1:2) to D1(PT-2:2)
add 1 to PT-1
evaluate FLAG-FOR-ADDR-FMT
when 'F' subtract 2 from PT-2
when 'O' add 2 to PT-2
when 'N' add 2 to PT-2
when other add 2 to PT-2
end-evaluate
end-perform
add 1 to ZERO giving IX-2
add 1 to ZERO giving IX-3
perform DUMP-SINGLE-LINE
if BUFFER-LENGTH greater than 15
subtract 16 from BUFFER-LENGTH
else
subtract BUFFER-LENGTH from BUFFER-LENGTH
end-if
if BUFFER-LENGTH greater than 15
add 16 to ZERO giving LINE-LENGTH
else
add BUFFER-LENGTH to ZERO giving LINE-LENGTH
end-if
set MEM-ADDRESS-PTR up by 16
evaluate FLAG-FOR-ADDR-FMT
when 'F' set MEM-ADDRESS-PTR up by 16
when 'O' add 16 to MEM-ADDR-V-OFFSET
when 'N' set MEM-ADDRESS-PTR up by 16
when other set MEM-ADDRESS-PTR up by 16
end-evaluate
end-perform
exit.
*****************************************************************
DUMP-SINGLE-LINE.
perform until LINE-LENGTH = 0
* Get table element
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move STSNAP-START(IX-1:1) to TWO-BYTES-02
add TWO-BYTES-BINARY to 1 giving IX-5
move TAB-X1(IX-5) to WA-5
move WA-5(1:2) to D2(IX-2:2)
* Increment to next position in hex-dump area of buffer
add 2 to IX-2
if IX-2 = 9
or IX-2 = 18
or IX-2 = 27
add 1 to IX-2
end-if
* EBCDIC Print Character and increment to next position
move WA-5(3:1) to D3(IX-3:1)
add 1 to IX-3
* ASCII Print Character and increment to next position
move WA-5(4:1) to D4(IX-4:1)
add 1 to IX-4
* Increment pointer to next input buffer byte
add 1 to IX-1
subtract 1 from LINE-LENGTH
end-perform
move DUMP-LINE to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT-79
exit.
*****************************************************************
* Display CONSOLE messages... *
*****************************************************************
Z-DISPLAY-MESSAGE-BUFFER.
if MESSAGE-TEXT-2 = SPACES
display MESSAGE-BUFFER(1:79)
else
display MESSAGE-BUFFER
end-if
move all SPACES to MESSAGE-TEXT
exit.
*---------------------------------------------------------------*
Z-DISPLAY-MESSAGE-TEXT-79.
display MESSAGE-TEXT(1:79)
move all SPACES to MESSAGE-TEXT
exit.
*****************************************************************
* This example is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
The purpose of this document is to provide a COBOL Source member and a brief description for installing and using the SimoSNAP module.
Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to Simotime Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
Permission to use, copy, modify and distribute this software for a non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.
You may click here to view an example of a COBOL program that uses the callable SimoSNAP routine.
You may view the complete list of SimoTime callable Modules or Driver Programs at http://www.simotime.com/simomods.htm.
The SimoZAPS Utility Program has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPS can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function provides the capability of viewing, finding or patching the contents of a file in hexadecimal.
This item will provide a link to an ASCII or EBCDIC translation table. A column for decimal, hexadecimal and binary is also included.
This document provides a quick summary of the File Status Key for VSAM data sets and QSAM files.
Check out The SimoTime Library for a wide range of topics for Programmers, Project Managers and Software Developers.
To review all the information available on this site start at The SimoTime Home Page .
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
We appreciate your comments and feedback.
Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |