Skip to content

Commit 33aa794

Browse files
identify error in pointer to ctypes subclass dependency fixing
1 parent d855e9e commit 33aa794

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pythonbpf/vmlinux_parser/class_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def process_vmlinux_post_ast(
9999
local_module_name = getattr(elem_type, "__module__", None)
100100
new_dep_node.add_field(elem_name, elem_type, ready=False)
101101
if local_module_name == ctypes.__name__:
102+
#TODO: need to process pointer to ctype and also CFUNCTYPES here
102103
new_dep_node.set_field_bitfield_size(elem_name, elem_bitfield_size)
104+
print(elem_type)
103105
new_dep_node.set_field_ready(elem_name, is_ready=True)
104106
logger.debug(
105107
f"Field {elem_name} is direct ctypes type: {elem_type}"
@@ -127,6 +129,8 @@ def process_vmlinux_post_ast(
127129
ctype_complex_type = ctypes.Array
128130
elif issubclass(elem_type, ctypes._Pointer):
129131
ctype_complex_type = ctypes._Pointer
132+
else:
133+
raise ImportError("Non Array and Pointer type ctype imports not supported in current version")
130134
else:
131135
raise TypeError("Unsupported ctypes subclass")
132136
else:

pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def _get_field_debug_type(
7878
"""
7979
# Handle complex types (arrays, pointers)
8080
if field.ctype_complex_type is not None:
81-
print(field)
8281
if issubclass(field.ctype_complex_type, ctypes.Array):
8382
# Handle array types
8483
element_type, base_type_size = _get_basic_debug_type(
@@ -90,7 +89,6 @@ def _get_field_debug_type(
9089
elif issubclass(field.ctype_complex_type, ctypes._Pointer):
9190
# Handle pointer types
9291
pointee_type, _ = _get_basic_debug_type(field.containing_type, generator)
93-
print("DEBUG", pointee_type)
9492
return generator.create_pointer_type(pointee_type), 64
9593

9694
# Handle other vmlinux types (nested structs)

tests/passing_tests/vmlinux/simple_struct_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from pythonbpf import bpf, section, bpfglobal, compile_to_ir, compile
22
from vmlinux import TASK_COMM_LEN # noqa: F401
33
from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
4-
# from vmlinux import struct_xdp_md
5-
# from vmlinux import struct_request
4+
# from vmlinux import struct_uinput_device
65
from vmlinux import struct_blk_integrity_iter
76
from ctypes import c_int64
87

0 commit comments

Comments
 (0)