Skip to content

Commit

Permalink
lua: Allow LuaJIT parameterized types in open_perf_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
vmg committed May 24, 2016
1 parent 9bbe58f commit 973a528
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lua/bcc/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions tools/stacksnoop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 973a528

Please sign in to comment.