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/fileslower.py b/tools/fileslower.py
index e2830e9..6fa0c26 100755
--- a/tools/fileslower.py
+++ b/tools/fileslower.py
@@ -31,7 +31,6 @@
from __future__ import print_function
from bcc import BPF
import argparse
-import ctypes as ct
import time
# arguments
@@ -210,20 +209,6 @@
b.attach_kprobe(event="vfs_write", fn_name="trace_write_entry")
b.attach_kretprobe(event="vfs_write", fn_name="trace_write_return")
-TASK_COMM_LEN = 16 # linux/sched.h
-DNAME_INLINE_LEN = 32 # linux/dcache.h
-
-class Data(ct.Structure):
- _fields_ = [
- ("mode", ct.c_int),
- ("pid", ct.c_uint),
- ("sz", ct.c_uint),
- ("delta_us", ct.c_ulonglong),
- ("name_len", ct.c_uint),
- ("name", ct.c_char * DNAME_INLINE_LEN),
- ("comm", ct.c_char * TASK_COMM_LEN),
- ]
-
mode_s = {
0: 'R',
1: 'W',
@@ -237,7 +222,7 @@
start_ts = time.time()
def print_event(cpu, data, size):
- event = ct.cast(data, ct.POINTER(Data)).contents
+ event = b["events"].event(data)
ms = float(event.delta_us) / 1000
name = event.name.decode('utf-8', 'replace')