pub struct EbpfContext<'ctx> {Show 26 fields
pub context: &'ctx Context,
pub module: Module<'ctx>,
pub builder: Builder<'ctx>,
pub trace_printk_fn: FunctionValue<'ctx>,
pub map_manager: MapManager<'ctx>,
pub di_builder: DebugInfoBuilder<'ctx>,
pub compile_unit: DICompileUnit<'ctx>,
pub register_cache: HashMap<u16, IntValue<'ctx>>,
pub variables: HashMap<String, PointerValue<'ctx>>,
pub var_types: HashMap<String, VarType>,
pub optimized_out_vars: HashMap<String, bool>,
pub var_pc_addresses: HashMap<String, u64>,
pub variable_context: Option<VariableContext>,
pub process_analyzer: Option<*mut DwarfAnalyzer>,
pub current_trace_id: Option<u32>,
pub current_compile_time_context: Option<CompileTimeContext>,
pub trace_context: TraceContext,
pub current_resolved_var_module_path: Option<String>,
pub pm_key_alloca: Option<PointerValue<'ctx>>,
pub event_offset_alloca: Option<PointerValue<'ctx>>,
pub offsets_found_flag: Option<PointerValue<'ctx>>,
pub compile_options: CompileOptions,
pub condition_context_active: bool,
pub alias_vars: HashMap<String, Expr>,
pub string_vars: HashMap<String, Vec<u8>>,
pub scope_stack: Vec<HashSet<String>>,
}Expand description
eBPF LLVM code generation context
Fields§
§context: &'ctx Context§module: Module<'ctx>§builder: Builder<'ctx>§trace_printk_fn: FunctionValue<'ctx>§map_manager: MapManager<'ctx>§di_builder: DebugInfoBuilder<'ctx>§compile_unit: DICompileUnit<'ctx>§register_cache: HashMap<u16, IntValue<'ctx>>§variables: HashMap<String, PointerValue<'ctx>>§var_types: HashMap<String, VarType>§optimized_out_vars: HashMap<String, bool>§var_pc_addresses: HashMap<String, u64>§variable_context: Option<VariableContext>§process_analyzer: Option<*mut DwarfAnalyzer>§current_trace_id: Option<u32>§current_compile_time_context: Option<CompileTimeContext>§trace_context: TraceContext§current_resolved_var_module_path: Option<String>§pm_key_alloca: Option<PointerValue<'ctx>>§event_offset_alloca: Option<PointerValue<'ctx>>§offsets_found_flag: Option<PointerValue<'ctx>>§compile_options: CompileOptions§condition_context_active: bool§alias_vars: HashMap<String, Expr>§string_vars: HashMap<String, Vec<u8>>§scope_stack: Vec<HashSet<String>>Implementations§
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn compile_program_with_staged_transmission(
&mut self,
program: &Program,
_variable_types: HashMap<String, TypeKind>,
) -> Result<TraceContext>
pub fn compile_program_with_staged_transmission( &mut self, program: &Program, _variable_types: HashMap<String, TypeKind>, ) -> Result<TraceContext>
Main entry point: compile program with staged transmission system
Sourcepub fn compile_statement(&mut self, statement: &Statement) -> Result<u16>
pub fn compile_statement(&mut self, statement: &Statement) -> Result<u16>
Compile a statement and return the number of instructions generated
Sourcepub fn compile_print_statement(
&mut self,
print_stmt: &PrintStatement,
) -> Result<u16>
pub fn compile_print_statement( &mut self, print_stmt: &PrintStatement, ) -> Result<u16>
Compile print statement and generate LLVM IR on-demand
Sourcepub fn resolve_variable_with_priority(
&mut self,
var_name: &str,
) -> Result<(u16, TypeKind)>
pub fn resolve_variable_with_priority( &mut self, var_name: &str, ) -> Result<(u16, TypeKind)>
Resolve variable with correct priority: script variables first, then DWARF variables This method is copied from protocol.rs to maintain functionality
Sourcepub fn generate_print_string_index(&mut self, string_index: u16) -> Result<()>
pub fn generate_print_string_index(&mut self, string_index: u16) -> Result<()>
Generate eBPF code for PrintStringIndex instruction
Sourcepub fn generate_expr_error(
&mut self,
expr_string_index: u16,
error_code_iv: IntValue<'ctx>,
flags_iv: IntValue<'ctx>,
failing_addr_iv: IntValue<'ctx>,
) -> Result<()>
pub fn generate_expr_error( &mut self, expr_string_index: u16, error_code_iv: IntValue<'ctx>, flags_iv: IntValue<'ctx>, failing_addr_iv: IntValue<'ctx>, ) -> Result<()>
Generate ExprError instruction with expression string index and error code/flags
Sourcepub fn generate_print_variable_index(
&mut self,
var_name_index: u16,
type_encoding: TypeKind,
var_name: &str,
) -> Result<()>
pub fn generate_print_variable_index( &mut self, var_name_index: u16, type_encoding: TypeKind, var_name: &str, ) -> Result<()>
Generate eBPF code for PrintVariableIndex instruction
Sourcepub fn generate_backtrace_instruction(&mut self, depth: u8) -> Result<()>
pub fn generate_backtrace_instruction(&mut self, depth: u8) -> Result<()>
Generate Backtrace instruction
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn new(
context: &'ctx Context,
module_name: &str,
trace_id: Option<u32>,
compile_options: &CompileOptions,
) -> Result<Self>
pub fn new( context: &'ctx Context, module_name: &str, trace_id: Option<u32>, compile_options: &CompileOptions, ) -> Result<Self>
Create a new eBPF code generation context
Sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Enter a new lexical scope
Sourcepub fn exit_scope(&mut self)
pub fn exit_scope(&mut self)
Exit current lexical scope and drop all names declared within
Sourcepub fn is_name_in_any_scope(&self, name: &str) -> bool
pub fn is_name_in_any_scope(&self, name: &str) -> bool
Check if a name exists in any active scope
Sourcepub fn is_name_in_current_scope(&self, name: &str) -> bool
pub fn is_name_in_current_scope(&self, name: &str) -> bool
Check if a name exists in current (top) scope
Sourcepub fn declare_name_in_current_scope(&mut self, name: &str) -> Result<()>
pub fn declare_name_in_current_scope(&mut self, name: &str) -> Result<()>
Declare a name in the current scope. Disallow same-scope redeclaration and shadowing.
Sourcepub fn new_with_process_analyzer(
context: &'ctx Context,
module_name: &str,
process_analyzer: Option<&mut DwarfAnalyzer>,
trace_id: Option<u32>,
compile_options: &CompileOptions,
) -> Result<Self>
pub fn new_with_process_analyzer( context: &'ctx Context, module_name: &str, process_analyzer: Option<&mut DwarfAnalyzer>, trace_id: Option<u32>, compile_options: &CompileOptions, ) -> Result<Self>
Create a new code generator with DWARF analyzer support
Sourcepub fn set_compile_time_context(&mut self, pc_address: u64, module_path: String)
pub fn set_compile_time_context(&mut self, pc_address: u64, module_path: String)
Set compile-time context for DWARF queries
Sourcepub fn get_compile_time_context(&self) -> Result<&CompileTimeContext>
pub fn get_compile_time_context(&self) -> Result<&CompileTimeContext>
Get compile-time context for DWARF queries
Sourcepub fn take_module_hint(&mut self) -> Option<String>
pub fn take_module_hint(&mut self) -> Option<String>
Take and clear the current module hint for offsets (if any)
Sourcepub fn create_basic_ebpf_function(&mut self, function_name: &str) -> Result<()>
pub fn create_basic_ebpf_function(&mut self, function_name: &str) -> Result<()>
Create basic eBPF function with proper signature
Sourcepub fn get_module(&self) -> &Module<'ctx>
pub fn get_module(&self) -> &Module<'ctx>
Get the LLVM module reference
Sourcepub fn get_trace_context(&self) -> TraceContext
pub fn get_trace_context(&self) -> TraceContext
Get the string table after compilation
Sourcepub fn get_pt_regs_parameter(&self) -> Result<PointerValue<'ctx>>
pub fn get_pt_regs_parameter(&self) -> Result<PointerValue<'ctx>>
Get pt_regs parameter from current function
Sourcepub fn compile_program(
&mut self,
_program: &Program,
function_name: &str,
trace_statements: &[Statement],
target_pid: Option<u32>,
compile_time_pc: Option<u64>,
module_path: Option<&str>,
) -> Result<(FunctionValue<'ctx>, TraceContext)>
pub fn compile_program( &mut self, _program: &Program, function_name: &str, trace_statements: &[Statement], target_pid: Option<u32>, compile_time_pc: Option<u64>, module_path: Option<&str>, ) -> Result<(FunctionValue<'ctx>, TraceContext)>
Compile a complete program with statements
Sourcepub fn get_or_create_flag_global(&mut self, name: &str) -> PointerValue<'ctx>
pub fn get_or_create_flag_global(&mut self, name: &str) -> PointerValue<'ctx>
Get or create a global i8 flag by name, initialized to 0
Sourcepub fn store_flag_value(&mut self, name: &str, value: u8) -> Result<()>
pub fn store_flag_value(&mut self, name: &str, value: u8) -> Result<()>
Set a flag global to a constant u8 value at runtime
Sourcepub fn mark_any_success(&mut self) -> Result<()>
pub fn mark_any_success(&mut self) -> Result<()>
Mark that at least one variable succeeded (status==0)
Sourcepub fn mark_any_fail(&mut self) -> Result<()>
pub fn mark_any_fail(&mut self) -> Result<()>
Mark that at least one variable failed (status!=0)
Sourcepub fn get_or_create_offsets_found_flag(&mut self) -> PointerValue<'ctx>
pub fn get_or_create_offsets_found_flag(&mut self) -> PointerValue<'ctx>
Get (and create if needed) the global flag tracking the last proc_module_offsets lookup. Stored as i8 where 0 = miss, 1 = found.
Sourcepub fn store_offsets_found_flag(&mut self, flag: IntValue<'ctx>) -> Result<()>
pub fn store_offsets_found_flag(&mut self, flag: IntValue<'ctx>) -> Result<()>
Store a boolean into the offsets-found flag (true => found, false => miss).
Sourcepub fn store_offsets_found_const(&mut self, value: bool) -> Result<()>
pub fn store_offsets_found_const(&mut self, value: bool) -> Result<()>
Store a constant boolean value into the offsets-found flag.
Sourcepub fn load_offsets_found_flag(&mut self) -> Result<IntValue<'ctx>>
pub fn load_offsets_found_flag(&mut self) -> Result<IntValue<'ctx>>
Load the current offsets-found flag as i1 (true => found, false => miss).
Sourcepub fn get_or_create_cond_error_global(&mut self) -> PointerValue<'ctx>
pub fn get_or_create_cond_error_global(&mut self) -> PointerValue<'ctx>
Get or create global for condition error code (i8). Name: _gs_cond_error
Sourcepub fn reset_condition_error(&mut self) -> Result<()>
pub fn reset_condition_error(&mut self) -> Result<()>
Reset condition error to 0 (only meaningful when condition_context_active=true)
Sourcepub fn get_or_create_cond_error_addr_global(&mut self) -> PointerValue<'ctx>
pub fn get_or_create_cond_error_addr_global(&mut self) -> PointerValue<'ctx>
Get or create global for condition error address (i64). Name: _gs_cond_error_addr
Sourcepub fn set_condition_error_if_unset(&mut self, code: u8) -> Result<()>
pub fn set_condition_error_if_unset(&mut self, code: u8) -> Result<()>
If in condition context, set error code when it’s currently 0 (first error wins)
Sourcepub fn build_condition_error_predicate(&mut self) -> Result<IntValue<'ctx>>
pub fn build_condition_error_predicate(&mut self) -> Result<IntValue<'ctx>>
Read the current condition error as i1 predicate: (error != 0)
Sourcepub fn get_or_create_cond_error_flags_global(&mut self) -> PointerValue<'ctx>
pub fn get_or_create_cond_error_flags_global(&mut self) -> PointerValue<'ctx>
Get or create global for condition error flags (i8). Name: _gs_cond_error_flags
Sourcepub fn or_condition_error_flags(&mut self, flags: IntValue<'ctx>) -> Result<()>
pub fn or_condition_error_flags(&mut self, flags: IntValue<'ctx>) -> Result<()>
OR into condition error flags (BV must be i8)
Sourcepub fn set_condition_error_addr_if_unset(
&mut self,
addr: IntValue<'ctx>,
) -> Result<()>
pub fn set_condition_error_addr_if_unset( &mut self, addr: IntValue<'ctx>, ) -> Result<()>
If in condition context, record failing address (first win). addr must be i64
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn evaluate_result_to_llvm_value(
&mut self,
evaluation_result: &EvaluationResult,
dwarf_type: &TypeInfo,
var_name: &str,
pc_address: u64,
) -> Result<BasicValueEnum<'ctx>>
pub fn evaluate_result_to_llvm_value( &mut self, evaluation_result: &EvaluationResult, dwarf_type: &TypeInfo, var_name: &str, pc_address: u64, ) -> Result<BasicValueEnum<'ctx>>
Convert EvaluationResult to LLVM value
Sourcepub fn evaluation_result_to_address_with_hint(
&mut self,
evaluation_result: &EvaluationResult,
status_ptr: Option<PointerValue<'ctx>>,
module_hint: Option<&str>,
) -> Result<IntValue<'ctx>>
pub fn evaluation_result_to_address_with_hint( &mut self, evaluation_result: &EvaluationResult, status_ptr: Option<PointerValue<'ctx>>, module_hint: Option<&str>, ) -> Result<IntValue<'ctx>>
Variant that allows passing an explicit module hint for offsets lookup
Sourcepub fn query_dwarf_for_complex_expr(
&mut self,
expr: &Expr,
) -> Result<Option<VariableWithEvaluation>>
pub fn query_dwarf_for_complex_expr( &mut self, expr: &Expr, ) -> Result<Option<VariableWithEvaluation>>
Query DWARF for complex expression (supports member access, array access, etc.)
Sourcepub fn query_dwarf_for_variable(
&mut self,
var_name: &str,
) -> Result<Option<VariableWithEvaluation>>
pub fn query_dwarf_for_variable( &mut self, var_name: &str, ) -> Result<Option<VariableWithEvaluation>>
Query DWARF for variable information
Sourcepub fn get_dwarf_type_size(dwarf_type: &TypeInfo) -> u64
pub fn get_dwarf_type_size(dwarf_type: &TypeInfo) -> u64
Get DWARF type size in bytes
Sourcepub fn query_dwarf_for_member_access(
&mut self,
obj_expr: &Expr,
field_name: &str,
) -> Result<Option<VariableWithEvaluation>>
pub fn query_dwarf_for_member_access( &mut self, obj_expr: &Expr, field_name: &str, ) -> Result<Option<VariableWithEvaluation>>
Query DWARF for member access (obj.field)
Sourcepub fn query_dwarf_for_array_access(
&mut self,
array_expr: &Expr,
index_expr: &Expr,
) -> Result<Option<VariableWithEvaluation>>
pub fn query_dwarf_for_array_access( &mut self, array_expr: &Expr, index_expr: &Expr, ) -> Result<Option<VariableWithEvaluation>>
Query DWARF for array access (arr[index])
Sourcepub fn query_dwarf_for_chain_access(
&mut self,
chain: &[String],
) -> Result<Option<VariableWithEvaluation>>
pub fn query_dwarf_for_chain_access( &mut self, chain: &[String], ) -> Result<Option<VariableWithEvaluation>>
Query DWARF for chain access (person.name.first)
Sourcepub fn query_dwarf_for_pointer_deref(
&mut self,
expr: &Expr,
) -> Result<Option<VariableWithEvaluation>>
pub fn query_dwarf_for_pointer_deref( &mut self, expr: &Expr, ) -> Result<Option<VariableWithEvaluation>>
Query DWARF for pointer dereference (*ptr)
Sourcepub fn compute_pointed_location_with_index(
&mut self,
ptr_expr: &Expr,
index: i64,
) -> Result<(EvaluationResult, TypeInfo)>
pub fn compute_pointed_location_with_index( &mut self, ptr_expr: &Expr, index: i64, ) -> Result<(EvaluationResult, TypeInfo)>
Compute a typed pointed-to location for expressions like ptr +/- K where K is an element index.
Returns a computed location EvaluationResult along with the pointed-to DWARF type.
The offset is scaled by the element size of the pointer/array target type.
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn compile_expr(&mut self, expr: &Expr) -> Result<BasicValueEnum<'ctx>>
pub fn compile_expr(&mut self, expr: &Expr) -> Result<BasicValueEnum<'ctx>>
Compile an expression
Sourcepub fn handle_special_variable(
&mut self,
name: &str,
) -> Result<BasicValueEnum<'ctx>>
pub fn handle_special_variable( &mut self, name: &str, ) -> Result<BasicValueEnum<'ctx>>
Handle special variables like $pid, $tid, etc.
Sourcepub fn compile_binary_op(
&mut self,
left: BasicValueEnum<'ctx>,
op: BinaryOp,
right: BasicValueEnum<'ctx>,
) -> Result<BasicValueEnum<'ctx>>
pub fn compile_binary_op( &mut self, left: BasicValueEnum<'ctx>, op: BinaryOp, right: BasicValueEnum<'ctx>, ) -> Result<BasicValueEnum<'ctx>>
Compile binary operations
Sourcepub fn compile_member_access(
&mut self,
obj_expr: &Expr,
field: &str,
) -> Result<BasicValueEnum<'ctx>>
pub fn compile_member_access( &mut self, obj_expr: &Expr, field: &str, ) -> Result<BasicValueEnum<'ctx>>
Compile member access (struct.field)
Sourcepub fn compile_pointer_deref(
&mut self,
expr: &Expr,
) -> Result<BasicValueEnum<'ctx>>
pub fn compile_pointer_deref( &mut self, expr: &Expr, ) -> Result<BasicValueEnum<'ctx>>
Compile pointer dereference (*ptr)
Sourcepub fn compile_array_access(
&mut self,
array_expr: &Expr,
index_expr: &Expr,
) -> Result<BasicValueEnum<'ctx>>
pub fn compile_array_access( &mut self, array_expr: &Expr, index_expr: &Expr, ) -> Result<BasicValueEnum<'ctx>>
Compile array access (arr[index])
Sourcepub fn compile_chain_access(
&mut self,
chain: &[String],
) -> Result<BasicValueEnum<'ctx>>
pub fn compile_chain_access( &mut self, chain: &[String], ) -> Result<BasicValueEnum<'ctx>>
Compile chain access (person.name.first)
Sourcepub fn compile_dwarf_expression(
&mut self,
expr: &Expr,
) -> Result<BasicValueEnum<'ctx>>
pub fn compile_dwarf_expression( &mut self, expr: &Expr, ) -> Result<BasicValueEnum<'ctx>>
Unified DWARF expression compilation
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn get_or_create_i8_buffer(
&mut self,
size: u32,
name_prefix: &str,
) -> (ArrayType<'ctx>, PointerValue<'ctx>)
pub fn get_or_create_i8_buffer( &mut self, size: u32, name_prefix: &str, ) -> (ArrayType<'ctx>, PointerValue<'ctx>)
Get or create a static i8 buffer global of a given size, returning its ArrayType and pointer
Sourcepub fn read_user_cstr_into_buffer(
&mut self,
src_addr: IntValue<'ctx>,
size: u32,
name_prefix: &str,
) -> Result<(PointerValue<'ctx>, IntValue<'ctx>, ArrayType<'ctx>)>
pub fn read_user_cstr_into_buffer( &mut self, src_addr: IntValue<'ctx>, size: u32, name_prefix: &str, ) -> Result<(PointerValue<'ctx>, IntValue<'ctx>, ArrayType<'ctx>)>
Read a user C-string into a static buffer using bpf_probe_read_user_str. Returns (buffer_ptr, len_including_nul).
Sourcepub fn read_user_bytes_into_buffer(
&mut self,
src_addr: IntValue<'ctx>,
size: u32,
name_prefix: &str,
) -> Result<(PointerValue<'ctx>, IntValue<'ctx>, ArrayType<'ctx>)>
pub fn read_user_bytes_into_buffer( &mut self, src_addr: IntValue<'ctx>, size: u32, name_prefix: &str, ) -> Result<(PointerValue<'ctx>, IntValue<'ctx>, ArrayType<'ctx>)>
Read raw user bytes into a static buffer using bpf_probe_read_user. Returns (buffer_ptr, status==0?).
Sourcepub fn generate_runtime_address_from_offsets(
&mut self,
link_addr: IntValue<'ctx>,
section_type: u8,
module_cookie: u64,
) -> Result<(IntValue<'ctx>, IntValue<'ctx>)>
pub fn generate_runtime_address_from_offsets( &mut self, link_addr: IntValue<'ctx>, section_type: u8, module_cookie: u64, ) -> Result<(IntValue<'ctx>, IntValue<'ctx>)>
Compute runtime address from link-time address using proc_module_offsets map section_type: 0=text, 1=rodata, 2=data, 3=bss; other values fallback to data
Sourcepub fn load_register_value(
&mut self,
reg_num: u16,
pt_regs_ptr: PointerValue<'ctx>,
) -> Result<BasicValueEnum<'ctx>>
pub fn load_register_value( &mut self, reg_num: u16, pt_regs_ptr: PointerValue<'ctx>, ) -> Result<BasicValueEnum<'ctx>>
Load a register value from pt_regs
Sourcepub fn generate_memory_read(
&mut self,
addr: IntValue<'ctx>,
size: MemoryAccessSize,
) -> Result<BasicValueEnum<'ctx>>
pub fn generate_memory_read( &mut self, addr: IntValue<'ctx>, size: MemoryAccessSize, ) -> Result<BasicValueEnum<'ctx>>
Generate memory read using bpf_probe_read_user
Sourcepub fn generate_memory_read_with_status(
&mut self,
addr: IntValue<'ctx>,
size: MemoryAccessSize,
) -> Result<BasicValueEnum<'ctx>>
pub fn generate_memory_read_with_status( &mut self, addr: IntValue<'ctx>, size: MemoryAccessSize, ) -> Result<BasicValueEnum<'ctx>>
Generate memory read with runtime status capture (for control-flow conditions). On helper failure, sets condition error code (if active) and returns zero value.
Sourcepub fn dwarf_reg_to_pt_regs_offset(&self, dwarf_reg: u16) -> Result<usize>
pub fn dwarf_reg_to_pt_regs_offset(&self, dwarf_reg: u16) -> Result<usize>
Map DWARF register number to pt_regs offset (simplified)
Sourcepub fn create_bpf_helper_call(
&mut self,
helper_id: u64,
args: &[BasicValueEnum<'ctx>],
return_type: BasicTypeEnum<'ctx>,
call_name: &str,
) -> Result<BasicValueEnum<'ctx>>
pub fn create_bpf_helper_call( &mut self, helper_id: u64, args: &[BasicValueEnum<'ctx>], return_type: BasicTypeEnum<'ctx>, call_name: &str, ) -> Result<BasicValueEnum<'ctx>>
Create eBPF helper call using the correct calling convention This creates an indirect call through the eBPF helper mechanism
Sourcepub fn get_current_timestamp(&mut self) -> Result<IntValue<'ctx>>
pub fn get_current_timestamp(&mut self) -> Result<IntValue<'ctx>>
Get current timestamp using bpf_ktime_get_ns
Sourcepub fn get_current_pid_tgid(&mut self) -> Result<IntValue<'ctx>>
pub fn get_current_pid_tgid(&mut self) -> Result<IntValue<'ctx>>
Get current PID/TID using bpf_get_current_pid_tgid
Sourcepub fn create_event_output(
&mut self,
data: PointerValue<'ctx>,
size: u64,
) -> Result<()>
pub fn create_event_output( &mut self, data: PointerValue<'ctx>, size: u64, ) -> Result<()>
Create event output using either RingBuf or PerfEventArray based on compile options This is the unified interface that should be used for all event output
Sourcepub fn create_ringbuf_output_dynamic(
&mut self,
data: PointerValue<'ctx>,
size: IntValue<'ctx>,
) -> Result<()>
pub fn create_ringbuf_output_dynamic( &mut self, data: PointerValue<'ctx>, size: IntValue<'ctx>, ) -> Result<()>
Create ringbuf output with dynamic size (IntValue)
Sourcepub fn lookup_percpu_value_ptr(
&mut self,
map_name: &str,
key_const: u32,
) -> Result<PointerValue<'ctx>>
pub fn lookup_percpu_value_ptr( &mut self, map_name: &str, key_const: u32, ) -> Result<PointerValue<'ctx>>
Lookup per-CPU map value pointer for a given map name and u32 key constant
Sourcepub fn create_perf_event_output_dynamic(
&mut self,
data: PointerValue<'ctx>,
size: IntValue<'ctx>,
) -> Result<()>
pub fn create_perf_event_output_dynamic( &mut self, data: PointerValue<'ctx>, size: IntValue<'ctx>, ) -> Result<()>
Create perf event output with dynamic size (IntValue)
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn send_trace_event_header(&mut self) -> Result<()>
pub fn send_trace_event_header(&mut self) -> Result<()>
Send TraceEventHeader as first segment
Sourcepub fn send_trace_event_message(&mut self, trace_id: u64) -> Result<()>
pub fn send_trace_event_message(&mut self, trace_id: u64) -> Result<()>
Send TraceEventMessage as second segment
Sourcepub fn send_end_instruction(&mut self, total_instructions: u16) -> Result<()>
pub fn send_end_instruction(&mut self, total_instructions: u16) -> Result<()>
Send EndInstruction as final segment
Source§impl<'ctx> EbpfContext<'ctx>
impl<'ctx> EbpfContext<'ctx>
Sourcepub fn set_alias_variable(&mut self, name: &str, expr: Expr)
pub fn set_alias_variable(&mut self, name: &str, expr: Expr)
Register a DWARF alias variable. The value expression is stored and resolved at use time.
Sourcepub fn alias_variable_exists(&self, name: &str) -> bool
pub fn alias_variable_exists(&self, name: &str) -> bool
Check whether an alias variable exists
Sourcepub fn get_alias_variable(&self, name: &str) -> Option<Expr>
pub fn get_alias_variable(&self, name: &str) -> Option<Expr>
Get a clone of the stored alias expression if present
Sourcepub fn store_variable(
&mut self,
name: &str,
value: BasicValueEnum<'ctx>,
) -> Result<()>
pub fn store_variable( &mut self, name: &str, value: BasicValueEnum<'ctx>, ) -> Result<()>
Store a variable value
Sourcepub fn load_variable(&mut self, name: &str) -> Result<BasicValueEnum<'ctx>>
pub fn load_variable(&mut self, name: &str) -> Result<BasicValueEnum<'ctx>>
Retrieve a variable value
Sourcepub fn variable_exists(&self, name: &str) -> bool
pub fn variable_exists(&self, name: &str) -> bool
Check if a variable exists in the current scope
Sourcepub fn get_variable_type(&self, name: &str) -> Option<&VarType>
pub fn get_variable_type(&self, name: &str) -> Option<&VarType>
Get variable type
Sourcepub fn clear_variables(&mut self)
pub fn clear_variables(&mut self)
Clear all variables (for new scope)
Sourcepub fn set_string_variable_bytes(&mut self, name: &str, bytes: Vec<u8>)
pub fn set_string_variable_bytes(&mut self, name: &str, bytes: Vec<u8>)
Register a string variable’s bytes (including optional NUL terminator)
Auto Trait Implementations§
impl<'ctx> !Freeze for EbpfContext<'ctx>
impl<'ctx> !RefUnwindSafe for EbpfContext<'ctx>
impl<'ctx> !Send for EbpfContext<'ctx>
impl<'ctx> !Sync for EbpfContext<'ctx>
impl<'ctx> Unpin for EbpfContext<'ctx>
impl<'ctx> UnwindSafe for EbpfContext<'ctx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more