Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add enum support for generating perf event data struct #2199

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/python/bcc/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ def _get_event_class(self):
'u16' : ct.c_ushort,
'int' : ct.c_int,
's32' : ct.c_int,
'enum' : ct.c_int,
'unsigned int' : ct.c_uint,
'u32' : ct.c_uint,
'long' : ct.c_long,
Expand All @@ -599,6 +600,9 @@ def _get_event_class(self):
field_name = m.group(1)
field_type = m.group(2)

if re.match(r"enum .*", field_type):
field_type = "enum"

m = array_type.match(field_type)
try:
if m:
Expand Down
14 changes: 1 addition & 13 deletions tools/dcsnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from __future__ import print_function
from bcc import BPF
import argparse
import ctypes as ct
import re
import time

Expand Down Expand Up @@ -123,17 +122,6 @@
}
"""

TASK_COMM_LEN = 16 # linux/sched.h
MAX_FILE_LEN = 64 # see inline C

class Data(ct.Structure):
_fields_ = [
("pid", ct.c_uint),
("type", ct.c_int),
("comm", ct.c_char * TASK_COMM_LEN),
("filename", ct.c_char * MAX_FILE_LEN),
]

if args.ebpf:
print(bpf_text)
exit()
Expand All @@ -151,7 +139,7 @@ class Data(ct.Structure):
start_ts = time.time()

def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
event = b["events"].event(data)
print("%-11.6f %-6d %-16s %1s %s" % (
time.time() - start_ts, event.pid,
event.comm.decode('utf-8', 'replace'), mode_s[event.type],
Expand Down