File tree Expand file tree Collapse file tree 4 files changed +22
-27
lines changed
Expand file tree Collapse file tree 4 files changed +22
-27
lines changed Original file line number Diff line number Diff line change 22import logging
33
44from llvmlite import ir
5- from dataclasses import dataclass
6- from typing import Any
5+ from .local_symbol import LocalSymbol
76from pythonbpf .helper import HelperHandlerRegistry
87from pythonbpf .vmlinux_parser .dependency_node import Field
98from .expr import VmlinuxHandlerRegistry
1211logger = logging .getLogger (__name__ )
1312
1413
15- @dataclass
16- class LocalSymbol :
17- var : ir .AllocaInstr
18- ir_type : ir .Type
19- metadata : Any = None
20-
21- def __iter__ (self ):
22- yield self .var
23- yield self .ir_type
24- yield self .metadata
25-
26-
2714def create_targets_and_rvals (stmt ):
2815 """Create lists of targets and right-hand values from an assignment statement."""
2916 if isinstance (stmt .targets [0 ], ast .Tuple ):
Original file line number Diff line number Diff line change @@ -351,18 +351,8 @@ def process_func_body(
351351 context_type = LocalSymbol (
352352 None , ir .PointerType (resolved_type ), resolved_type
353353 )
354- else :
355- try :
356- resolved_type = ctypes_to_ir (context_type_name )
357- logger .error ("THIS SHOULD NOT HAPPEN. I THINK. PROBABLY." )
358- context_type = LocalSymbol (
359- None , ir .PointerType (resolved_type ), resolved_type
360- )
361- except Exception :
362- raise TypeError (f"Type '{ context_type_name } ' not declared" )
363-
364- local_sym_tab [context_name ] = context_type
365- logger .info (f"Added argument '{ context_name } ' to local symbol table" )
354+ local_sym_tab [context_name ] = context_type
355+ logger .info (f"Added argument '{ context_name } ' to local symbol table" )
366356
367357 # pre-allocate dynamic variables
368358 local_sym_tab = allocate_mem (
Original file line number Diff line number Diff line change 1+ import llvmlite .ir as ir
2+ from dataclasses import dataclass
3+ from typing import Any
4+
5+
6+ @dataclass
7+ class LocalSymbol :
8+ var : ir .AllocaInstr
9+ ir_type : ir .Type
10+ metadata : Any = None
11+
12+ def __iter__ (self ):
13+ yield self .var
14+ yield self .ir_type
15+ yield self .metadata
Original file line number Diff line number Diff line change 11import logging
22from llvmlite import ir
33
4+ from pythonbpf .local_symbol import LocalSymbol
45from pythonbpf .vmlinux_parser .assignment_info import AssignmentType
56
67logger = logging .getLogger (__name__ )
@@ -88,10 +89,12 @@ def handle_vmlinux_struct_field(
8889 ):
8990 """Handle access to vmlinux struct fields"""
9091 if struct_var_name in local_sym_tab :
91- var_info = local_sym_tab [struct_var_name ]
92+ var_info : LocalSymbol = local_sym_tab [struct_var_name ]
9293 logger .info (
9394 f"Attempting to access field { field_name } of possible vmlinux struct { struct_var_name } "
9495 )
96+ print (var_info .ir_type )
97+ print (self .get_field_type (struct_var_name , field_name ))
9598 # Return pointer to field and field type
9699 return None
97100 else :
You can’t perform that action at this time.
0 commit comments