mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 09:58:34 +00:00
Core: Give every symbol kind a common Symbol base class
LocalSymbol, BpfGlobalSymbol and MapSymbol each named the storage behind a name differently (var, var, sym) and shared no type. They now all derive from symbols.Symbol, which carries what every symbol has -- the storage pointer (alloca, GlobalVariable, or None for the context parameter) and its IR type -- and each subclass adds only what its kind needs: LocalSymbol its metadata and declared_global flag, BpfGlobalSymbol its ctypes name, MapSymbol its map type and params. MapSymbol.sym becomes var to match. local_symbol.py is folded into the new symbols.py. LocalSymbol keeps its three-field __iter__ for the call sites that tuple-unpack a symbol. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
This commit is contained in:
@ -50,7 +50,12 @@ def create_bpf_map(compilation_context, map_name, map_params):
|
||||
map_global.align = 8
|
||||
|
||||
logger.info(f"Created BPF map: {map_name} with params {map_params}")
|
||||
return MapSymbol(type=map_params["type"], sym=map_global, params=map_params)
|
||||
return MapSymbol(
|
||||
var=map_global,
|
||||
ir_type=map_global.value_type,
|
||||
type=map_params["type"],
|
||||
params=map_params,
|
||||
)
|
||||
|
||||
|
||||
def _parse_map_params(rval, expected_args=None):
|
||||
@ -112,7 +117,7 @@ def process_ringbuf_map(map_name, rval, compilation_context):
|
||||
map_global = create_bpf_map(compilation_context, map_name, map_params)
|
||||
create_ringbuf_debug_info(
|
||||
compilation_context,
|
||||
map_global.sym,
|
||||
map_global.var,
|
||||
map_name,
|
||||
map_params,
|
||||
)
|
||||
@ -131,7 +136,7 @@ def process_hash_map(map_name, rval, compilation_context):
|
||||
# Generate debug info for BTF
|
||||
create_map_debug_info(
|
||||
compilation_context,
|
||||
map_global.sym,
|
||||
map_global.var,
|
||||
map_name,
|
||||
map_params,
|
||||
)
|
||||
@ -150,7 +155,7 @@ def process_perf_event_map(map_name, rval, compilation_context):
|
||||
# Generate debug info for BTF
|
||||
create_map_debug_info(
|
||||
compilation_context,
|
||||
map_global.sym,
|
||||
map_global.var,
|
||||
map_name,
|
||||
map_params,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user