add dependency debug info list

This commit is contained in:
2025-10-18 03:27:26 +05:30
parent 51a1be0b0b
commit 9b7aa6d8be
3 changed files with 62 additions and 6 deletions

View File

@ -1,10 +1,14 @@
from pythonbpf.debuginfo import DebugInfoGenerator
from ..dependency_node import DependencyNode
def debug_info_generation(struct, llvm_module):
def debug_info_generation(
struct: DependencyNode, llvm_module, generated_debug_info: list
):
generator = DebugInfoGenerator(llvm_module)
# this is sample debug info generation
# i64type = generator.get_uint64_type()
print("DEBUG1", generated_debug_info)
for field in struct.fields:
print("DEBUG", field)
struct_type = generator.create_struct_type([], 64 * 4, is_distinct=True)

View File

@ -14,6 +14,7 @@ class IRGenerator:
self.llvm_module = llvm_module
self.handler: DependencyHandler = handler
self.generated: list[str] = []
self.generated_debug_info: list = []
if not handler.is_ready:
raise ImportError(
"Semantic analysis of vmlinux imports failed. Cannot generate IR"
@ -67,18 +68,22 @@ class IRGenerator:
)
# Actual processor logic here after dependencies are resolved
self.gen_ir(struct)
self.generated_debug_info.append(
(struct, self.gen_ir(struct, self.generated_debug_info))
)
self.generated.append(struct.name)
finally:
# Remove from processing stack after we're done
processing_stack.discard(struct.name)
def gen_ir(self, struct):
def gen_ir(self, struct, generated_debug_info):
# TODO: we add the btf_ama attribute by monkey patching in the end of compilation, but once llvmlite
# accepts our issue, we will resort to normal accessed attribute based attribute addition
# currently we generate all possible field accesses for CO-RE and put into the assignment table
debug_info = debug_info_generation(struct, self.llvm_module)
debug_info = debug_info_generation(
struct, self.llvm_module, generated_debug_info
)
field_index = 0
for field_name, field in struct.fields.items():
# does not take arrays and similar types into consideration yet.
@ -126,6 +131,7 @@ class IRGenerator:
)
globvar.linkage = "external"
globvar.set_metadata("llvm.preserve.access.index", debug_info)
return debug_info
def _struct_name_generator(
self,