mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
change debug_compile_unit addition location
This commit is contained in:
@ -4,6 +4,7 @@ from .license_pass import license_processing
|
|||||||
from .functions_pass import func_proc
|
from .functions_pass import func_proc
|
||||||
from .maps_pass import maps_proc
|
from .maps_pass import maps_proc
|
||||||
from .globals_pass import globals_processing
|
from .globals_pass import globals_processing
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def find_bpf_chunks(tree):
|
def find_bpf_chunks(tree):
|
||||||
@ -41,7 +42,27 @@ def compile_to_ir(filename: str, output: str):
|
|||||||
module.data_layout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
|
module.data_layout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
|
||||||
module.triple = "bpf"
|
module.triple = "bpf"
|
||||||
|
|
||||||
|
if not hasattr(module, '_debug_compile_unit'):
|
||||||
|
module._file_metadata = module.add_debug_info("DIFile", { # type: ignore
|
||||||
|
"filename": filename,
|
||||||
|
"directory": os.path.dirname(filename)
|
||||||
|
})
|
||||||
|
|
||||||
|
module._debug_compile_unit = module.add_debug_info("DICompileUnit", { # type: ignore
|
||||||
|
"language": 29, # DW_LANG_C11
|
||||||
|
"file": module._file_metadata, # type: ignore
|
||||||
|
"producer": "PythonBPF DSL Compiler",
|
||||||
|
"isOptimized": True,
|
||||||
|
"runtimeVersion": 0,
|
||||||
|
"emissionKind": 1,
|
||||||
|
"splitDebugInlining": False,
|
||||||
|
"nameTableKind": 0
|
||||||
|
}, is_distinct=True)
|
||||||
|
|
||||||
|
module.add_named_metadata("llvm.dbg.cu", module._debug_compile_unit) # type: ignore
|
||||||
|
|
||||||
processor(source, filename, module)
|
processor(source, filename, module)
|
||||||
|
|
||||||
wchar_size = module.add_metadata([ir.Constant(ir.IntType(32), 1),
|
wchar_size = module.add_metadata([ir.Constant(ir.IntType(32), 1),
|
||||||
"wchar_size",
|
"wchar_size",
|
||||||
ir.Constant(ir.IntType(32), 4)])
|
ir.Constant(ir.IntType(32), 4)])
|
||||||
|
|||||||
@ -48,29 +48,7 @@ def create_bpf_map(module, map_name, map_params):
|
|||||||
|
|
||||||
def create_map_debug_info(module, map_global, map_name, map_params):
|
def create_map_debug_info(module, map_global, map_name, map_params):
|
||||||
"""Generate debug information metadata for BPF map"""
|
"""Generate debug information metadata for BPF map"""
|
||||||
file_metadata = module
|
file_metadata = module._file_metadata
|
||||||
# Get or create compile unit (you may already have this)
|
|
||||||
if not hasattr(module, '_debug_compile_unit'):
|
|
||||||
# Create file metadata
|
|
||||||
file_metadata = module.add_debug_info("DIFile", {
|
|
||||||
"filename": "generated.bpf.c", # Adjust as needed
|
|
||||||
"directory": "/generated", # Adjust as needed
|
|
||||||
})
|
|
||||||
|
|
||||||
# Create compile unit
|
|
||||||
module._debug_compile_unit = module.add_debug_info("DICompileUnit", {
|
|
||||||
"language": 12, # DW_LANG_C11
|
|
||||||
"file": file_metadata,
|
|
||||||
"producer": "PythonBPF DSL Compiler",
|
|
||||||
"isOptimized": True,
|
|
||||||
"runtimeVersion": 0,
|
|
||||||
"emissionKind": 1,
|
|
||||||
"splitDebugInlining": False,
|
|
||||||
"nameTableKind": 0
|
|
||||||
}, is_distinct=True)
|
|
||||||
|
|
||||||
module.add_named_metadata("llvm.dbg.cu", module._debug_compile_unit)
|
|
||||||
|
|
||||||
compile_unit = module._debug_compile_unit
|
compile_unit = module._debug_compile_unit
|
||||||
|
|
||||||
# Create basic type for unsigned int (32-bit)
|
# Create basic type for unsigned int (32-bit)
|
||||||
|
|||||||
Reference in New Issue
Block a user