From d855e9ef2ed21ecaa8a37feeb2496548207589a0 Mon Sep 17 00:00:00 2001 From: varun-r-mallya Date: Sat, 18 Oct 2025 22:32:03 +0530 Subject: [PATCH] correct mistake in null pointer. Also identify error in pointer to char debug info generation --- pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py | 5 +++-- tests/c-form/ex7.bpf.c | 2 +- tests/passing_tests/vmlinux/simple_struct_test.py | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py b/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py index 0ec6be3..ccb27a9 100644 --- a/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py +++ b/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py @@ -78,6 +78,7 @@ def _get_field_debug_type( """ # Handle complex types (arrays, pointers) if field.ctype_complex_type is not None: + print(field) if issubclass(field.ctype_complex_type, ctypes.Array): # Handle array types element_type, base_type_size = _get_basic_debug_type( @@ -89,6 +90,7 @@ def _get_field_debug_type( elif issubclass(field.ctype_complex_type, ctypes._Pointer): # Handle pointer types pointee_type, _ = _get_basic_debug_type(field.containing_type, generator) + print("DEBUG", pointee_type) return generator.create_pointer_type(pointee_type), 64 # Handle other vmlinux types (nested structs) @@ -156,7 +158,6 @@ def _get_basic_debug_type(ctype, generator: DebugInfoGenerator) -> Any: char_type = generator.get_basic_type("char", 8, dc.DW_ATE_signed_char), 8 return generator.create_pointer_type(char_type) elif ctype == ctypes.c_void_p: - void_type = generator.module.add_debug_info("DIBasicType", {"name": "void"}) - return generator.create_pointer_type(void_type), 64 + return generator.create_pointer_type(None), 64 else: return generator.get_uint64_type(), 64 diff --git a/tests/c-form/ex7.bpf.c b/tests/c-form/ex7.bpf.c index 80a60d1..33ed6a5 100644 --- a/tests/c-form/ex7.bpf.c +++ b/tests/c-form/ex7.bpf.c @@ -19,7 +19,7 @@ struct { SEC("tp/syscalls/sys_enter_setuid") int handle_setuid_entry(struct trace_event_raw_sys_enter *ctx) { struct event data = {}; - + struct blk_integrity_iter it = {}; // Extract UID from the syscall arguments data.uid = (unsigned int)ctx->args[0]; data.ts = bpf_ktime_get_ns(); diff --git a/tests/passing_tests/vmlinux/simple_struct_test.py b/tests/passing_tests/vmlinux/simple_struct_test.py index 99fc7a1..f3cbb97 100644 --- a/tests/passing_tests/vmlinux/simple_struct_test.py +++ b/tests/passing_tests/vmlinux/simple_struct_test.py @@ -1,6 +1,9 @@ from pythonbpf import bpf, section, bpfglobal, compile_to_ir, compile from vmlinux import TASK_COMM_LEN # noqa: F401 from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401 +# from vmlinux import struct_xdp_md +# from vmlinux import struct_request +from vmlinux import struct_blk_integrity_iter from ctypes import c_int64 @@ -24,4 +27,3 @@ def LICENSE() -> str: compile_to_ir("simple_struct_test.py", "simple_struct_test.ll") -compile()