Add trace_pipe utility

This commit is contained in:
Pragyansh Chaturvedi
2025-10-14 03:51:43 +05:30
parent 18d62d605a
commit edc33733d9
4 changed files with 36 additions and 2 deletions

View File

@ -1,5 +1,6 @@
from .decorators import bpf, map, section, bpfglobal, struct
from .codegen import compile_to_ir, compile, BPF
from .utils import trace_pipe
__all__ = [
"bpf",
@ -10,4 +11,5 @@ __all__ = [
"compile_to_ir",
"compile",
"BPF",
"trace_pipe",
]

9
pythonbpf/utils.py Normal file
View File

@ -0,0 +1,9 @@
import subprocess
def trace_pipe():
"""Util to read from the trace pipe."""
try:
subprocess.run(["cat", "/sys/kernel/tracing/trace_pipe"])
except KeyboardInterrupt:
print("Tracing stopped.")