/* @(#)01 1.4 src/avs/fs/mmfs/ts/kernext/gpl-linux/lxtrace.sial, mmfs, avs_rgpfs24, rgpfs240610b 2/27/03 12:39:57 */ /* lcrash sial script that determines where the lxtrace * data is in the dump and outputs a helpful example of * how to retrieve it. The user would then use * the program "dumpconv" to turn the "dump -B" output * into a file that "lxtrace format" could read. */ string lxtrace_help() { return "this is the << help >> for main"; } string lxtrace_opt() { return ""; } string lxtrace_usage() { return ""; } /* Unfortunately I can't include these from lxtrace.h because * it includes other things that sial doesn't like. */ #define LXTRACE_MAX_HW 8 /* Possible states of the trace device */ typedef enum trcdev_state_t { trc_initialized, /* header constructed */ trc_opened, /* device opened */ trc_active, /* ready for tracing */ trc_stopped /* tracing disabled */ } trcdev_state_t; typedef struct trcdev_buffer_t { char * beginP; /* first byte of the buffer */ char * endP; /* last byte of the buffer */ char * nextP; /* offset of next record to be read/written */ char * dirtyP; /* offset of next byte to be read */ } trcdev_buffer_t; typedef struct trcdev_header_t { int major; /* major number of the trace device */ int minor; /* minor number of the trace device */ int bufSize; /* number of bytes in the trace buffers */ int nHooks; /* number of trace hookids being traced */ int hookP[LXTRACE_MAX_HW];/* the list of hooks being traced */ int nOpens; /* number of times the device is open */ int nWaits; /* number of times we had to wait for the daemon */ int nBuffers; /* number of buffers filled with trace data */ int nLost; /* number of traces lost due to full buffer */ trcdev_state_t state; /* status of the trace device */ trcdev_buffer_t writeBuf; /* The trace buffer being written */ trcdev_buffer_t readBuf; /* The buffer being read by the daemon */ } trcdev_header_t; #ifdef DEBUG #define DPRINTF(x) printf x #else #define DPRINTF(x) #endif int lxtrace() { trcdev_header_t *headerP; char *beginP; char *endP; int rbytes, wbytes; printf("\n"); if (exists("lxthe")) { headerP = (trcdev_header_t *)lxthe; DPRINTF(("lxthe : 0x%08x\n", headerP)); DPRINTF(("writeBuf beginP : 0x%08x\n", headerP->writeBuf.beginP)); DPRINTF(("writeBuf nextP : 0x%08x\n", headerP->writeBuf.nextP)); DPRINTF(("readBuf beginP : 0x%08x\n", headerP->readBuf.beginP)); DPRINTF(("readBuf nextP : 0x%08x\n", headerP->readBuf.nextP)); if (headerP->readBuf.nextP <= headerP->readBuf.endP) endP = headerP->readBuf.nextP; else endP = headerP->readBuf.endP; rbytes = endP - (char *)headerP->readBuf.beginP; if (headerP->writeBuf.nextP <= headerP->writeBuf.endP) endP = headerP->writeBuf.nextP; else endP = headerP->writeBuf.endP; wbytes = endP - (char *)headerP->writeBuf.beginP; if (rbytes || wbytes) { printf("There are %d bytes of trace records in this memory image\n", rbytes + wbytes); printf("Execute the following commands and specify an .\n"); printf("The can then be used as input to lxtrace format.\n"); printf("Note that the \"dump\" command appends data to \n"); printf("so start with a empty file.\n\n"); if (rbytes) printf("dump -B %x %d -w \n", headerP->readBuf.beginP, rbytes); if (wbytes) printf("dump -B %x %d -w \n", headerP->writeBuf.beginP, wbytes); } else { printf("A trace header exists in this memory image but no trace\n"); printf("records are present.\n"); } } else { printf("The \"lxthe\" symbol cannot be found in this memory image.\n"); printf("Did you give lcrash a /var/mmfs/tmp/complete.map?\n"); } return 0; }