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:
@ -147,8 +147,12 @@ def process_vmlinux_post_ast(
|
|||||||
process_vmlinux_post_ast(
|
process_vmlinux_post_ast(
|
||||||
containing_type, llvm_handler, handler, processing_stack
|
containing_type, llvm_handler, handler, processing_stack
|
||||||
)
|
)
|
||||||
size_of_containing_type = (handler[containing_type.__name__]).__sizeof__()
|
size_of_containing_type = (
|
||||||
new_dep_node.set_field_ready(elem_name, True, size_of_containing_type)
|
handler[containing_type.__name__]
|
||||||
|
).__sizeof__()
|
||||||
|
new_dep_node.set_field_ready(
|
||||||
|
elem_name, True, size_of_containing_type
|
||||||
|
)
|
||||||
elif containing_type.__module__ == ctypes.__name__:
|
elif containing_type.__module__ == ctypes.__name__:
|
||||||
logger.debug(f"Processing ctype internal{containing_type}")
|
logger.debug(f"Processing ctype internal{containing_type}")
|
||||||
new_dep_node.set_field_ready(elem_name, True)
|
new_dep_node.set_field_ready(elem_name, True)
|
||||||
@ -165,8 +169,12 @@ def process_vmlinux_post_ast(
|
|||||||
process_vmlinux_post_ast(
|
process_vmlinux_post_ast(
|
||||||
elem_type, llvm_handler, handler, processing_stack
|
elem_type, llvm_handler, handler, processing_stack
|
||||||
)
|
)
|
||||||
size_of_containing_type = (handler[elem_type.__name__]).__sizeof__()
|
size_of_containing_type = (
|
||||||
new_dep_node.set_field_ready(elem_name, True, size_of_containing_type)
|
handler[elem_type.__name__]
|
||||||
|
).__sizeof__()
|
||||||
|
new_dep_node.set_field_ready(
|
||||||
|
elem_name, True, size_of_containing_type
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"{elem_name} with type {elem_type} from module {module_name} not supported in recursive resolver"
|
f"{elem_name} with type {elem_type} from module {module_name} not supported in recursive resolver"
|
||||||
|
|||||||
@ -215,7 +215,12 @@ class DependencyNode:
|
|||||||
# Invalidate readiness cache
|
# Invalidate readiness cache
|
||||||
self._ready_cache = None
|
self._ready_cache = None
|
||||||
|
|
||||||
def set_field_ready(self, name: str, is_ready: bool = False, size_of_containing_type: Optional[int] = None) -> None:
|
def set_field_ready(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
is_ready: bool = False,
|
||||||
|
size_of_containing_type: Optional[int] = None,
|
||||||
|
) -> None:
|
||||||
"""Mark a field as ready or not ready."""
|
"""Mark a field as ready or not ready."""
|
||||||
if name not in self.fields:
|
if name not in self.fields:
|
||||||
raise KeyError(f"Field '{name}' does not exist in node '{self.name}'")
|
raise KeyError(f"Field '{name}' does not exist in node '{self.name}'")
|
||||||
@ -226,7 +231,9 @@ class DependencyNode:
|
|||||||
# Invalidate readiness cache
|
# Invalidate readiness cache
|
||||||
self._ready_cache = None
|
self._ready_cache = None
|
||||||
|
|
||||||
def _calculate_size(self, name: str, size_of_containing_type: Optional[int] = None) -> int:
|
def _calculate_size(
|
||||||
|
self, name: str, size_of_containing_type: Optional[int] = None
|
||||||
|
) -> int:
|
||||||
processing_field = self.fields[name]
|
processing_field = self.fields[name]
|
||||||
# size_of_field will be in bytes
|
# size_of_field will be in bytes
|
||||||
if processing_field.type.__module__ == ctypes.__name__:
|
if processing_field.type.__module__ == ctypes.__name__:
|
||||||
@ -244,8 +251,7 @@ class DependencyNode:
|
|||||||
return size_of_field
|
return size_of_field
|
||||||
elif processing_field.containing_type.__module__ == "vmlinux":
|
elif processing_field.containing_type.__module__ == "vmlinux":
|
||||||
size_of_field = (
|
size_of_field = (
|
||||||
size_of_containing_type
|
size_of_containing_type * processing_field.type_size
|
||||||
* processing_field.type_size
|
|
||||||
)
|
)
|
||||||
return size_of_field
|
return size_of_field
|
||||||
elif issubclass(processing_field.ctype_complex_type, ctypes._Pointer):
|
elif issubclass(processing_field.ctype_complex_type, ctypes._Pointer):
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from pythonbpf.maps import HashMap
|
|||||||
from pythonbpf.helper import XDP_PASS
|
from pythonbpf.helper import XDP_PASS
|
||||||
from vmlinux import TASK_COMM_LEN # noqa: F401
|
from vmlinux import TASK_COMM_LEN # noqa: F401
|
||||||
from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
|
from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
|
||||||
|
|
||||||
# from vmlinux import struct_request
|
# from vmlinux import struct_request
|
||||||
from vmlinux import struct_xdp_md
|
from vmlinux import struct_xdp_md
|
||||||
# from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
|
# from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
|
||||||
|
|||||||
Reference in New Issue
Block a user