Chapter Contents

Previous

Next
storck

storck



Checks if Storage Has Been Corrupted

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
USAGE NOTES
EXAMPLE
EXAMPLE OUTPUT IN DDN:STGRPT


SYNOPSIS

#include <lclib.h>

int storck (unsigned options, char * path, char * title);


DESCRIPTION

The storck function calls the SAS/C Debugger storage command to determine if storage has been corrupted. See the SAS/C Debugger User's Guide for details on the report created by the storage command.

The options value is a bit string formed by OR-ing the option bits. The bits are defined symbolically; the header file lclib.h should be included to obtain their definitions. The flags and their meanings are as follows:

STORCK_NARROW
limit output report to 80 columns (default: 132).

STORCK_NOAPPEND
do not append output to previous output (default: APPEND).

STORCK_FREE_CHECK
specifies that Heap FREE storage should be inspected for correctness and consistency.

STORCK_HEAP_CHECK
specifies that Heap storage, other than FREE, be inspected for correctness and consistency (default: STORCK_HEAP_CHECK).

NO_STORCK_HEAP_CHECK
specifies that free HEAP storage should not be checked.

STORCK_HEAP_REPT
specifies that a usage report be created for Heap storage.

STORCK_STACK_CHECK
specifies that Stack storage should be inspected for correctness and consistency (default: STORCK_STACK_CHECK).

NO_STORCK_STACK_CHECK
specifies that STACK storage should not be checked.

STROCK_STACK_REPT
specifies that a usage report be created for Stack storage.

The path argument specifies the output path for the messages and report produced by storck. This value must be specified. It can be NULL to request a default value determined by the operating system. For details, see the information on general filename specification in I/O Functions. Following are the default values when NULL is specified:

OS/390 Batch
DDN:DBGSTG

OS/390 TSO
Same as for batch if the DDname id defined, otherwise DSN:userid.pgmname.DBGSTG

OS/390 CICS
Transient Data Queue `SASR'

OS/390 USS
HFS:dbgstg.report

CMS
CMS:pgmname DBGSTG A


RETURN VALUE

storck returns 0 if no corruption is detected and a nonzero value if corruption is detected.


CAUTION

Care and planning should be exercised on the number of times one calls the storck function. Repeated calls will result in an increase in processing time. For example, two to three calls would not normally increase processing time significantly; however, 300 to 500 calls would affect processing time.


USAGE NOTES

The storck function is a debugging aid to assist in finding code that is overlaying storage by accident and to report on how the heap and stack are utilized.

Prior to Release 7.00, the Debugger storage command could be called during a debugger session from the command line or after the program terminated with the run-time option =STORAGE.

The storck function allows the user to call the storage command at any time during execution. For example, the user could isolate an overlay to a single function by calling storck before calling the suspect function, then call the suspect function, and then call storck again to see if storage was corrupted.

To call storck in all-resident applications you must code

#define ALLOW_TRANSIENT

before including resident.h.


EXAMPLE

#include <stdio.h>
#include <lclib.h>
#include <time.h>
int main ()
{
  int exit_rc       = 0;
  unsigned options  = 0;
  char title_buffer[80];
  char * envarg;
  time_t current;
  envarg = getenv("CHECK_STOR");
  if ( envarg != NULL)
      { /* user wants storage check on this run */                            
       time(&current);               // current time
       sprintf(title_buffer,"Storage Report - TimeStamp: %s\n",
               ctime(&current));    // build title with current time
       options = STORCK_HEAP_CHECK+STORCK_STACK_CHECK+STORCK_FREE_CHECK;
       exit_rc = storck(options, "DDN:STGRPT", title_buffer);
       if (exit_rc != 0) fprintf(stderr,"Storage corrupted!");
      };
  exit(exit_rc);
}


EXAMPLE OUTPUT IN DDN:STGRPT

Storage Report - TimeStamp: Mon Feb 21 13:11:17 2000

No corruptions found in heap.
No corruptions found in free heap storage.
No corruptions found in stack.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.