Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2000, International Business Machines Corporation and others. | |
3 | * All Rights Reserved. | |
4 | * | |
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 | |
8 | */ | |
9 | ||
10 | #include <afsconfig.h> | |
11 | #include <afs/param.h> | |
12 | ||
13 | ||
14 | #ifdef RXDEBUG | |
15 | ||
16 | #include <roken.h> | |
17 | ||
18 | #include <afs/afsutil.h> | |
19 | ||
20 | #include "rx.h" | |
21 | #include "rx_globals.h" | |
22 | #include "rx_trace.h" | |
23 | ||
24 | extern char *rxi_tracename; | |
25 | extern int rxi_logfd; | |
26 | ||
27 | struct rx_trace { | |
28 | afs_uint32 cid; | |
29 | unsigned short call; | |
30 | unsigned short qlen; | |
31 | afs_uint32 now; | |
32 | afs_uint32 waittime; | |
33 | afs_uint32 servicetime; | |
34 | afs_uint32 event; | |
35 | }; | |
36 | ||
37 | int | |
38 | main(int argc, char **argv) | |
39 | { | |
40 | struct rx_trace ip; | |
41 | int err = 0; | |
42 | ||
43 | setlinebuf(stdout); | |
44 | argv++; | |
45 | argc--; | |
46 | while (argc && **argv == '-') { | |
47 | if (strcmp(*argv, "-trace") == 0) { | |
48 | strcpy(rxi_tracename, *(++argv)); | |
49 | argc--; | |
50 | } else { | |
51 | err++; | |
52 | break; | |
53 | } | |
54 | argv++, argc--; | |
55 | } | |
56 | if (err || argc != 0) { | |
57 | printf("usage: dumptrace [-trace pathname]"); | |
58 | exit(1); | |
59 | } | |
60 | ||
61 | rxi_logfd = open(rxi_tracename, O_RDONLY); | |
62 | if (rxi_logfd < 0) { | |
63 | perror(""); | |
64 | exit(errno); | |
65 | } | |
66 | ||
67 | while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) { | |
68 | printf("%9u ", ip.now); | |
69 | switch (ip.event) { | |
70 | case RX_CALL_END: | |
71 | putchar('E'); | |
72 | break; | |
73 | case RX_CALL_START: | |
74 | putchar('S'); | |
75 | break; | |
76 | case RX_CALL_ARRIVAL: | |
77 | putchar('A'); | |
78 | break; | |
79 | case RX_TRACE_DROP: | |
80 | putchar('D'); | |
81 | break; | |
82 | default: | |
83 | putchar('U'); | |
84 | break; | |
85 | } | |
86 | printf(" %3u %7u %7u %x.%x\n", ip.qlen, ip.servicetime, | |
87 | ip.waittime, ip.cid, ip.call); | |
88 | } | |
89 | return 0; | |
90 | } | |
91 | ||
92 | #endif |