Thread (78 messages) flat view 78 messages, 7 authors, 2014-08-19

Re: [PATCH RFC v4 net-next 23/26] samples: bpf: elf file loader

From: Brendan Gregg <hidden>
Date: 2014-08-14 19:29:12
Also in: linux-api, lkml

On Wed, Aug 13, 2014 at 12:57 AM, Alexei Starovoitov [off-list ref] wrote:
[...]
+static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
+{
+       int fd, event_fd, err;
+       char fmt[32];
+       char path[256] = DEBUGFS;
+
+       fd = bpf_prog_load(BPF_PROG_TYPE_TRACING_FILTER, prog, size, license);
+
+       if (fd < 0) {
+               printf("err %d errno %d\n", fd, errno);
+               return fd;
+       }
Minor suggestion: since this is sample code, I'd always print the bpf
log after this this printf() error message:

printf("%s", bpf_log_buf);

Which has helped me debug my eBPF programs, as will be the case for
anyone hacking on the examples. Or have a function for logdie(), if
the log buffer may be populated with useful messages from other error
paths as well.

Brendan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help