Skip to content
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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

#- repo: https://github.com/astral-sh/ruff-pre-commit
# rev: "v0.4.2"
# hooks:
# - id: ruff
# args: ["--fix", "--show-fixes"]
# - id: ruff-format
# exclude: ^(docs)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.2"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format
exclude: ^(docs)

## Checking static types
#- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
2 changes: 1 addition & 1 deletion examples/clone_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pythonbpf import bpf, map, section, bpfglobal, BPF
from pythonbpf.helpers import pid
from pythonbpf.maps import HashMap
from pylibbpf import *
from pylibbpf import BpfMap
from ctypes import c_void_p, c_int64, c_uint64, c_int32
import matplotlib.pyplot as plt

Expand Down
5 changes: 3 additions & 2 deletions examples/struct_and_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ def events() -> PerfEventArray:
def hello(ctx: c_void_p) -> c_int32:
dataobj = data_t()
ts = ktime()
process_id = pid()
strobj = "hellohellohello"
dataobj.pid = pid()
dataobj.ts = ktime()
# 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)
return c_int32(0)

Expand Down
11 changes: 11 additions & 0 deletions pythonbpf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
from .decorators import bpf, map, section, bpfglobal, struct
from .codegen import compile_to_ir, compile, BPF

__all__ = [
"bpf",
"map",
"section",
"bpfglobal",
"struct",
"compile_to_ir",
"compile",
"BPF",
]
6 changes: 4 additions & 2 deletions pythonbpf/debuginfo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .dwarf_constants import *
from .dtypes import *
from .dwarf_constants import * # noqa: F403
from .dtypes import * # noqa: F403
from .debug_info_generator import DebugInfoGenerator

__all__ = ["DebugInfoGenerator"]
6 changes: 3 additions & 3 deletions pythonbpf/functions_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def handle_assign(
map_name = rval.func.value.func.id
method_name = rval.func.attr
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:
val = handle_helper_call(
rval,
Expand Down Expand Up @@ -289,7 +289,7 @@ def handle_if(
):
"""Handle if statements in the function body."""
print("Handling if statement")
start = builder.block.parent
# start = builder.block.parent
then_block = func.append_basic_block(name="if.then")
merge_block = func.append_basic_block(name="if.end")
if stmt.orelse:
Expand Down Expand Up @@ -674,7 +674,7 @@ def assign_string_to_array(builder, target_array_ptr, source_string_ptr, array_l
Copy a string (i8*) to a fixed-size array ([N x i8]*)
"""
# Create a loop to copy characters one by one
entry_block = builder.block
# entry_block = builder.block
copy_block = builder.append_basic_block("copy_char")
end_block = builder.append_basic_block("copy_end")

Expand Down
2 changes: 2 additions & 0 deletions pythonbpf/maps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .maps import HashMap, PerfEventArray
from .maps_pass import maps_proc

__all__ = ["HashMap", "PerfEventArray", "maps_proc"]
2 changes: 2 additions & 0 deletions pythonbpf/structs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .structs_pass import structs_proc

__all__ = ["structs_proc"]
1 change: 1 addition & 0 deletions tests/failing_tests/binops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@section("sometag1")
def sometag(ctx: c_void_p) -> c_int64:
a = 1 + 2 + 1
print(f"{a}")
return c_int64(0)


Expand Down
1 change: 1 addition & 0 deletions tests/failing_tests/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@section("sometag1")
def sometag(ctx: c_void_p) -> c_int64:
a = 1 + 2
print(f"{a}")
return c_int64(0)


Expand Down