mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-02-12 16:10:59 +00:00
Compare commits
3 Commits
5a8b64f1d9
...
df981be095
| Author | SHA1 | Date | |
|---|---|---|---|
| df981be095 | |||
| 316c21c428 | |||
| c883d95655 |
@ -68,8 +68,6 @@ def callback(cpu, event):
|
|||||||
|
|
||||||
perf = b["events"].open_perf_buffer(callback, struct_name="data_t")
|
perf = b["events"].open_perf_buffer(callback, struct_name="data_t")
|
||||||
print("Starting to poll... (Ctrl+C to stop)")
|
print("Starting to poll... (Ctrl+C to stop)")
|
||||||
print("Try running: fork() or clone() system calls to trigger events")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
b["events"].poll(1000)
|
b["events"].poll(1000)
|
||||||
|
|||||||
@ -287,7 +287,10 @@ def get_char_array_ptr_and_size(buf_arg, builder, local_sym_tab, struct_sym_tab)
|
|||||||
|
|
||||||
field_type = struct_info.field_type(field_name)
|
field_type = struct_info.field_type(field_name)
|
||||||
if not _is_char_array(field_type):
|
if not _is_char_array(field_type):
|
||||||
raise ValueError("Expected char array field")
|
logger.info(
|
||||||
|
"Field is not a char array, falling back to int or ptr detection"
|
||||||
|
)
|
||||||
|
return None, 0
|
||||||
|
|
||||||
struct_ptr = local_sym_tab[var_name].var
|
struct_ptr = local_sym_tab[var_name].var
|
||||||
field_ptr = struct_info.gep(builder, struct_ptr, field_name)
|
field_ptr = struct_info.gep(builder, struct_ptr, field_name)
|
||||||
|
|||||||
@ -220,11 +220,12 @@ def _prepare_expr_args(expr, func, module, builder, local_sym_tab, struct_sym_ta
|
|||||||
"""Evaluate and prepare an expression to use as an arg for bpf_printk."""
|
"""Evaluate and prepare an expression to use as an arg for bpf_printk."""
|
||||||
|
|
||||||
# Special case: struct field char array needs pointer to first element
|
# Special case: struct field char array needs pointer to first element
|
||||||
char_array_ptr, _ = get_char_array_ptr_and_size(
|
if isinstance(expr, ast.Attribute):
|
||||||
expr, builder, local_sym_tab, struct_sym_tab
|
char_array_ptr, _ = get_char_array_ptr_and_size(
|
||||||
)
|
expr, builder, local_sym_tab, struct_sym_tab
|
||||||
if char_array_ptr:
|
)
|
||||||
return char_array_ptr
|
if char_array_ptr:
|
||||||
|
return char_array_ptr
|
||||||
|
|
||||||
# Regular expression evaluation
|
# Regular expression evaluation
|
||||||
val, _ = eval_expr(func, module, builder, expr, local_sym_tab, None, struct_sym_tab)
|
val, _ = eval_expr(func, module, builder, expr, local_sym_tab, None, struct_sym_tab)
|
||||||
|
|||||||
Reference in New Issue
Block a user