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>
26 #include "rx_globals.h"
30 char rxi_tracename[80] = "/tmp/rxcalltrace";
32 char rxi_tracename[80] =
33 "\0Change This pathname (and preceding NUL) to initiate tracing";
36 char rxi_tracebuf[4096];
37 afs_uint32 rxi_tracepos = 0;
45 afs_uint32 servicetime;
53 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
58 rxi_calltrace(event, call)
63 struct rx_trace rxtinfo;
65 if (!rxi_tracename[0])
69 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
71 rxi_tracename[0] = '\0';
75 rxtinfo.event = event;
76 rxtinfo.now = now.sec * 1000 + now.usec / 1000;
77 rxtinfo.cid = call->conn->cid;
78 rxtinfo.call = *(call->callNumber);
79 rxtinfo.qlen = rx_nWaiting;
80 rxtinfo.servicetime = 0;
85 clock_Sub(&now, &(call->traceStart));
86 rxtinfo.servicetime = now.sec * 10000 + now.usec / 100;
87 if (call->traceWait.sec) {
88 now = call->traceStart;
89 clock_Sub(&now, &(call->traceWait));
90 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
93 call->traceWait.sec = call->traceWait.usec = call->traceStart.sec =
94 call->traceStart.usec = 0;
98 call->traceStart = now;
99 if (call->traceWait.sec) {
100 clock_Sub(&now, &(call->traceWait));
101 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
103 rxtinfo.waittime = 0;
107 if (call->traceWait.sec) {
108 clock_Sub(&now, &(call->traceWait));
109 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
111 rxtinfo.waittime = 0;
114 case RX_CALL_ARRIVAL:
115 call->traceWait = now;
120 memcpy(rxi_tracebuf + rxi_tracepos, &rxtinfo, sizeof(struct rx_trace));
121 rxi_tracepos += sizeof(struct rx_trace);
122 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
129 #include <afs/afsutil.h>
142 while (argc && **argv == '-') {
143 if (strcmp(*argv, "-trace") == 0) {
144 strcpy(rxi_tracename, *(++argv));
152 if (err || argc != 0) {
153 printf("usage: dumptrace [-trace pathname]");
157 rxi_logfd = open(rxi_tracename, O_RDONLY);
163 while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
164 printf("%9u ", ip.now);
172 case RX_CALL_ARRIVAL:
182 printf(" %3u %7u %7u %x.%x\n", ip.qlen, ip.servicetime,
183 ip.waittime, ip.cid, ip.call);
187 #endif /* DUMPTRACE */