]>
Commit | Line | Data |
---|---|---|
d2cdbd54 | 1 | #!/usr/bin/env python3 |
49a88ce3 HPB |
2 | # Pretty print 9p simpletrace log |
3 | # Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid> | |
4 | # | |
5 | # Author: Harsh Prateek Bora | |
058a96ed | 6 | import os |
49a88ce3 HPB |
7 | import simpletrace |
8 | ||
058a96ed HPB |
9 | symbol_9p = { |
10 | 6 : 'TLERROR', | |
11 | 7 : 'RLERROR', | |
12 | 8 : 'TSTATFS', | |
13 | 9 : 'RSTATFS', | |
14 | 12 : 'TLOPEN', | |
15 | 13 : 'RLOPEN', | |
16 | 14 : 'TLCREATE', | |
17 | 15 : 'RLCREATE', | |
18 | 16 : 'TSYMLINK', | |
19 | 17 : 'RSYMLINK', | |
20 | 18 : 'TMKNOD', | |
21 | 19 : 'RMKNOD', | |
22 | 20 : 'TRENAME', | |
23 | 21 : 'RRENAME', | |
24 | 22 : 'TREADLINK', | |
25 | 23 : 'RREADLINK', | |
26 | 24 : 'TGETATTR', | |
27 | 25 : 'RGETATTR', | |
28 | 26 : 'TSETATTR', | |
29 | 27 : 'RSETATTR', | |
30 | 30 : 'TXATTRWALK', | |
31 | 31 : 'RXATTRWALK', | |
32 | 32 : 'TXATTRCREATE', | |
33 | 33 : 'RXATTRCREATE', | |
34 | 40 : 'TREADDIR', | |
35 | 41 : 'RREADDIR', | |
36 | 50 : 'TFSYNC', | |
37 | 51 : 'RFSYNC', | |
38 | 52 : 'TLOCK', | |
39 | 53 : 'RLOCK', | |
40 | 54 : 'TGETLOCK', | |
41 | 55 : 'RGETLOCK', | |
42 | 70 : 'TLINK', | |
43 | 71 : 'RLINK', | |
44 | 72 : 'TMKDIR', | |
45 | 73 : 'RMKDIR', | |
46 | 74 : 'TRENAMEAT', | |
47 | 75 : 'RRENAMEAT', | |
48 | 76 : 'TUNLINKAT', | |
49 | 77 : 'RUNLINKAT', | |
50 | 100 : 'TVERSION', | |
51 | 101 : 'RVERSION', | |
52 | 102 : 'TAUTH', | |
53 | 103 : 'RAUTH', | |
54 | 104 : 'TATTACH', | |
55 | 105 : 'RATTACH', | |
56 | 106 : 'TERROR', | |
57 | 107 : 'RERROR', | |
58 | 108 : 'TFLUSH', | |
59 | 109 : 'RFLUSH', | |
60 | 110 : 'TWALK', | |
61 | 111 : 'RWALK', | |
62 | 112 : 'TOPEN', | |
63 | 113 : 'ROPEN', | |
64 | 114 : 'TCREATE', | |
65 | 115 : 'RCREATE', | |
66 | 116 : 'TREAD', | |
67 | 117 : 'RREAD', | |
68 | 118 : 'TWRITE', | |
69 | 119 : 'RWRITE', | |
70 | 120 : 'TCLUNK', | |
71 | 121 : 'RCLUNK', | |
72 | 122 : 'TREMOVE', | |
73 | 123 : 'RREMOVE', | |
74 | 124 : 'TSTAT', | |
75 | 125 : 'RSTAT', | |
76 | 126 : 'TWSTAT', | |
77 | 127 : 'RWSTAT' | |
78 | } | |
79 | ||
49a88ce3 | 80 | class VirtFSRequestTracker(simpletrace.Analyzer): |
7999f7e1 | 81 | def begin(self): |
f03868bd | 82 | print("Pretty printing 9p simpletrace log ...") |
49a88ce3 | 83 | |
7999f7e1 | 84 | def v9fs_rerror(self, tag, id, err): |
f03868bd | 85 | print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")") |
49a88ce3 HPB |
86 | |
87 | def v9fs_version(self, tag, id, msize, version): | |
f03868bd | 88 | print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")") |
49a88ce3 HPB |
89 | |
90 | def v9fs_version_return(self, tag, id, msize, version): | |
f03868bd | 91 | print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")") |
49a88ce3 HPB |
92 | |
93 | def v9fs_attach(self, tag, id, fid, afid, uname, aname): | |
f03868bd | 94 | print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")") |
49a88ce3 | 95 | |
7999f7e1 | 96 | def v9fs_attach_return(self, tag, id, type, version, path): |
f03868bd | 97 | print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})") |
49a88ce3 | 98 | |
7999f7e1 | 99 | def v9fs_stat(self, tag, id, fid): |
f03868bd | 100 | print("TSTAT (tag =", tag, ", fid =", fid, ")") |
49a88ce3 | 101 | |
7999f7e1 | 102 | def v9fs_stat_return(self, tag, id, mode, atime, mtime, length): |
f03868bd | 103 | print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")") |
49a88ce3 | 104 | |
7999f7e1 | 105 | def v9fs_getattr(self, tag, id, fid, request_mask): |
f03868bd | 106 | print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")") |
49a88ce3 | 107 | |
7999f7e1 | 108 | def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid): |
f03868bd | 109 | print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")") |
49a88ce3 | 110 | |
7999f7e1 | 111 | def v9fs_walk(self, tag, id, fid, newfid, nwnames): |
f03868bd | 112 | print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")") |
49a88ce3 | 113 | |
7999f7e1 | 114 | def v9fs_walk_return(self, tag, id, nwnames, qids): |
f03868bd | 115 | print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")") |
49a88ce3 | 116 | |
7999f7e1 | 117 | def v9fs_open(self, tag, id, fid, mode): |
f03868bd | 118 | print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")") |
49a88ce3 | 119 | |
7999f7e1 | 120 | def v9fs_open_return(self, tag, id, type, version, path, iounit): |
f03868bd | 121 | print("ROPEN (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")") |
49a88ce3 | 122 | |
7999f7e1 | 123 | def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid): |
f03868bd | 124 | print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")") |
49a88ce3 | 125 | |
7999f7e1 | 126 | def v9fs_lcreate_return(self, tag, id, type, version, path, iounit): |
f03868bd | 127 | print("RLCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")") |
49a88ce3 | 128 | |
7999f7e1 | 129 | def v9fs_fsync(self, tag, id, fid, datasync): |
f03868bd | 130 | print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")") |
49a88ce3 | 131 | |
7999f7e1 | 132 | def v9fs_clunk(self, tag, id, fid): |
f03868bd | 133 | print("TCLUNK (tag =", tag, ", fid =", fid, ")") |
49a88ce3 | 134 | |
7999f7e1 | 135 | def v9fs_read(self, tag, id, fid, off, max_count): |
f03868bd | 136 | print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")") |
49a88ce3 | 137 | |
7999f7e1 | 138 | def v9fs_read_return(self, tag, id, count, err): |
f03868bd | 139 | print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")") |
49a88ce3 | 140 | |
7999f7e1 | 141 | def v9fs_readdir(self, tag, id, fid, offset, max_count): |
f03868bd | 142 | print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")") |
49a88ce3 | 143 | |
7999f7e1 | 144 | def v9fs_readdir_return(self, tag, id, count, retval): |
f03868bd | 145 | print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")") |
49a88ce3 | 146 | |
7999f7e1 | 147 | def v9fs_write(self, tag, id, fid, off, count, cnt): |
f03868bd | 148 | print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")") |
49a88ce3 | 149 | |
7999f7e1 | 150 | def v9fs_write_return(self, tag, id, total, err): |
f03868bd | 151 | print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")") |
49a88ce3 | 152 | |
7999f7e1 | 153 | def v9fs_create(self, tag, id, fid, name, perm, mode): |
f03868bd | 154 | print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")") |
49a88ce3 | 155 | |
7999f7e1 | 156 | def v9fs_create_return(self, tag, id, type, version, path, iounit): |
f03868bd | 157 | print("RCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")") |
49a88ce3 | 158 | |
7999f7e1 | 159 | def v9fs_symlink(self, tag, id, fid, name, symname, gid): |
f03868bd | 160 | print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")") |
49a88ce3 | 161 | |
7999f7e1 | 162 | def v9fs_symlink_return(self, tag, id, type, version, path): |
f03868bd | 163 | print("RSYMLINK (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})") |
49a88ce3 | 164 | |
7999f7e1 | 165 | def v9fs_flush(self, tag, id, flush_tag): |
f03868bd | 166 | print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")") |
49a88ce3 | 167 | |
7999f7e1 | 168 | def v9fs_link(self, tag, id, dfid, oldfid, name): |
f03868bd | 169 | print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")") |
49a88ce3 | 170 | |
7999f7e1 | 171 | def v9fs_remove(self, tag, id, fid): |
f03868bd | 172 | print("TREMOVE (tag =", tag, ", fid =", fid, ")") |
49a88ce3 | 173 | |
7999f7e1 | 174 | def v9fs_wstat(self, tag, id, fid, mode, atime, mtime): |
f03868bd | 175 | print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")") |
49a88ce3 | 176 | |
7999f7e1 | 177 | def v9fs_mknod(self, tag, id, fid, mode, major, minor): |
f03868bd | 178 | print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")") |
49a88ce3 | 179 | |
7999f7e1 | 180 | def v9fs_lock(self, tag, id, fid, type, start, length): |
f03868bd | 181 | print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")") |
49a88ce3 | 182 | |
7999f7e1 | 183 | def v9fs_lock_return(self, tag, id, status): |
f03868bd | 184 | print("RLOCK (tag =", tag, ", status =", status, ")") |
49a88ce3 | 185 | |
7999f7e1 | 186 | def v9fs_getlock(self, tag, id, fid, type, start, length): |
f03868bd | 187 | print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")") |
49a88ce3 | 188 | |
7999f7e1 | 189 | def v9fs_getlock_return(self, tag, id, type, start, length, proc_id): |
f03868bd | 190 | print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id, ")") |
49a88ce3 | 191 | |
7999f7e1 | 192 | def v9fs_mkdir(self, tag, id, fid, name, mode, gid): |
f03868bd | 193 | print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")") |
49a88ce3 | 194 | |
7999f7e1 | 195 | def v9fs_mkdir_return(self, tag, id, type, version, path, err): |
f03868bd | 196 | print("RMKDIR (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")") |
49a88ce3 | 197 | |
7999f7e1 | 198 | def v9fs_xattrwalk(self, tag, id, fid, newfid, name): |
f03868bd | 199 | print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")") |
49a88ce3 | 200 | |
7999f7e1 | 201 | def v9fs_xattrwalk_return(self, tag, id, size): |
f03868bd | 202 | print("RXATTRWALK (tag =", tag, ", xattrsize =", size, ")") |
49a88ce3 | 203 | |
7999f7e1 | 204 | def v9fs_xattrcreate(self, tag, id, fid, name, size, flags): |
f03868bd | 205 | print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")") |
49a88ce3 | 206 | |
7999f7e1 | 207 | def v9fs_readlink(self, tag, id, fid): |
f03868bd | 208 | print("TREADLINK (tag =", tag, ", fid =", fid, ")") |
49a88ce3 | 209 | |
7999f7e1 | 210 | def v9fs_readlink_return(self, tag, id, target): |
f03868bd | 211 | print("RREADLINK (tag =", tag, ", target =", target, ")") |
49a88ce3 HPB |
212 | |
213 | simpletrace.run(VirtFSRequestTracker()) |