analyse-9p-simpletrace.py 8.93 KB
Newer Older
1 2 3 4 5
#!/usr/bin/env python
# Pretty print 9p simpletrace log
# Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
#
# Author: Harsh Prateek Bora
6
from __future__ import print_function
7
import os
8 9
import simpletrace

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
symbol_9p = {
    6   : 'TLERROR',
    7   : 'RLERROR',
    8   : 'TSTATFS',
    9   : 'RSTATFS',
    12  : 'TLOPEN',
    13  : 'RLOPEN',
    14  : 'TLCREATE',
    15  : 'RLCREATE',
    16  : 'TSYMLINK',
    17  : 'RSYMLINK',
    18  : 'TMKNOD',
    19  : 'RMKNOD',
    20  : 'TRENAME',
    21  : 'RRENAME',
    22  : 'TREADLINK',
    23  : 'RREADLINK',
    24  : 'TGETATTR',
    25  : 'RGETATTR',
    26  : 'TSETATTR',
    27  : 'RSETATTR',
    30  : 'TXATTRWALK',
    31  : 'RXATTRWALK',
    32  : 'TXATTRCREATE',
    33  : 'RXATTRCREATE',
    40  : 'TREADDIR',
    41  : 'RREADDIR',
    50  : 'TFSYNC',
    51  : 'RFSYNC',
    52  : 'TLOCK',
    53  : 'RLOCK',
    54  : 'TGETLOCK',
    55  : 'RGETLOCK',
    70  : 'TLINK',
    71  : 'RLINK',
    72  : 'TMKDIR',
    73  : 'RMKDIR',
    74  : 'TRENAMEAT',
    75  : 'RRENAMEAT',
    76  : 'TUNLINKAT',
    77  : 'RUNLINKAT',
    100 : 'TVERSION',
    101 : 'RVERSION',
    102 : 'TAUTH',
    103 : 'RAUTH',
    104 : 'TATTACH',
    105 : 'RATTACH',
    106 : 'TERROR',
    107 : 'RERROR',
    108 : 'TFLUSH',
    109 : 'RFLUSH',
    110 : 'TWALK',
    111 : 'RWALK',
    112 : 'TOPEN',
    113 : 'ROPEN',
    114 : 'TCREATE',
    115 : 'RCREATE',
    116 : 'TREAD',
    117 : 'RREAD',
    118 : 'TWRITE',
    119 : 'RWRITE',
    120 : 'TCLUNK',
    121 : 'RCLUNK',
    122 : 'TREMOVE',
    123 : 'RREMOVE',
    124 : 'TSTAT',
    125 : 'RSTAT',
    126 : 'TWSTAT',
    127 : 'RWSTAT'
}

81
class VirtFSRequestTracker(simpletrace.Analyzer):
82
        def begin(self):
83
                print("Pretty printing 9p simpletrace log ...")
84

85
        def v9fs_rerror(self, tag, id, err):
86
                print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")
87 88

        def v9fs_version(self, tag, id, msize, version):
89
                print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
90 91

        def v9fs_version_return(self, tag, id, msize, version):
92
                print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
93 94

        def v9fs_attach(self, tag, id, fid, afid, uname, aname):
95
                print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")
96

97
        def v9fs_attach_return(self, tag, id, type, version, path):
98
                print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
99

100
        def v9fs_stat(self, tag, id, fid):
101
                print("TSTAT (tag =", tag, ", fid =", fid, ")")
102

103
        def v9fs_stat_return(self, tag, id, mode, atime, mtime, length):
104
                print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")
105

106
        def v9fs_getattr(self, tag, id, fid, request_mask):
107
                print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")
108

109
        def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid):
110
                print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")
111

112
        def v9fs_walk(self, tag, id, fid, newfid, nwnames):
113
                print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")
114

115
        def v9fs_walk_return(self, tag, id, nwnames, qids):
116
                print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")
117

118
        def v9fs_open(self, tag, id, fid, mode):
119
                print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")
120

121
        def v9fs_open_return(self, tag, id, type, version, path, iounit):
122
                print("ROPEN (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
123

124
        def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid):
125
                print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")
126

127
        def v9fs_lcreate_return(self, tag, id, type, version, path, iounit):
128
                print("RLCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
129

130
        def v9fs_fsync(self, tag, id, fid, datasync):
131
                print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")
132

133
        def v9fs_clunk(self, tag, id, fid):
134
                print("TCLUNK (tag =", tag, ", fid =", fid, ")")
135

136
        def v9fs_read(self, tag, id, fid, off, max_count):
137
                print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")
138

139
        def v9fs_read_return(self, tag, id, count, err):
140
                print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")
141

142
        def v9fs_readdir(self, tag, id, fid, offset, max_count):
143
                print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")
144

145
        def v9fs_readdir_return(self, tag, id, count, retval):
146
                print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")
147

148
        def v9fs_write(self, tag, id, fid, off, count, cnt):
149
                print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")
150

151
        def v9fs_write_return(self, tag, id, total, err):
152
                print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")
153

154
        def v9fs_create(self, tag, id, fid, name, perm, mode):
155
                print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")
156

157
        def v9fs_create_return(self, tag, id, type, version, path, iounit):
158
                print("RCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
159

160
        def v9fs_symlink(self, tag, id, fid, name, symname, gid):
161
                print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")
162

163
        def v9fs_symlink_return(self, tag, id, type, version, path):
164
                print("RSYMLINK (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "})")
165

166
        def v9fs_flush(self, tag, id, flush_tag):
167
                print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")")
168

169
        def v9fs_link(self, tag, id, dfid, oldfid, name):
170
                print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")
171

172
        def v9fs_remove(self, tag, id, fid):
173
                print("TREMOVE (tag =", tag, ", fid =", fid, ")")
174

175
        def v9fs_wstat(self, tag, id, fid, mode, atime, mtime):
176
                print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")
177

178
        def v9fs_mknod(self, tag, id, fid, mode, major, minor):
179
                print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")
180

181
        def v9fs_lock(self, tag, id, fid, type, start, length):
182
                print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
183

184
        def v9fs_lock_return(self, tag, id, status):
185
                print("RLOCK (tag =", tag, ", status =", status, ")")
186

187
        def v9fs_getlock(self, tag, id, fid, type, start, length):
188
                print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
189

190
        def v9fs_getlock_return(self, tag, id, type, start, length, proc_id):
191
                print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id,  ")")
192

193
        def v9fs_mkdir(self, tag, id, fid, name, mode, gid):
194
                print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")
195

196
        def v9fs_mkdir_return(self, tag, id, type, version, path, err):
197
                print("RMKDIR (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")
198

199
        def v9fs_xattrwalk(self, tag, id, fid, newfid, name):
200
                print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")
201

202
        def v9fs_xattrwalk_return(self, tag, id, size):
203
                print("RXATTRWALK (tag =", tag, ", xattrsize  =", size, ")")
204

205
        def v9fs_xattrcreate(self, tag, id, fid, name, size, flags):
206
                print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")
207

208
        def v9fs_readlink(self, tag, id, fid):
209
                print("TREADLINK (tag =", tag, ", fid =", fid, ")")
210

211
        def v9fs_readlink_return(self, tag, id, target):
212
                print("RREADLINK (tag =", tag, ", target =", target, ")")
213 214

simpletrace.run(VirtFSRequestTracker())