Commit 973a528d authored by Vicent Marti's avatar Vicent Marti

lua: Allow LuaJIT parameterized types in `open_perf_buffer`

parent 9bbe58f9
......@@ -254,9 +254,9 @@ function PerfEventArray:_open_perf_buffer(cpu, callback, ctype)
self._callbacks[cpu] = _cb
end
function PerfEventArray:open_perf_buffer(callback, data_type)
function PerfEventArray:open_perf_buffer(callback, data_type, ...)
assert(data_type, "a data type is needed for callback conversion")
local ctype = ffi.typeof(data_type.."*")
local ctype = ffi.typeof(data_type.."*", ...)
for i = 0, Posix.cpu_count() - 1 do
self:_open_perf_buffer(i, callback, ctype)
end
......
......@@ -100,12 +100,8 @@ return function(BPF, utils)
local TASK_COMM_LEN = 16 -- linux/sched.h
bpf:get_table("events"):open_perf_buffer(print_event, [[
struct {
uint64_t stack_id;
uint32_t pid;
char comm[%d];
}
]] % {TASK_COMM_LEN})
bpf:get_table("events"):open_perf_buffer(print_event,
"struct { uint64_t stack_id; uint32_t pid; char comm[$]; }",
TASK_COMM_LEN)
bpf:kprobe_poll_loop()
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment