blob: 710e01adba316840e35ce74cff13cd211a6b325f [file] [log] [blame]
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +05301#!/usr/bin/env python
2# Pretty print 9p simpletrace log
3# Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
4#
5# Author: Harsh Prateek Bora
Eduardo Habkostf03868b2018-06-08 09:29:43 -03006from __future__ import print_function
Harsh Prateek Bora058a96e2011-12-21 12:37:23 +05307import os
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +05308import simpletrace
9
Harsh Prateek Bora058a96e2011-12-21 12:37:23 +053010symbol_9p = {
11 6 : 'TLERROR',
12 7 : 'RLERROR',
13 8 : 'TSTATFS',
14 9 : 'RSTATFS',
15 12 : 'TLOPEN',
16 13 : 'RLOPEN',
17 14 : 'TLCREATE',
18 15 : 'RLCREATE',
19 16 : 'TSYMLINK',
20 17 : 'RSYMLINK',
21 18 : 'TMKNOD',
22 19 : 'RMKNOD',
23 20 : 'TRENAME',
24 21 : 'RRENAME',
25 22 : 'TREADLINK',
26 23 : 'RREADLINK',
27 24 : 'TGETATTR',
28 25 : 'RGETATTR',
29 26 : 'TSETATTR',
30 27 : 'RSETATTR',
31 30 : 'TXATTRWALK',
32 31 : 'RXATTRWALK',
33 32 : 'TXATTRCREATE',
34 33 : 'RXATTRCREATE',
35 40 : 'TREADDIR',
36 41 : 'RREADDIR',
37 50 : 'TFSYNC',
38 51 : 'RFSYNC',
39 52 : 'TLOCK',
40 53 : 'RLOCK',
41 54 : 'TGETLOCK',
42 55 : 'RGETLOCK',
43 70 : 'TLINK',
44 71 : 'RLINK',
45 72 : 'TMKDIR',
46 73 : 'RMKDIR',
47 74 : 'TRENAMEAT',
48 75 : 'RRENAMEAT',
49 76 : 'TUNLINKAT',
50 77 : 'RUNLINKAT',
51 100 : 'TVERSION',
52 101 : 'RVERSION',
53 102 : 'TAUTH',
54 103 : 'RAUTH',
55 104 : 'TATTACH',
56 105 : 'RATTACH',
57 106 : 'TERROR',
58 107 : 'RERROR',
59 108 : 'TFLUSH',
60 109 : 'RFLUSH',
61 110 : 'TWALK',
62 111 : 'RWALK',
63 112 : 'TOPEN',
64 113 : 'ROPEN',
65 114 : 'TCREATE',
66 115 : 'RCREATE',
67 116 : 'TREAD',
68 117 : 'RREAD',
69 118 : 'TWRITE',
70 119 : 'RWRITE',
71 120 : 'TCLUNK',
72 121 : 'RCLUNK',
73 122 : 'TREMOVE',
74 123 : 'RREMOVE',
75 124 : 'TSTAT',
76 125 : 'RSTAT',
77 126 : 'TWSTAT',
78 127 : 'RWSTAT'
79}
80
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053081class VirtFSRequestTracker(simpletrace.Analyzer):
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +053082 def begin(self):
Eduardo Habkostf03868b2018-06-08 09:29:43 -030083 print("Pretty printing 9p simpletrace log ...")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053084
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +053085 def v9fs_rerror(self, tag, id, err):
Eduardo Habkostf03868b2018-06-08 09:29:43 -030086 print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053087
88 def v9fs_version(self, tag, id, msize, version):
Eduardo Habkostf03868b2018-06-08 09:29:43 -030089 print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053090
91 def v9fs_version_return(self, tag, id, msize, version):
Eduardo Habkostf03868b2018-06-08 09:29:43 -030092 print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053093
94 def v9fs_attach(self, tag, id, fid, afid, uname, aname):
Eduardo Habkostf03868b2018-06-08 09:29:43 -030095 print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053096
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +053097 def v9fs_attach_return(self, tag, id, type, version, path):
Eduardo Habkostf03868b2018-06-08 09:29:43 -030098 print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +053099
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530100 def v9fs_stat(self, tag, id, fid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300101 print("TSTAT (tag =", tag, ", fid =", fid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530102
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530103 def v9fs_stat_return(self, tag, id, mode, atime, mtime, length):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300104 print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530105
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530106 def v9fs_getattr(self, tag, id, fid, request_mask):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300107 print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530108
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530109 def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300110 print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530111
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530112 def v9fs_walk(self, tag, id, fid, newfid, nwnames):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300113 print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530114
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530115 def v9fs_walk_return(self, tag, id, nwnames, qids):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300116 print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530117
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530118 def v9fs_open(self, tag, id, fid, mode):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300119 print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530120
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530121 def v9fs_open_return(self, tag, id, type, version, path, iounit):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300122 print("ROPEN (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530123
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530124 def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300125 print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530126
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530127 def v9fs_lcreate_return(self, tag, id, type, version, path, iounit):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300128 print("RLCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530129
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530130 def v9fs_fsync(self, tag, id, fid, datasync):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300131 print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530132
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530133 def v9fs_clunk(self, tag, id, fid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300134 print("TCLUNK (tag =", tag, ", fid =", fid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530135
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530136 def v9fs_read(self, tag, id, fid, off, max_count):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300137 print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530138
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530139 def v9fs_read_return(self, tag, id, count, err):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300140 print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530141
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530142 def v9fs_readdir(self, tag, id, fid, offset, max_count):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300143 print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530144
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530145 def v9fs_readdir_return(self, tag, id, count, retval):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300146 print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530147
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530148 def v9fs_write(self, tag, id, fid, off, count, cnt):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300149 print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530150
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530151 def v9fs_write_return(self, tag, id, total, err):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300152 print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530153
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530154 def v9fs_create(self, tag, id, fid, name, perm, mode):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300155 print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530156
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530157 def v9fs_create_return(self, tag, id, type, version, path, iounit):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300158 print("RCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530159
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530160 def v9fs_symlink(self, tag, id, fid, name, symname, gid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300161 print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530162
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530163 def v9fs_symlink_return(self, tag, id, type, version, path):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300164 print("RSYMLINK (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530165
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530166 def v9fs_flush(self, tag, id, flush_tag):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300167 print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530168
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530169 def v9fs_link(self, tag, id, dfid, oldfid, name):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300170 print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530171
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530172 def v9fs_remove(self, tag, id, fid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300173 print("TREMOVE (tag =", tag, ", fid =", fid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530174
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530175 def v9fs_wstat(self, tag, id, fid, mode, atime, mtime):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300176 print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530177
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530178 def v9fs_mknod(self, tag, id, fid, mode, major, minor):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300179 print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530180
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530181 def v9fs_lock(self, tag, id, fid, type, start, length):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300182 print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530183
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530184 def v9fs_lock_return(self, tag, id, status):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300185 print("RLOCK (tag =", tag, ", status =", status, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530186
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530187 def v9fs_getlock(self, tag, id, fid, type, start, length):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300188 print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530189
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530190 def v9fs_getlock_return(self, tag, id, type, start, length, proc_id):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300191 print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530192
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530193 def v9fs_mkdir(self, tag, id, fid, name, mode, gid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300194 print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530195
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530196 def v9fs_mkdir_return(self, tag, id, type, version, path, err):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300197 print("RMKDIR (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530198
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530199 def v9fs_xattrwalk(self, tag, id, fid, newfid, name):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300200 print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530201
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530202 def v9fs_xattrwalk_return(self, tag, id, size):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300203 print("RXATTRWALK (tag =", tag, ", xattrsize =", size, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530204
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530205 def v9fs_xattrcreate(self, tag, id, fid, name, size, flags):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300206 print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530207
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530208 def v9fs_readlink(self, tag, id, fid):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300209 print("TREADLINK (tag =", tag, ", fid =", fid, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530210
Aneesh Kumar K.V7999f7e2011-10-24 15:09:49 +0530211 def v9fs_readlink_return(self, tag, id, target):
Eduardo Habkostf03868b2018-06-08 09:29:43 -0300212 print("RREADLINK (tag =", tag, ", target =", target, ")")
Harsh Prateek Bora49a88ce2011-09-30 16:06:15 +0530213
214simpletrace.run(VirtFSRequestTracker())