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>
25 #include "rx_internal.h"
27 #include "rx_globals.h"
31 char rxi_tracename[80] = "/tmp/rxcalltrace";
33 char rxi_tracename[80] =
34 "\0Change This pathname (and preceding NUL) to initiate tracing";
37 char rxi_tracebuf[4096];
38 afs_uint32 rxi_tracepos = 0;
46 afs_uint32 servicetime;
54 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
59 rxi_calltrace(unsigned int event, struct rx_call *call)
62 struct rx_trace rxtinfo;
64 if (!rxi_tracename[0])
68 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
70 rxi_tracename[0] = '\0';
74 rxtinfo.event = event;
75 rxtinfo.now = now.sec * 1000 + now.usec / 1000;
76 rxtinfo.cid = call->conn->cid;
77 rxtinfo.call = *(call->callNumber);
78 rxtinfo.qlen = rx_nWaiting;
79 rxtinfo.servicetime = 0;
84 clock_Sub(&now, &(call->traceStart));
85 rxtinfo.servicetime = now.sec * 10000 + now.usec / 100;
86 if (call->traceWait.sec) {
87 now = call->traceStart;
88 clock_Sub(&now, &(call->traceWait));
89 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
92 call->traceWait.sec = call->traceWait.usec = call->traceStart.sec =
93 call->traceStart.usec = 0;
97 call->traceStart = now;
98 if (call->traceWait.sec) {
99 clock_Sub(&now, &(call->traceWait));
100 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
102 rxtinfo.waittime = 0;
106 if (call->traceWait.sec) {
107 clock_Sub(&now, &(call->traceWait));
108 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
110 rxtinfo.waittime = 0;
113 case RX_CALL_ARRIVAL:
114 call->traceWait = now;
119 memcpy(rxi_tracebuf + rxi_tracepos, &rxtinfo, sizeof(struct rx_trace));
120 rxi_tracepos += sizeof(struct rx_trace);
121 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
128 #include <afs/afsutil.h>
132 main(int argc, char **argv)
140 while (argc && **argv == '-') {
141 if (strcmp(*argv, "-trace") == 0) {
142 strcpy(rxi_tracename, *(++argv));
150 if (err || argc != 0) {
151 printf("usage: dumptrace [-trace pathname]");
155 rxi_logfd = open(rxi_tracename, O_RDONLY);
161 while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
162 printf("%9u ", ip.now);
170 case RX_CALL_ARRIVAL:
180 printf(" %3u %7u %7u %x.%x\n", ip.qlen, ip.servicetime,
181 ip.waittime, ip.cid, ip.call);
186 #endif /* DUMPTRACE */