source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/lxtrace.sial @ 214

Last change on this file since 214 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 4.0 KB
RevLine 
[16]1/* @(#)01       1.4  src/avs/fs/mmfs/ts/kernext/gpl-linux/lxtrace.sial, mmfs, avs_rgpfs24, rgpfs240610b 2/27/03 12:39:57 */
2
3/* lcrash sial script that determines where the lxtrace
4 * data is in the dump and outputs a helpful example of
5 * how to retrieve it.   The user would then use
6 * the program "dumpconv" to turn the "dump -B" output
7 * into a file that "lxtrace format" could read.
8 */
9string lxtrace_help()  { return "this is the << help >> for main"; }
10string lxtrace_opt()   { return ""; }
11string lxtrace_usage() { return ""; }
12
13/* Unfortunately I can't include these from lxtrace.h because
14 * it includes other things that sial doesn't like.
15 */
16#define LXTRACE_MAX_HW 8
17
18/* Possible states of the trace device */
19typedef enum trcdev_state_t
20{
21  trc_initialized,  /* header constructed */
22  trc_opened,       /* device opened      */
23  trc_active,       /* ready for tracing  */
24  trc_stopped       /* tracing disabled   */
25} trcdev_state_t;
26
27typedef struct trcdev_buffer_t
28{
29  char * beginP; /* first byte of the buffer */
30  char * endP;   /* last byte of the buffer */
31  char * nextP;  /* offset of next record to be read/written */
32  char * dirtyP; /* offset of next byte to be read */
33} trcdev_buffer_t;
34
35typedef struct trcdev_header_t
36{
37  int major;                /* major number of the trace device */
38  int minor;                /* minor number of the trace device */
39  int bufSize;              /* number of bytes in the trace buffers */
40  int nHooks;               /* number of trace hookids being traced */
41  int hookP[LXTRACE_MAX_HW];/* the list of hooks being traced */
42  int nOpens;               /* number of times the device is open */
43  int nWaits;               /* number of times we had to wait for the daemon */
44  int nBuffers;             /* number of buffers filled with trace data */
45  int nLost;                /* number of traces lost due to full buffer */
46  trcdev_state_t state;     /* status of the trace device */
47  trcdev_buffer_t writeBuf; /* The trace buffer being written */
48  trcdev_buffer_t readBuf;  /* The buffer being read by the daemon */
49} trcdev_header_t;
50
51#ifdef DEBUG
52#define DPRINTF(x) printf x
53#else
54#define DPRINTF(x)
55#endif
56
57int
58lxtrace()
59{
60  trcdev_header_t *headerP;
61  char *beginP;
62  char *endP;
63  int rbytes, wbytes;
64
65  printf("\n");
66  if (exists("lxthe"))
67  {
68    headerP = (trcdev_header_t *)lxthe;
69    DPRINTF(("lxthe           : 0x%08x\n", headerP));
70    DPRINTF(("writeBuf beginP : 0x%08x\n", headerP->writeBuf.beginP));
71    DPRINTF(("writeBuf nextP  : 0x%08x\n", headerP->writeBuf.nextP));
72    DPRINTF(("readBuf beginP  : 0x%08x\n", headerP->readBuf.beginP));
73    DPRINTF(("readBuf nextP   : 0x%08x\n", headerP->readBuf.nextP));
74
75    if (headerP->readBuf.nextP <= headerP->readBuf.endP)
76      endP = headerP->readBuf.nextP;
77    else
78      endP = headerP->readBuf.endP;
79
80    rbytes = endP - (char *)headerP->readBuf.beginP;
81
82    if (headerP->writeBuf.nextP <= headerP->writeBuf.endP)
83      endP = headerP->writeBuf.nextP;
84    else
85      endP = headerP->writeBuf.endP;
86
87    wbytes = endP - (char *)headerP->writeBuf.beginP;
88   
89    if (rbytes || wbytes)
90    {
91      printf("There are %d bytes of trace records in this memory image\n",
92             rbytes + wbytes);
93      printf("Execute the following commands and specify an <outfile>.\n");
94      printf("The <outfile> can then be used as input to lxtrace format.\n");
95      printf("Note that the \"dump\" command appends data to <outfile>\n");
96      printf("so start with a empty file.\n\n");
97
98      if (rbytes)
99        printf("dump -B %x %d -w <outfile>\n",
100               headerP->readBuf.beginP, rbytes);
101      if (wbytes)
102        printf("dump -B %x %d -w <outfile>\n",
103               headerP->writeBuf.beginP, wbytes);
104    }
105    else
106    {
107      printf("A trace header exists in this memory image but no trace\n");
108      printf("records are present.\n");
109    }
110  }
111  else
112  {
113    printf("The \"lxthe\" symbol cannot be found in this memory image.\n");
114    printf("Did you give lcrash a /var/mmfs/tmp/complete.map?\n");
115  }
116  return 0;
117}
Note: See TracBrowser for help on using the repository browser.