mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
correct mistake in null pointer. Also identify error in pointer to char debug info generation
This commit is contained in:
@ -78,6 +78,7 @@ def _get_field_debug_type(
|
||||
"""
|
||||
# Handle complex types (arrays, pointers)
|
||||
if field.ctype_complex_type is not None:
|
||||
print(field)
|
||||
if issubclass(field.ctype_complex_type, ctypes.Array):
|
||||
# Handle array types
|
||||
element_type, base_type_size = _get_basic_debug_type(
|
||||
@ -89,6 +90,7 @@ def _get_field_debug_type(
|
||||
elif issubclass(field.ctype_complex_type, ctypes._Pointer):
|
||||
# Handle pointer types
|
||||
pointee_type, _ = _get_basic_debug_type(field.containing_type, generator)
|
||||
print("DEBUG", pointee_type)
|
||||
return generator.create_pointer_type(pointee_type), 64
|
||||
|
||||
# Handle other vmlinux types (nested structs)
|
||||
@ -156,7 +158,6 @@ def _get_basic_debug_type(ctype, generator: DebugInfoGenerator) -> Any:
|
||||
char_type = generator.get_basic_type("char", 8, dc.DW_ATE_signed_char), 8
|
||||
return generator.create_pointer_type(char_type)
|
||||
elif ctype == ctypes.c_void_p:
|
||||
void_type = generator.module.add_debug_info("DIBasicType", {"name": "void"})
|
||||
return generator.create_pointer_type(void_type), 64
|
||||
return generator.create_pointer_type(None), 64
|
||||
else:
|
||||
return generator.get_uint64_type(), 64
|
||||
|
||||
@ -19,7 +19,7 @@ struct {
|
||||
SEC("tp/syscalls/sys_enter_setuid")
|
||||
int handle_setuid_entry(struct trace_event_raw_sys_enter *ctx) {
|
||||
struct event data = {};
|
||||
|
||||
struct blk_integrity_iter it = {};
|
||||
// Extract UID from the syscall arguments
|
||||
data.uid = (unsigned int)ctx->args[0];
|
||||
data.ts = bpf_ktime_get_ns();
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
from pythonbpf import bpf, section, bpfglobal, compile_to_ir, compile
|
||||
from vmlinux import TASK_COMM_LEN # noqa: F401
|
||||
from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
|
||||
# from vmlinux import struct_xdp_md
|
||||
# from vmlinux import struct_request
|
||||
from vmlinux import struct_blk_integrity_iter
|
||||
from ctypes import c_int64
|
||||
|
||||
|
||||
@ -24,4 +27,3 @@ def LICENSE() -> str:
|
||||
|
||||
|
||||
compile_to_ir("simple_struct_test.py", "simple_struct_test.ll")
|
||||
compile()
|
||||
|
||||
Reference in New Issue
Block a user