2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 char rxi_tracename[80] = "\0Tracing not compiled in";
18 main(int argc, char **argv)
33 #include "rx_globals.h"
37 char rxi_tracename[80] = "/tmp/rxcalltrace";
39 char rxi_tracename[80] =
40 "\0Change This pathname (and preceding NUL) to initiate tracing";
43 char rxi_tracebuf[4096];
44 afs_uint32 rxi_tracepos = 0;
52 afs_uint32 servicetime;
60 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
65 rxi_calltrace(unsigned int event, struct rx_call *call)
68 struct rx_trace rxtinfo;
70 if (!rxi_tracename[0])
74 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
76 rxi_tracename[0] = '\0';
80 rxtinfo.event = event;
81 rxtinfo.now = now.sec * 1000 + now.usec / 1000;
82 rxtinfo.cid = call->conn->cid;
83 rxtinfo.call = *(call->callNumber);
84 rxtinfo.qlen = rx_nWaiting;
85 rxtinfo.servicetime = 0;
90 clock_Sub(&now, &(call->traceStart));
91 rxtinfo.servicetime = now.sec * 10000 + now.usec / 100;
92 if (call->traceWait.sec) {
93 now = call->traceStart;
94 clock_Sub(&now, &(call->traceWait));
95 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
98 call->traceWait.sec = call->traceWait.usec = call->traceStart.sec =
99 call->traceStart.usec = 0;
103 call->traceStart = now;
104 if (call->traceWait.sec) {
105 clock_Sub(&now, &(call->traceWait));
106 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
108 rxtinfo.waittime = 0;
112 if (call->traceWait.sec) {
113 clock_Sub(&now, &(call->traceWait));
114 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
116 rxtinfo.waittime = 0;
119 case RX_CALL_ARRIVAL:
120 call->traceWait = now;
125 memcpy(rxi_tracebuf + rxi_tracepos, &rxtinfo, sizeof(struct rx_trace));
126 rxi_tracepos += sizeof(struct rx_trace);
127 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
134 #include <afs/afsutil.h>
138 main(int argc, char **argv)
146 while (argc && **argv == '-') {
147 if (strcmp(*argv, "-trace") == 0) {
148 strcpy(rxi_tracename, *(++argv));
156 if (err || argc != 0) {
157 printf("usage: dumptrace [-trace pathname]");
161 rxi_logfd = open(rxi_tracename, O_RDONLY);
167 while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
168 printf("%9u ", ip.now);
176 case RX_CALL_ARRIVAL:
186 printf(" %3u %7u %7u %x.%x\n", ip.qlen, ip.servicetime,
187 ip.waittime, ip.cid, ip.call);
192 #endif /* DUMPTRACE */