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 <afs/param.h>
11 #include <afsconfig.h>
31 #include "rx_globals.h"
35 char rxi_tracename[80]="/tmp/rxcalltrace";
37 char rxi_tracename[80]="\0Change This pathname (and preceding NUL) to initiate tracing";
40 char rxi_tracebuf[4096];
41 afs_uint32 rxi_tracepos = 0;
49 afs_uint32 servicetime;
56 write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
60 void rxi_calltrace(event, call)
65 struct rx_trace rxtinfo;
67 if (!rxi_tracename[0])
71 rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
73 rxi_tracename[0] = '\0';
77 rxtinfo.event = event;
78 rxtinfo.now = now.sec*1000 + now.usec/1000;
79 rxtinfo.cid = call->conn->cid;
80 rxtinfo.call = *(call->callNumber);
81 rxtinfo.qlen = rx_nWaiting;
82 rxtinfo.servicetime = 0;
87 clock_Sub(&now, &(call->traceStart));
88 rxtinfo.servicetime = now.sec*10000 + now.usec/100;
89 if (call->traceWait.sec) {
90 now = call->traceStart;
91 clock_Sub(&now, &(call->traceWait));
92 rxtinfo.waittime = now.sec*10000 + now.usec/100;
94 else rxtinfo.waittime = 0;
95 call->traceWait.sec = call->traceWait.usec =
96 call->traceStart.sec = call->traceStart.usec = 0;
100 call->traceStart = now;
101 if (call->traceWait.sec) {
102 clock_Sub(&now, &(call->traceWait));
103 rxtinfo.waittime = now.sec*10000 + now.usec/100;
105 else rxtinfo.waittime = 0;
109 if (call->traceWait.sec) {
110 clock_Sub(&now, &(call->traceWait));
111 rxtinfo.waittime = now.sec*10000 + now.usec/100;
113 else rxtinfo.waittime = 0;
116 case RX_CALL_ARRIVAL:
117 call->traceWait = now;
122 bcopy(&rxtinfo, rxi_tracebuf+rxi_tracepos, sizeof(struct rx_trace));
123 rxi_tracepos += sizeof(struct rx_trace);
124 if (rxi_tracepos >= (4096 - sizeof(struct rx_trace)))
131 #include <afs/afsutil.h>
142 while (argc && **argv == '-') {
143 if (strcmp(*argv, "-trace") == 0) {
144 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);
164 case RX_CALL_END: putchar('E'); break;
165 case RX_CALL_START: putchar('S'); break;
166 case RX_CALL_ARRIVAL: putchar('A'); break;
167 case RX_TRACE_DROP: putchar('D'); break;
168 default: putchar('U'); break;
170 printf(" %3u %7u %7u %x.%x\n",
171 ip.qlen, ip.servicetime, ip.waittime, ip.cid, ip.call);
175 #endif /* DUMPTRACE */