Merge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc
authorDerek <“derek0883@gmail.com”>
Tue, 31 Jan 2017 05:16:55 +0000 (21:16 -0800)
committerDerek <“derek0883@gmail.com”>
Tue, 31 Jan 2017 05:16:55 +0000 (21:16 -0800)
1  2 
src/cc/libbpf.c
src/cc/libbpf.h

diff --cc 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
  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);