local ffi = require("ffi")
return function(BPF)
- local b = BPF:new{src_file="bashreadline.c", debug=true}
+ local b = BPF:new{src_file="bashreadline.c", debug=0}
b:attach_uprobe{name="/bin/bash", sym="readline", fn_name="printret", retprobe=true}
local function print_readline(cpu, event)
text = text:gsub("SHOULD_PRINT", args.trace and "1" or "0")
text = text:gsub("SAMPLE_EVERY_N", tostring(args.sample_rate))
- local bpf = BPF:new{text=text, debug=true}
+ local bpf = BPF:new{text=text, debug=0}
local syms = nil
local min_age_ns = args.older * 1e6
Bpf.static.process_symbols = {}
Bpf.static.KPROBE_LIMIT = 1000
Bpf.static.tracer_pipe = nil
+Bpf.static.DEFAULT_CFLAGS = {
+ '-D__HAVE_BUILTIN_BSWAP16__',
+ '-D__HAVE_BUILTIN_BSWAP32__',
+ '-D__HAVE_BUILTIN_BSWAP64__',
+}
function Bpf.static.check_probe_quota(n)
local cur = table.count(Bpf.static.open_kprobes) + table.count(Bpf.static.open_uprobes)
self.funcs = {}
self.tables = {}
+ local cflags = table.join(Bpf.DEFAULT_CFLAGS, args.cflags)
+ local cflags_ary = ffi.new("const char *[?]", #cflags, cflags)
+
+ local llvm_debug = args.debug or 0
+ assert(type(llvm_debug) == "number")
+
if args.text then
log.info("\n%s\n", args.text)
- self.module = libbcc.bpf_module_create_c_from_string(args.text, args.llvm_debug or 0, nil, 0)
+ self.module = libbcc.bpf_module_create_c_from_string(args.text, llvm_debug, cflags_ary, #cflags)
elseif args.src_file then
local src = _find_file(Bpf.SCRIPT_ROOT, args.src_file)
if src:ends(".b") then
local hdr = _find_file(Bpf.SCRIPT_ROOT, args.hdr_file)
- self.module = libbcc.bpf_module_create_b(src, hdr, args.llvm_debug or 0)
+ self.module = libbcc.bpf_module_create_b(src, hdr, llvm_debug)
else
- self.module = libbcc.bpf_module_create_c(src, args.llvm_debug or 0, nil, 0)
+ self.module = libbcc.bpf_module_create_c(src, llvm_debug, cflags_ary, #cflags)
end
end
return nil
end
+function table.join(a, b)
+ assert(a)
+ if b == nil or #b == 0 then
+ return a
+ end
+
+ local res = {}
+ for _, v in ipairs(a) do
+ table.insert(res, v)
+ end
+ for _, v in ipairs(b) do
+ table.insert(res, v)
+ end
+ return res
+end
+
function table.build(iterator_fn, build_fn)
build_fn = (build_fn or function(arg) return arg end)
local res = {}