tools: remove redundant Python event data structure definitions (#2204)
Simplify code following #2198 (https://github.com/iovisor/bcc/pull/2198).
Some tools are not touched: mountsnoop.py, trace.py, lib/*.py, old/*.py.
diff --git a/tools/syncsnoop.py b/tools/syncsnoop.py
index 708fbc4..e5fa78e 100755
--- a/tools/syncsnoop.py
+++ b/tools/syncsnoop.py
@@ -15,7 +15,6 @@
from __future__ import print_function
from bcc import BPF
-import ctypes as ct
# load BPF program
b = BPF(text="""
@@ -34,17 +33,12 @@
b.attach_kprobe(event=b.get_syscall_fnname("sync"),
fn_name="syscall__sync")
-class Data(ct.Structure):
- _fields_ = [
- ("ts", ct.c_ulonglong)
- ]
-
# header
print("%-18s %s" % ("TIME(s)", "CALL"))
# process event
def print_event(cpu, data, size):
- event = ct.cast(data, ct.POINTER(Data)).contents
+ event = b["events"].event(data)
print("%-18.9f sync()" % (float(event.ts) / 1000000))
# loop with callback to print_event