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/cpuunclaimed.py b/tools/cpuunclaimed.py
index 75ee932..dc0f325 100755
--- a/tools/cpuunclaimed.py
+++ b/tools/cpuunclaimed.py
@@ -59,11 +59,9 @@
from __future__ import print_function
from bcc import BPF, PerfType, PerfSWConfig
from time import sleep, strftime
-from ctypes import c_int
import argparse
import multiprocessing
from os import getpid, system, open, close, dup, unlink, O_WRONLY
-import ctypes as ct
from tempfile import NamedTemporaryFile
# arguments
@@ -248,12 +246,6 @@
else:
print(("Sampling run queues... Output every %s seconds. " +
"Hit Ctrl-C to end.") % args.interval)
-class Data(ct.Structure):
- _fields_ = [
- ("ts", ct.c_ulonglong),
- ("cpu", ct.c_ulonglong),
- ("len", ct.c_ulonglong)
- ]
samples = {}
group = {}
@@ -261,7 +253,7 @@
# process event
def print_event(cpu, data, size):
- event = ct.cast(data, ct.POINTER(Data)).contents
+ event = b["events"].event(data)
samples[event.ts] = {}
samples[event.ts]['cpu'] = event.cpu
samples[event.ts]['len'] = event.len