From: Derek <“derek0883@gmail.com”> Date: Tue, 31 Jan 2017 05:16:55 +0000 (-0800) Subject: Merge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc X-Git-Tag: v0.3.0~66^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be0d60b45cb722c1aa914855c52d730e4f10021c;p=platform%2Fupstream%2Fbcc.git Merge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc --- be0d60b45cb722c1aa914855c52d730e4f10021c diff --cc src/cc/libbpf.c index d8caf69,d7ca6d6..d6bc3bc --- a/src/cc/libbpf.c +++ b/src/cc/libbpf.c @@@ -362,7 -361,7 +362,7 @@@ void * bpf_attach_kprobe(int progfd, en goto error; } -- snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r', ++ snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==probe_entry ? 'p' : 'r', event_type, new_name, fn_name); if (write(kfd, buf, strlen(buf)) < 0) { if (errno == EINVAL) @@@ -420,12 -419,8 +420,12 @@@ void * bpf_attach_uprobe(int progfd, en goto error; } - n = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r', - snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r', ++ n = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==probe_entry ? 'p' : 'r', event_type, new_name, binary_path, offset); + if (n >= sizeof(buf)) { + close(kfd); + goto error; + } if (write(kfd, buf, strlen(buf)) < 0) { if (errno == EINVAL) fprintf(stderr, "check dmesg output for possible cause\n"); diff --cc src/cc/libbpf.h index 34787b6,fdc5fcf..31b2451 --- a/src/cc/libbpf.h +++ b/src/cc/libbpf.h @@@ -24,12 -24,8 +24,10 @@@ extern "C" { #endif -#define BPF_PROBE_ENTRY 0 -#define BPF_PROBE_RETURN 1 +enum bpf_probe_attach_type { + probe_entry, + probe_return +}; - #define BPF_PROBE_ENTRY 0 - #define BPF_PROBE_RETURN 1 int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size, int max_entries, int map_flags); @@@ -51,15 -47,15 +49,15 @@@ typedef void (*perf_reader_cb)(void *cb void *callchain); typedef void (*perf_reader_raw_cb)(void *cb_cookie, void *raw, int raw_size); - void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, const char *ev_name, -void * bpf_attach_kprobe(int progfd, int attach_type, const char *ev_name, -- const char *fn_name, ++void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, ++ const char *ev_name, const char *fn_name, pid_t pid, int cpu, int group_fd, perf_reader_cb cb, void *cb_cookie); int bpf_detach_kprobe(const char *ev_name); - void * bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type, const char *ev_name, -void * bpf_attach_uprobe(int progfd, int attach_type, const char *ev_name, -- const char *binary_path, uint64_t offset, ++void * bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type, ++ const char *ev_name, const char *binary_path, uint64_t offset, pid_t pid, int cpu, int group_fd, perf_reader_cb cb, void *cb_cookie);