Skip to content

Commit

Permalink
Merge pull request iovisor#1702 from iovisor/yhs_dev
Browse files Browse the repository at this point in the history
print out more useful attach_kprobe failure information
  • Loading branch information
4ast committed Apr 24, 2018
2 parents a4782bd + 858a3d7 commit 435dded
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cc/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,10 @@ int bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type,
snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
event_type, event_alias, fn_name);
if (write(kfd, buf, strlen(buf)) < 0) {
if (errno == EINVAL)
fprintf(stderr, "check dmesg output for possible cause\n");
if (errno == ENOENT)
fprintf(stderr, "cannot attach kprobe, probe entry may not exist\n");
else
fprintf(stderr, "cannot attach kprobe, %s\n", strerror(errno));
close(kfd);
goto error;
}
Expand Down

0 comments on commit 435dded

Please sign in to comment.