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>
32 #include "rx_globals.h"
36 char rxi_tracename[80] = "/tmp/rxcalltrace";
38 char rxi_tracename[80] =
39 "\0Change This pathname (and preceding NUL) to initiate tracing";
42 char rxi_tracebuf[4096];
43 afs_uint32 rxi_tracepos = 0;
51 afs_uint32 servicetime;
59 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
64 rxi_calltrace(event, call)
69 struct rx_trace rxtinfo;
71 if (!rxi_tracename[0])
75 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
77 rxi_tracename[0] = '\0';
81 rxtinfo.event = event;
82 rxtinfo.now = now.sec * 1000 + now.usec / 1000;
83 rxtinfo.cid = call->conn->cid;
84 rxtinfo.call = *(call->callNumber);
85 rxtinfo.qlen = rx_nWaiting;
86 rxtinfo.servicetime = 0;
91 clock_Sub(&now, &(call->traceStart));
92 rxtinfo.servicetime = now.sec * 10000 + now.usec / 100;
93 if (call->traceWait.sec) {
94 now = call->traceStart;
95 clock_Sub(&now, &(call->traceWait));
96 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
99 call->traceWait.sec = call->traceWait.usec = call->traceStart.sec =
100 call->traceStart.usec = 0;
104 call->traceStart = now;
105 if (call->traceWait.sec) {
106 clock_Sub(&now, &(call->traceWait));
107 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
109 rxtinfo.waittime = 0;
113 if (call->traceWait.sec) {
114 clock_Sub(&now, &(call->traceWait));
115 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
117 rxtinfo.waittime = 0;
120 case RX_CALL_ARRIVAL:
121 call->traceWait = now;
126 memcpy(rxi_tracebuf + rxi_tracepos, &rxtinfo, sizeof(struct rx_trace));
127 rxi_tracepos += sizeof(struct rx_trace);
128 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
135 #include <afs/afsutil.h>
148 while (argc && **argv == '-') {
149 if (strcmp(*argv, "-trace") == 0) {
150 strcpy(rxi_tracename, *(++argv));
158 if (err || argc != 0) {
159 printf("usage: dumptrace [-trace pathname]");
163 rxi_logfd = open(rxi_tracename, O_RDONLY);
169 while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
170 printf("%9u ", ip.now);
178 case RX_CALL_ARRIVAL:
188 printf(" %3u %7u %7u %x.%x\n", ip.qlen, ip.servicetime,
189 ip.waittime, ip.cid, ip.call);
193 #endif /* DUMPTRACE */