MCPcopy
hub / github.com/brendangregg/bpf-perf-tools-book / print_event

Function print_event

originals/Ch07_Memory/mmapsnoop.py:142–162  ·  view source on GitHub ↗
(cpu, data, size)

Source from the content-addressed store, hash-verified

140
141# process event
142def print_event(cpu, data, size):
143 event = ct.cast(data, ct.POINTER(Data)).contents
144
145 # protection flags
146 r = "R" if event.prot & PROT_READ else "-"
147 w = "W" if event.prot & PROT_WRITE else "-"
148 x = "E" if event.prot & PROT_EXEC else "-"
149 prot = r + w + x
150
151 # map flags
152 s = "S" if event.flags & MAP_SHARED else "-"
153 p = "P" if event.flags & MAP_PRIVATE else "-"
154 f = "F" if event.flags & MAP_FIXED else "-"
155 a = "A" if event.flags & MAP_ANON else "-"
156 flags = s + p + f + a
157
158 if args.time:
159 print("%-8s " % strftime("%H:%M:%S"), end="")
160 print("%-6d %-14.14s %-4s %-5s %-8d %-8d %s" % (event.pid,
161 event.comm, prot, flags, event.off / 1024, event.len / 1024,
162 event.path))
163
164# initialize BPF
165b = BPF(text=bpf_text)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected