format chore

This commit is contained in:
2025-11-13 09:31:10 +05:30
parent 73bbf00e7c
commit 49740598ea
5 changed files with 25 additions and 11 deletions

View File

@ -14,6 +14,7 @@ class IRGenerator:
# This field keeps track of the non_struct names to avoid duplicate name errors. # This field keeps track of the non_struct names to avoid duplicate name errors.
type_number = 0 type_number = 0
unprocessed_store = [] unprocessed_store = []
# get the assignments dict and add this stuff to it. # get the assignments dict and add this stuff to it.
def __init__(self, llvm_module, handler: DependencyHandler, assignments): def __init__(self, llvm_module, handler: DependencyHandler, assignments):
self.llvm_module = llvm_module self.llvm_module = llvm_module
@ -193,7 +194,11 @@ class IRGenerator:
base_containing_type = next_type base_containing_type = next_type
# Get the base struct name # Get the base struct name
base_struct_name = base_containing_type.__name__ if hasattr(base_containing_type, "__name__") else str(base_containing_type) base_struct_name = (
base_containing_type.__name__
if hasattr(base_containing_type, "__name__")
else str(base_containing_type)
)
# Look up the size using the base struct name # Look up the size using the base struct name
containing_type_size = self.handler[base_struct_name].current_offset containing_type_size = self.handler[base_struct_name].current_offset
@ -212,14 +217,23 @@ class IRGenerator:
else: else:
for i in range(0, array_size): for i in range(0, array_size):
field_co_re_name, returned = self._struct_name_generator( field_co_re_name, returned = self._struct_name_generator(
struct, field, field_index, True, i, containing_type_size struct,
field,
field_index,
True,
i,
containing_type_size,
) )
globvar = ir.GlobalVariable( globvar = ir.GlobalVariable(
self.llvm_module, ir.IntType(64), name=field_co_re_name self.llvm_module, ir.IntType(64), name=field_co_re_name
) )
globvar.linkage = "external" globvar.linkage = "external"
globvar.set_metadata("llvm.preserve.access.index", debug_info) globvar.set_metadata(
self.generated_field_names[struct.name][field_name] = globvar "llvm.preserve.access.index", debug_info
)
self.generated_field_names[struct.name][field_name] = (
globvar
)
field_index += 1 field_index += 1
else: else:
field_co_re_name, returned = self._struct_name_generator( field_co_re_name, returned = self._struct_name_generator(

View File

@ -1,7 +1,7 @@
from vmlinux import struct_request, struct_pt_regs from vmlinux import struct_request, struct_pt_regs
from pythonbpf import bpf, section, bpfglobal, compile_to_ir from pythonbpf import bpf, section, bpfglobal, compile_to_ir
import logging import logging
from ctypes import c_int64, c_void_p from ctypes import c_int64
@bpf @bpf

View File

@ -1,4 +1,4 @@
from vmlinux import struct_request, struct_pt_regs, XDP_PASS from vmlinux import struct_pt_regs
from pythonbpf import bpf, section, bpfglobal, compile_to_ir from pythonbpf import bpf, section, bpfglobal, compile_to_ir
import logging import logging
from ctypes import c_int64 from ctypes import c_int64