mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Merge pull request #18 from pythonbpf/fix-maps
Fix map calling convention
This commit is contained in:
@ -21,17 +21,17 @@ def last() -> HashMap:
|
|||||||
@section("tracepoint/syscalls/sys_enter_sync")
|
@section("tracepoint/syscalls/sys_enter_sync")
|
||||||
def do_trace(ctx: c_void_p) -> c_int64:
|
def do_trace(ctx: c_void_p) -> c_int64:
|
||||||
key = 0
|
key = 0
|
||||||
tsp = last().lookup(key)
|
tsp = last.lookup(key)
|
||||||
if tsp:
|
if tsp:
|
||||||
kt = ktime()
|
kt = ktime()
|
||||||
delta = kt - tsp
|
delta = kt - tsp
|
||||||
if delta < 1000000000:
|
if delta < 1000000000:
|
||||||
time_ms = delta // 1000000
|
time_ms = delta // 1000000
|
||||||
print(f"sync called within last second, last {time_ms} ms ago")
|
print(f"sync called within last second, last {time_ms} ms ago")
|
||||||
last().delete(key)
|
last.delete(key)
|
||||||
else:
|
else:
|
||||||
kt = ktime()
|
kt = ktime()
|
||||||
last().update(key, kt)
|
last.update(key, kt)
|
||||||
return c_int64(0)
|
return c_int64(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -192,8 +192,23 @@ def handle_assign(
|
|||||||
elif isinstance(rval.func, ast.Attribute):
|
elif isinstance(rval.func, ast.Attribute):
|
||||||
logger.info(f"Assignment call attribute: {ast.dump(rval.func)}")
|
logger.info(f"Assignment call attribute: {ast.dump(rval.func)}")
|
||||||
if isinstance(rval.func.value, ast.Name):
|
if isinstance(rval.func.value, ast.Name):
|
||||||
# TODO: probably a struct access
|
if rval.func.value.id in map_sym_tab:
|
||||||
logger.info(f"TODO STRUCT ACCESS {ast.dump(rval)}")
|
map_name = rval.func.value.id
|
||||||
|
method_name = rval.func.attr
|
||||||
|
if HelperHandlerRegistry.has_handler(method_name):
|
||||||
|
val = handle_helper_call(
|
||||||
|
rval,
|
||||||
|
module,
|
||||||
|
builder,
|
||||||
|
func,
|
||||||
|
local_sym_tab,
|
||||||
|
map_sym_tab,
|
||||||
|
structs_sym_tab,
|
||||||
|
)
|
||||||
|
builder.store(val[0], local_sym_tab[var_name].var)
|
||||||
|
else:
|
||||||
|
# TODO: probably a struct access
|
||||||
|
logger.info(f"TODO STRUCT ACCESS {ast.dump(rval)}")
|
||||||
elif isinstance(rval.func.value, ast.Call) and isinstance(
|
elif isinstance(rval.func.value, ast.Call) and isinstance(
|
||||||
rval.func.value.func, ast.Name
|
rval.func.value.func, ast.Name
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user