Skip to content

Commit 4974059

Browse files
format chore
1 parent 73bbf00 commit 4974059

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _get_field_debug_type(
7979
"""
8080
# Handle complex types (arrays, pointers)
8181
if field.ctype_complex_type is not None:
82-
#TODO: Check if this is a CFUNCTYPE (function pointer), but sadly it just checks callable for now
82+
# TODO: Check if this is a CFUNCTYPE (function pointer), but sadly it just checks callable for now
8383
if callable(field.ctype_complex_type):
8484
# Handle function pointer types, create a void pointer as a placeholder
8585
return generator.create_pointer_type(None), 64

pythonbpf/vmlinux_parser/ir_gen/ir_generation.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class IRGenerator:
1414
# This field keeps track of the non_struct names to avoid duplicate name errors.
1515
type_number = 0
1616
unprocessed_store = []
17+
1718
# get the assignments dict and add this stuff to it.
1819
def __init__(self, llvm_module, handler: DependencyHandler, assignments):
1920
self.llvm_module = llvm_module
@@ -187,13 +188,17 @@ def gen_ir(self, struct, generated_debug_info):
187188
while hasattr(base_containing_type, "_type_"):
188189
next_type = base_containing_type._type_
189190
# Stop if _type_ is a string (like 'c' for c_char)
190-
#TODO: stacked pointers not handl;ing ctypes check here as well
191+
# TODO: stacked pointers not handl;ing ctypes check here as well
191192
if isinstance(next_type, str):
192193
break
193194
base_containing_type = next_type
194195

195196
# Get the base struct name
196-
base_struct_name = base_containing_type.__name__ if hasattr(base_containing_type, "__name__") else str(base_containing_type)
197+
base_struct_name = (
198+
base_containing_type.__name__
199+
if hasattr(base_containing_type, "__name__")
200+
else str(base_containing_type)
201+
)
197202

198203
# Look up the size using the base struct name
199204
containing_type_size = self.handler[base_struct_name].current_offset
@@ -212,14 +217,23 @@ def gen_ir(self, struct, generated_debug_info):
212217
else:
213218
for i in range(0, array_size):
214219
field_co_re_name, returned = self._struct_name_generator(
215-
struct, field, field_index, True, i, containing_type_size
220+
struct,
221+
field,
222+
field_index,
223+
True,
224+
i,
225+
containing_type_size,
216226
)
217227
globvar = ir.GlobalVariable(
218228
self.llvm_module, ir.IntType(64), name=field_co_re_name
219229
)
220230
globvar.linkage = "external"
221-
globvar.set_metadata("llvm.preserve.access.index", debug_info)
222-
self.generated_field_names[struct.name][field_name] = globvar
231+
globvar.set_metadata(
232+
"llvm.preserve.access.index", debug_info
233+
)
234+
self.generated_field_names[struct.name][field_name] = (
235+
globvar
236+
)
223237
field_index += 1
224238
else:
225239
field_co_re_name, returned = self._struct_name_generator(
@@ -272,7 +286,7 @@ def _struct_name_generator(
272286
return unprocessed_type + "_" + str(self.type_number), False
273287
else:
274288
self.unprocessed_store.append(unprocessed_type)
275-
return unprocessed_type, False
289+
return unprocessed_type, False
276290
# raise TypeError(
277291
# "Name generation cannot occur due to type name not starting with struct"
278292
# )

tests/failing_tests/vmlinux/assignment_handling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
@bpf
88
@section("kprobe/blk_mq_start_request")
99
def example(ctx: c_void_p) -> c_int64:
10-
d = XDP_PASS # This gives an error, but
11-
e = XDP_PASS + 0 # this does not
10+
d = XDP_PASS # This gives an error, but
11+
e = XDP_PASS + 0 # this does not
1212
print(f"test1 {e} test2 {d}")
1313
return c_int64(0)
1414

tests/failing_tests/vmlinux/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from vmlinux import struct_request, struct_pt_regs
22
from pythonbpf import bpf, section, bpfglobal, compile_to_ir
33
import logging
4-
from ctypes import c_int64, c_void_p
4+
from ctypes import c_int64
55

66

77
@bpf

tests/failing_tests/vmlinux/requests2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from vmlinux import struct_request, struct_pt_regs, XDP_PASS
1+
from vmlinux import struct_pt_regs
22
from pythonbpf import bpf, section, bpfglobal, compile_to_ir
33
import logging
44
from ctypes import c_int64

0 commit comments

Comments
 (0)