mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
format errors
This commit is contained in:
@ -62,12 +62,14 @@ def compile_to_ir(filename: str, output: str, loglevel=logging.WARNING):
|
|||||||
if not hasattr(module, "_debug_compile_unit"):
|
if not hasattr(module, "_debug_compile_unit"):
|
||||||
debug_generator = DebugInfoGenerator(module)
|
debug_generator = DebugInfoGenerator(module)
|
||||||
debug_generator.generate_file_metadata(filename, os.path.dirname(filename))
|
debug_generator.generate_file_metadata(filename, os.path.dirname(filename))
|
||||||
debug_generator.generate_debug_cu(DW_LANG_C11,
|
debug_generator.generate_debug_cu(
|
||||||
f"PythonBPF {VERSION}",
|
DW_LANG_C11,
|
||||||
True # TODO: This is probably not true
|
f"PythonBPF {VERSION}",
|
||||||
# TODO: add a global field here that keeps track of all the globals. Works without it, but I think it might
|
True, # TODO: This is probably not true
|
||||||
# be required for kprobes.
|
# TODO: add a global field here that keeps track of all the globals. Works without it, but I think it might
|
||||||
, True)
|
# be required for kprobes.
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
|
||||||
processor(source, filename, module)
|
processor(source, filename, module)
|
||||||
|
|
||||||
@ -129,7 +131,7 @@ def compile(loglevel=logging.WARNING) -> bool:
|
|||||||
|
|
||||||
success = True
|
success = True
|
||||||
success = (
|
success = (
|
||||||
compile_to_ir(str(caller_file), str(ll_file), loglevel=loglevel) and success
|
compile_to_ir(str(caller_file), str(ll_file), loglevel=loglevel) and success
|
||||||
)
|
)
|
||||||
|
|
||||||
success = bool(
|
success = bool(
|
||||||
@ -156,7 +158,7 @@ def BPF(loglevel=logging.WARNING) -> BpfProgram:
|
|||||||
caller_frame = inspect.stack()[1]
|
caller_frame = inspect.stack()[1]
|
||||||
src = inspect.getsource(caller_frame.frame)
|
src = inspect.getsource(caller_frame.frame)
|
||||||
with tempfile.NamedTemporaryFile(
|
with tempfile.NamedTemporaryFile(
|
||||||
mode="w+", delete=True, suffix=".py"
|
mode="w+", delete=True, suffix=".py"
|
||||||
) as f, tempfile.NamedTemporaryFile(
|
) as f, tempfile.NamedTemporaryFile(
|
||||||
mode="w+", delete=True, suffix=".ll"
|
mode="w+", delete=True, suffix=".ll"
|
||||||
) as inter, tempfile.NamedTemporaryFile(
|
) as inter, tempfile.NamedTemporaryFile(
|
||||||
|
|||||||
@ -21,7 +21,9 @@ class DebugInfoGenerator:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_debug_cu(self, language, producer: str, is_optimized: bool, is_distinct: bool):
|
def generate_debug_cu(
|
||||||
|
self, language, producer: str, is_optimized: bool, is_distinct: bool
|
||||||
|
):
|
||||||
self.module._debug_compile_unit = self.module.add_debug_info(
|
self.module._debug_compile_unit = self.module.add_debug_info(
|
||||||
"DICompileUnit",
|
"DICompileUnit",
|
||||||
{ # type: ignore
|
{ # type: ignore
|
||||||
@ -100,7 +102,7 @@ class DebugInfoGenerator:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def create_struct_type(
|
def create_struct_type(
|
||||||
self, members: List[Any], size: int, is_distinct: bool
|
self, members: List[Any], size: int, is_distinct: bool
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Create a struct type with the given members and size"""
|
"""Create a struct type with the given members and size"""
|
||||||
return self.module.add_debug_info(
|
return self.module.add_debug_info(
|
||||||
@ -115,7 +117,7 @@ class DebugInfoGenerator:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def create_global_var_debug_info(
|
def create_global_var_debug_info(
|
||||||
self, name: str, var_type: Any, is_local: bool = False
|
self, name: str, var_type: Any, is_local: bool = False
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Create debug info for a global variable"""
|
"""Create debug info for a global variable"""
|
||||||
global_var = self.module.add_debug_info(
|
global_var = self.module.add_debug_info(
|
||||||
|
|||||||
Reference in New Issue
Block a user