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>
17 char rxi_tracename[80] = "\0Tracing not compiled in";
20 main(int argc, char **argv)
34 #include "rx_internal.h"
36 #include "rx_globals.h"
40 char rxi_tracename[80] = "/tmp/rxcalltrace";
42 char rxi_tracename[80] =
43 "\0Change This pathname (and preceding NUL) to initiate tracing";
46 char rxi_tracebuf[4096];
47 afs_uint32 rxi_tracepos = 0;
55 afs_uint32 servicetime;
63 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
68 rxi_calltrace(unsigned int event, struct rx_call *call)
71 struct rx_trace rxtinfo;
73 if (!rxi_tracename[0])
77 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
79 rxi_tracename[0] = '\0';
83 rxtinfo.event = event;
84 rxtinfo.now = now.sec * 1000 + now.usec / 1000;
85 rxtinfo.cid = call->conn->cid;
86 rxtinfo.call = *(call->callNumber);
87 rxtinfo.qlen = rx_nWaiting;
88 rxtinfo.servicetime = 0;
93 clock_Sub(&now, &(call->traceStart));
94 rxtinfo.servicetime = now.sec * 10000 + now.usec / 100;
95 if (call->traceWait.sec) {
96 now = call->traceStart;
97 clock_Sub(&now, &(call->traceWait));
98 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
100 rxtinfo.waittime = 0;
101 call->traceWait.sec = call->traceWait.usec = call->traceStart.sec =
102 call->traceStart.usec = 0;
106 call->traceStart = now;
107 if (call->traceWait.sec) {
108 clock_Sub(&now, &(call->traceWait));
109 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
111 rxtinfo.waittime = 0;
115 if (call->traceWait.sec) {
116 clock_Sub(&now, &(call->traceWait));
117 rxtinfo.waittime = now.sec * 10000 + now.usec / 100;
119 rxtinfo.waittime = 0;
122 case RX_CALL_ARRIVAL:
123 call->traceWait = now;
128 memcpy(rxi_tracebuf + rxi_tracepos, &rxtinfo, sizeof(struct rx_trace));
129 rxi_tracepos += sizeof(struct rx_trace);
130 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
137 #include <afs/afsutil.h>
141 main(int argc, char **argv)
149 while (argc && **argv == '-') {
150 if (strcmp(*argv, "-trace") == 0) {
151 strcpy(rxi_tracename, *(++argv));
159 if (err || argc != 0) {
160 printf("usage: dumptrace [-trace pathname]");
164 rxi_logfd = open(rxi_tracename, O_RDONLY);
170 while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
171 printf("%9u ", ip.now);
179 case RX_CALL_ARRIVAL:
189 printf(" %3u %7u %7u %x.%x\n", ip.qlen, ip.servicetime,
190 ip.waittime, ip.cid, ip.call);
195 #endif /* DUMPTRACE */