function Bpf:attach_uprobe(args)
Bpf.check_probe_quota(1)
- local path, addr = Sym.check_path_symbol(args.name, args.sym, args.addr)
+ local path, addr = Sym.check_path_symbol(args.name, args.sym, args.addr, args.pid)
local fn = self:load_func(args.fn_name, 'BPF_PROG_TYPE_KPROBE')
local ptype = args.retprobe and "r" or "p"
local ev_name = string.format("%s_%s_0x%p", ptype, path:gsub("[^%a%d]", "_"), addr)
}
end
-local function check_path_symbol(module, symname, addr)
+local function check_path_symbol(module, symname, addr, pid)
local sym = SYM()
local module_path
- if libbcc.bcc_resolve_symname(module, symname, addr or 0x0, 0, sym) < 0 then
+ if libbcc.bcc_resolve_symname(module, symname, addr or 0x0, pid or 0, sym) < 0 then
if sym[0].module == nil then
error("could not find library '%s' in the library path" % module)
else
local text = text:gsub("PID", tostring(pid))
local b = BPF:new{text=text}
- b:attach_uprobe{name="c", sym="malloc_stats", fn_name="count"}
- b:attach_uprobe{name="c", sym="malloc_stats", fn_name="count", retprobe=true}
+ b:attach_uprobe{name="c", sym="malloc_stats", fn_name="count", pid=pid}
+ b:attach_uprobe{name="c", sym="malloc_stats", fn_name="count", pid=pid, retprobe=true}
assert_equals(BPF.num_open_uprobes(), 2)