diff --git a/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py b/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py index d83e3c0..5730670 100644 --- a/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py +++ b/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py @@ -79,7 +79,7 @@ def _get_field_debug_type( """ # Handle complex types (arrays, pointers) if field.ctype_complex_type is not None: - #TODO: Check if this is a CFUNCTYPE (function pointer), but sadly it just checks callable for now + # TODO: Check if this is a CFUNCTYPE (function pointer), but sadly it just checks callable for now if callable(field.ctype_complex_type): # Handle function pointer types, create a void pointer as a placeholder return generator.create_pointer_type(None), 64 diff --git a/pythonbpf/vmlinux_parser/ir_gen/ir_generation.py b/pythonbpf/vmlinux_parser/ir_gen/ir_generation.py index 855548c..fef51a5 100644 --- a/pythonbpf/vmlinux_parser/ir_gen/ir_generation.py +++ b/pythonbpf/vmlinux_parser/ir_gen/ir_generation.py @@ -14,6 +14,7 @@ class IRGenerator: # This field keeps track of the non_struct names to avoid duplicate name errors. type_number = 0 unprocessed_store = [] + # get the assignments dict and add this stuff to it. def __init__(self, llvm_module, handler: DependencyHandler, assignments): self.llvm_module = llvm_module @@ -187,13 +188,17 @@ class IRGenerator: while hasattr(base_containing_type, "_type_"): next_type = base_containing_type._type_ # Stop if _type_ is a string (like 'c' for c_char) - #TODO: stacked pointers not handl;ing ctypes check here as well + # TODO: stacked pointers not handl;ing ctypes check here as well if isinstance(next_type, str): break base_containing_type = next_type # 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 containing_type_size = self.handler[base_struct_name].current_offset @@ -212,14 +217,23 @@ class IRGenerator: else: for i in range(0, array_size): 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( self.llvm_module, ir.IntType(64), name=field_co_re_name ) globvar.linkage = "external" - globvar.set_metadata("llvm.preserve.access.index", debug_info) - self.generated_field_names[struct.name][field_name] = globvar + globvar.set_metadata( + "llvm.preserve.access.index", debug_info + ) + self.generated_field_names[struct.name][field_name] = ( + globvar + ) field_index += 1 else: field_co_re_name, returned = self._struct_name_generator( @@ -272,7 +286,7 @@ class IRGenerator: return unprocessed_type + "_" + str(self.type_number), False else: self.unprocessed_store.append(unprocessed_type) - return unprocessed_type, False + return unprocessed_type, False # raise TypeError( # "Name generation cannot occur due to type name not starting with struct" # ) diff --git a/tests/failing_tests/vmlinux/assignment_handling.py b/tests/failing_tests/vmlinux/assignment_handling.py index 5ba1a6e..b8fe43e 100644 --- a/tests/failing_tests/vmlinux/assignment_handling.py +++ b/tests/failing_tests/vmlinux/assignment_handling.py @@ -7,8 +7,8 @@ from ctypes import c_int64, c_void_p @bpf @section("kprobe/blk_mq_start_request") def example(ctx: c_void_p) -> c_int64: - d = XDP_PASS # This gives an error, but - e = XDP_PASS + 0 # this does not + d = XDP_PASS # This gives an error, but + e = XDP_PASS + 0 # this does not print(f"test1 {e} test2 {d}") return c_int64(0) diff --git a/tests/failing_tests/vmlinux/requests.py b/tests/failing_tests/vmlinux/requests.py index 3c5907e..bab809f 100644 --- a/tests/failing_tests/vmlinux/requests.py +++ b/tests/failing_tests/vmlinux/requests.py @@ -1,7 +1,7 @@ from vmlinux import struct_request, struct_pt_regs from pythonbpf import bpf, section, bpfglobal, compile_to_ir import logging -from ctypes import c_int64, c_void_p +from ctypes import c_int64 @bpf diff --git a/tests/failing_tests/vmlinux/requests2.py b/tests/failing_tests/vmlinux/requests2.py index 46ccdcb..63e90c7 100644 --- a/tests/failing_tests/vmlinux/requests2.py +++ b/tests/failing_tests/vmlinux/requests2.py @@ -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 import logging from ctypes import c_int64