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/ext4slower.py b/tools/ext4slower.py
index 16b56ec..0524f22 100755
--- a/tools/ext4slower.py
+++ b/tools/ext4slower.py
@@ -29,7 +29,6 @@
from bcc import BPF
import argparse
from time import strftime
-import ctypes as ct
# symbols
kallsyms = "/proc/kallsyms"
@@ -285,24 +284,9 @@
if args.ebpf:
exit()
-# kernel->user event data: struct data_t
-DNAME_INLINE_LEN = 32 # linux/dcache.h
-TASK_COMM_LEN = 16 # linux/sched.h
-class Data(ct.Structure):
- _fields_ = [
- ("ts_us", ct.c_ulonglong),
- ("type", ct.c_ulonglong),
- ("size", ct.c_ulonglong),
- ("offset", ct.c_ulonglong),
- ("delta_us", ct.c_ulonglong),
- ("pid", ct.c_ulonglong),
- ("task", ct.c_char * TASK_COMM_LEN),
- ("file", ct.c_char * DNAME_INLINE_LEN)
- ]
-
# process event
def print_event(cpu, data, size):
- event = ct.cast(data, ct.POINTER(Data)).contents
+ event = b["events"].event(data)
type = 'R'
if event.type == 1: