mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
format chore
This commit is contained in:
@ -150,7 +150,9 @@ def handle_variable_assignment(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
val, val_type = val_result
|
val, val_type = val_result
|
||||||
logger.info(f"Evaluated value for {var_name}: {val} of type {val_type}, expected {var_type}")
|
logger.info(
|
||||||
|
f"Evaluated value for {var_name}: {val} of type {val_type}, expected {var_type}"
|
||||||
|
)
|
||||||
|
|
||||||
if val_type != var_type:
|
if val_type != var_type:
|
||||||
# Handle vmlinux struct pointers - they're represented as Python classes but are i64 pointers
|
# Handle vmlinux struct pointers - they're represented as Python classes but are i64 pointers
|
||||||
@ -161,7 +163,9 @@ def handle_variable_assignment(
|
|||||||
# Convert pointer to i64 using ptrtoint
|
# Convert pointer to i64 using ptrtoint
|
||||||
if isinstance(val.type, ir.PointerType):
|
if isinstance(val.type, ir.PointerType):
|
||||||
val = builder.ptrtoint(val, ir.IntType(64))
|
val = builder.ptrtoint(val, ir.IntType(64))
|
||||||
logger.info(f"Converted vmlinux struct pointer to i64 using ptrtoint")
|
logger.info(
|
||||||
|
"Converted vmlinux struct pointer to i64 using ptrtoint"
|
||||||
|
)
|
||||||
builder.store(val, var_ptr)
|
builder.store(val, var_ptr)
|
||||||
logger.info(f"Assigned vmlinux struct pointer to {var_name} (i64)")
|
logger.info(f"Assigned vmlinux struct pointer to {var_name} (i64)")
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
from .helper_registry import HelperHandlerRegistry
|
from .helper_registry import HelperHandlerRegistry
|
||||||
from .helper_utils import reset_scratch_pool
|
from .helper_utils import reset_scratch_pool
|
||||||
from .bpf_helper_handler import handle_helper_call, emit_probe_read_kernel_str_call, emit_probe_read_kernel_call
|
from .bpf_helper_handler import (
|
||||||
|
handle_helper_call,
|
||||||
|
emit_probe_read_kernel_str_call,
|
||||||
|
emit_probe_read_kernel_call,
|
||||||
|
)
|
||||||
from .helpers import (
|
from .helpers import (
|
||||||
ktime,
|
ktime,
|
||||||
pid,
|
pid,
|
||||||
|
|||||||
@ -173,7 +173,9 @@ class VmlinuxHandler:
|
|||||||
|
|
||||||
if field_size_bits in [8, 16, 32, 64]:
|
if field_size_bits in [8, 16, 32, 64]:
|
||||||
int_width = field_size_bits
|
int_width = field_size_bits
|
||||||
logger.info(f"Determined field size: {int_width} bits ({field_size_bytes} bytes)")
|
logger.info(
|
||||||
|
f"Determined field size: {int_width} bits ({field_size_bytes} bytes)"
|
||||||
|
)
|
||||||
|
|
||||||
# Special handling for struct_xdp_md i32 fields
|
# Special handling for struct_xdp_md i32 fields
|
||||||
if struct_name == "struct_xdp_md" and int_width == 32:
|
if struct_name == "struct_xdp_md" and int_width == 32:
|
||||||
@ -212,11 +214,8 @@ class VmlinuxHandler:
|
|||||||
# %result = call i64 inttoptr (i64 113 to ptr)(ptr %local_storage, i32 %size, ptr %passed)
|
# %result = call i64 inttoptr (i64 113 to ptr)(ptr %local_storage, i32 %size, ptr %passed)
|
||||||
from pythonbpf.helper import emit_probe_read_kernel_call
|
from pythonbpf.helper import emit_probe_read_kernel_call
|
||||||
|
|
||||||
result = emit_probe_read_kernel_call(
|
emit_probe_read_kernel_call(
|
||||||
builder,
|
builder, local_storage_i8_ptr, field_size_bytes, field_ptr
|
||||||
local_storage_i8_ptr,
|
|
||||||
field_size_bytes,
|
|
||||||
field_ptr
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Load the value from local storage
|
# Load the value from local storage
|
||||||
|
|||||||
Reference in New Issue
Block a user