#ifdef public_domain_notice Copyright (c) 1996 David P. Murphy for Datametrics Systems Corporation --- please send all comments and bug reports to murphy@connor.datametrics.com Permission is granted to any individual or institution to use, copy, or redistribute this software so long as all of the original files are included, that it is not sold for profit, and that this copyright notice is retained. Use at your own risk. Neither Murphy nor Datametrics assumes responsibility. Do not taunt Happy Fun Ball. #endif /* this module is a sample program to test Hardware Exception Reporting */ #include #include #include #include #include #include #include #include #include #ifdef VAXC #define sys$enqw SYS$ENQW #define sys$setimr SYS$SETIMR #define lib$establish LIB$ESTABLISH #endif #include /* prototypes for the SYS$xxxxx() functions */ #include /* prototypes for the LIB$xxxxx() functions */ /* use this to create timers manually */ #define KLUNKS_PER_SEC 10000000 $DESCRIPTOR(Name1, "TEST_HER_LOCK_ONE"); $DESCRIPTOR(Name2, "TEST_HER_LOCK_TWO"); $DESCRIPTOR(Name3, "TEST_HER_LOCK_THREE"); $DESCRIPTOR(Name4, "TEST_HER_LOCK_FOUR"); extern long HER_HandleException(void *, void *); extern long HER_ReportException(void *, void *); extern long HER_CheckForException(unsigned long, void *); static long MyHandler( void *sigargs, void *mechargs ) { if (HER_CheckForException(0, sigargs) != FALSE) { HER_ReportException(sigargs, mechargs); } return(SS$_CONTINUE); } int cadabra( int x, int y, int z, int a4, int a5, int a6 ) { char *foo; printf("i am about to ACCESS VIOLATE:\n"); fflush(stdout); foo = NULL; *foo = 'a'; printf("\nback from making trouble!\n"); fflush(stdout); return(0); } int abra( int x, int y, int z, int a4, int a5, int a6 ) { return(cadabra(0x1001, 0x2002, 0x3003, 0x0A11, 0x0DEAD, 0x0BEEF)); } int main( int argc, char *argv[] ) { int tmpfd; long deltaTime[2]; long lksb[6]; /* create and open some files using various modes * to test the SHOW OPEN FILES command */ tmpfd = creat("SYS$LOGIN:READONLY.TMP", 0666); close(tmpfd); tmpfd = creat("SYS$LOGIN:MODIFY.TMP", 0666); close(tmpfd); fopen("SYS$LOGIN:READONLY.TMP", "r"); fopen("SYS$LOGIN:WRITEONLY.TMP", "w"); fopen("SYS$LOGIN:MODIFY.TMP", "r+"); /* start some timers to test the SHOW TIMERS command */ deltaTime[1] = -1; deltaTime[0] = 130 * -1 * KLUNKS_PER_SEC; sys$setimr(0, deltaTime, NULL, 668); deltaTime[0] = 70 * -1 * KLUNKS_PER_SEC; sys$setimr(0, deltaTime, NULL, 666); deltaTime[0] = 10 * -1 * KLUNKS_PER_SEC; sys$setimr(0, deltaTime, NULL, 664); /* request some resources to test the SHOW LOCKS command */ sys$enqw(0, LCK$K_CRMODE, &lksb, LCK$M_SYSTEM, &Name1, 0, 0, 0, 0, 0, 0); sys$enqw(0, LCK$K_NLMODE, &lksb, 0, &Name2, 0, 0, 0, 0, 0, 0); sys$enqw(0, LCK$K_EXMODE, &lksb, 0, &Name3, 0, 0, 0, 0, 0, 0); sys$enqw(0, LCK$K_EXMODE, &lksb, 0, &Name4, 0, 0, 0, 0, 0, 0); lksb[2] = 0x11111111; lksb[3] = 0x22222222; lksb[4] = 0x33333333; lksb[5] = 0x44444444; sys$enqw(0, LCK$K_PWMODE, &lksb, LCK$M_VALBLK | LCK$M_CONVERT, NULL, 0, 0, 0, 0, 0, 0); lib$establish(HER_HandleException); abra(1, 2, 3, 4, 5, 6); exit(EXIT_SUCCESS); }