mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
remove ruff errors. May contain breaking changes.
This commit is contained in:
@ -3,7 +3,7 @@ import time
|
|||||||
from pythonbpf import bpf, map, section, bpfglobal, BPF
|
from pythonbpf import bpf, map, section, bpfglobal, BPF
|
||||||
from pythonbpf.helpers import pid
|
from pythonbpf.helpers import pid
|
||||||
from pythonbpf.maps import HashMap
|
from pythonbpf.maps import HashMap
|
||||||
from pylibbpf import *
|
from pylibbpf import BpfMap
|
||||||
from ctypes import c_void_p, c_int64, c_uint64, c_int32
|
from ctypes import c_void_p, c_int64, c_uint64, c_int32
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|||||||
@ -24,12 +24,13 @@ def events() -> PerfEventArray:
|
|||||||
def hello(ctx: c_void_p) -> c_int32:
|
def hello(ctx: c_void_p) -> c_int32:
|
||||||
dataobj = data_t()
|
dataobj = data_t()
|
||||||
ts = ktime()
|
ts = ktime()
|
||||||
process_id = pid()
|
|
||||||
strobj = "hellohellohello"
|
strobj = "hellohellohello"
|
||||||
dataobj.pid = pid()
|
dataobj.pid = pid()
|
||||||
dataobj.ts = ktime()
|
dataobj.ts = ktime()
|
||||||
# dataobj.comm = strobj
|
# dataobj.comm = strobj
|
||||||
print(f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj}")
|
print(
|
||||||
|
f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj} at time {ts}"
|
||||||
|
)
|
||||||
events.output(dataobj)
|
events.output(dataobj)
|
||||||
return c_int32(0)
|
return c_int32(0)
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,13 @@
|
|||||||
from .decorators import bpf, map, section, bpfglobal, struct
|
from .decorators import bpf, map, section, bpfglobal, struct
|
||||||
from .codegen import compile_to_ir, compile, BPF
|
from .codegen import compile_to_ir, compile, BPF
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"bpf",
|
||||||
|
"map",
|
||||||
|
"section",
|
||||||
|
"bpfglobal",
|
||||||
|
"struct",
|
||||||
|
"compile_to_ir",
|
||||||
|
"compile",
|
||||||
|
"BPF",
|
||||||
|
]
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
from .dwarf_constants import *
|
from .dwarf_constants import * # noqa: F403
|
||||||
from .dtypes import *
|
from .dtypes import * # noqa: F403
|
||||||
from .debug_info_generator import DebugInfoGenerator
|
from .debug_info_generator import DebugInfoGenerator
|
||||||
|
|
||||||
|
__all__ = ["DebugInfoGenerator"]
|
||||||
|
|||||||
@ -189,7 +189,7 @@ def handle_assign(
|
|||||||
map_name = rval.func.value.func.id
|
map_name = rval.func.value.func.id
|
||||||
method_name = rval.func.attr
|
method_name = rval.func.attr
|
||||||
if map_name in map_sym_tab:
|
if map_name in map_sym_tab:
|
||||||
map_ptr = map_sym_tab[map_name]
|
# map_ptr = map_sym_tab[map_name]
|
||||||
if method_name in helper_func_list:
|
if method_name in helper_func_list:
|
||||||
val = handle_helper_call(
|
val = handle_helper_call(
|
||||||
rval,
|
rval,
|
||||||
@ -289,7 +289,7 @@ def handle_if(
|
|||||||
):
|
):
|
||||||
"""Handle if statements in the function body."""
|
"""Handle if statements in the function body."""
|
||||||
print("Handling if statement")
|
print("Handling if statement")
|
||||||
start = builder.block.parent
|
# start = builder.block.parent
|
||||||
then_block = func.append_basic_block(name="if.then")
|
then_block = func.append_basic_block(name="if.then")
|
||||||
merge_block = func.append_basic_block(name="if.end")
|
merge_block = func.append_basic_block(name="if.end")
|
||||||
if stmt.orelse:
|
if stmt.orelse:
|
||||||
|
|||||||
Reference in New Issue
Block a user