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
12 #include <afs/param.h>
20 #include "rx_globals.h"
24 char rxi_tracename[80]="/tmp/rxcalltrace";
26 char rxi_tracename[80]="\0Change This pathname (and preceding NUL) to initiate tracing";
29 char rxi_tracebuf[4096];
30 afs_uint32 rxi_tracepos = 0;
38 afs_uint32 servicetime;
45 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
49 void rxi_calltrace(event, call)
54 struct rx_trace rxtinfo;
56 if (!rxi_tracename[0])
60 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
62 rxi_tracename[0] = '\0';
66 rxtinfo.event = event;
67 rxtinfo.now = now.sec*1000 + now.usec/1000;
68 rxtinfo.cid = call->conn->cid;
69 rxtinfo.call = *(call->callNumber);
70 rxtinfo.qlen = rx_nWaiting;
71 rxtinfo.servicetime = 0;
76 clock_Sub(&now, &(call->traceStart));
77 rxtinfo.servicetime = now.sec*10000 + now.usec/100;
78 if (call->traceWait.sec) {
79 now = call->traceStart;
80 clock_Sub(&now, &(call->traceWait));
81 rxtinfo.waittime = now.sec*10000 + now.usec/100;
83 else rxtinfo.waittime = 0;
84 call->traceWait.sec = call->traceWait.usec =
85 call->traceStart.sec = call->traceStart.usec = 0;
89 call->traceStart = now;
90 if (call->traceWait.sec) {
91 clock_Sub(&now, &(call->traceWait));
92 rxtinfo.waittime = now.sec*10000 + now.usec/100;
94 else rxtinfo.waittime = 0;
98 if (call->traceWait.sec) {
99 clock_Sub(&now, &(call->traceWait));
100 rxtinfo.waittime = now.sec*10000 + now.usec/100;
102 else rxtinfo.waittime = 0;
105 case RX_CALL_ARRIVAL:
106 call->traceWait = now;
111 bcopy(&rxtinfo, rxi_tracebuf+rxi_tracepos, sizeof(struct rx_trace));
112 rxi_tracepos += sizeof(struct rx_trace);
113 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
120 #include <afs/afsutil.h>
131 while (argc && **argv == '-') {
132 if (strcmp(*argv, "-trace") == 0) {
133 strcpy(rxi_tracename, *(++argv));
139 if (err || argc != 0) {
140 printf("usage: dumptrace [-trace pathname]");
144 rxi_logfd = open(rxi_tracename, O_RDONLY);
150 while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
151 printf("%9u ", ip.now);
153 case RX_CALL_END: putchar('E'); break;
154 case RX_CALL_START: putchar('S'); break;
155 case RX_CALL_ARRIVAL: putchar('A'); break;
156 case RX_TRACE_DROP: putchar('D'); break;
157 default: putchar('U'); break;
159 printf(" %3u %7u %7u %x.%x\n",
160 ip.qlen, ip.servicetime, ip.waittime, ip.cid, ip.call);
164 #endif /* DUMPTRACE */