From 1f356bac21a1218ec5b0fecdf30a4a2459aead81 Mon Sep 17 00:00:00 2001 From: Derek <“derek0883@gmail.com”> Date: Wed, 25 Jan 2017 18:01:16 -0800 Subject: [PATCH] rename event_name for lua --- src/lua/bcc/bpf.lua | 9 +++++++-- src/lua/bcc/libbcc.lua | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lua/bcc/bpf.lua b/src/lua/bcc/bpf.lua index 8cda252..14f69bd 100644 --- a/src/lua/bcc/bpf.lua +++ b/src/lua/bcc/bpf.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]] local ffi = require("ffi") +ffi.cdef[[ + int getpid(void); +]] + local libbcc = require("bcc.libbcc") local TracerPipe = require("bcc.tracerpipe") @@ -47,9 +51,9 @@ function Bpf.static.cleanup() log.info("detaching %s", desc) if probe_type == "kprobes" then - libbcc.bpf_detach_kprobe(desc) + libbcc.bpf_detach_kprobe(desc, key) elseif probe_type == "uprobes" then - libbcc.bpf_detach_uprobe(desc) + libbcc.bpf_detach_uprobe(desc, key) end end all_probes[key] = nil @@ -209,6 +213,7 @@ function Bpf:attach_kprobe(args) local event = args.event or "" local ptype = args.retprobe and "r" or "p" local ev_name = string.format("%s_%s", ptype, event:gsub("[%+%.]", "_")) + local ev_name = string.format("%s_bcc_%s", ev_name, ffi.C.getpid()); local desc = string.format("%s:kprobes/%s %s", ptype, ev_name, event) log.info(desc) diff --git a/src/lua/bcc/libbcc.lua b/src/lua/bcc/libbcc.lua index d744a46..5680954 100644 --- a/src/lua/bcc/libbcc.lua +++ b/src/lua/bcc/libbcc.lua @@ -42,11 +42,11 @@ typedef void (*perf_reader_raw_cb)(void *cb_cookie, void *raw, int raw_size); void * bpf_attach_kprobe(int progfd, const char *event, const char *event_desc, int pid, int cpu, int group_fd, perf_reader_cb cb, void *cb_cookie); -int bpf_detach_kprobe(const char *event_desc); +int bpf_detach_kprobe(const char *event_desc, const char *event); void * bpf_attach_uprobe(int progfd, const char *event, const char *event_desc, int pid, int cpu, int group_fd, perf_reader_cb cb, void *cb_cookie); -int bpf_detach_uprobe(const char *event_desc); +int bpf_detach_uprobe(const char *event_desc, const char *event); void * bpf_open_perf_buffer(perf_reader_raw_cb raw_cb, void *cb_cookie, int pid, int cpu); ]] -- 2.7.4