Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-21 Thread Jakub Kicinski
On Mon, 21 Oct 2019 16:02:27 +0200, Jiri Olsa wrote: > > > static int do_dump(int argc, char **argv) > > > { > > > struct btf *btf = NULL; > > > @@ -397,7 +429,7 @@ static int do_dump(int argc, char **argv) > > > __u32 btf_id = -1; > > > const char *src; > > > int fd = -1; > > > - int err

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-21 Thread Jiri Olsa
On Fri, Oct 18, 2019 at 03:39:05PM -0700, Jakub Kicinski wrote: > On Fri, 18 Oct 2019 12:34:04 +0200, Jiri Olsa wrote: > > The bpftool interface stays the same, but now it's possible > > to run it over BTF raw data, like: > > > > $ bpftool btf dump file /sys/kernel/btf/vmlinux > > libbpf: fail

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-21 Thread Jiri Olsa
On Fri, Oct 18, 2019 at 08:04:44PM +, Yonghong Song wrote: SNIP > >> + FILE *f; > >> + > >> + if (stat(file, &st)) > >> + return btf; > >> + > >> + f = fopen(file, "rb"); > >> + if (!f) > >> + return btf; > >> + > >> + buf = malloc(st.st_size); > >> + if (!buf) > >> +

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-21 Thread Jiri Olsa
On Fri, Oct 18, 2019 at 04:48:25PM +, Andrii Nakryiko wrote: > On 10/18/19 3:34 AM, Jiri Olsa wrote: > > The bpftool interface stays the same, but now it's possible > > to run it over BTF raw data, like: > > Oh, great, I had similar patch laying around for a while, never got to > cleaning it

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-18 Thread Jakub Kicinski
On Fri, 18 Oct 2019 12:34:04 +0200, Jiri Olsa wrote: > The bpftool interface stays the same, but now it's possible > to run it over BTF raw data, like: > > $ bpftool btf dump file /sys/kernel/btf/vmlinux > libbpf: failed to get EHDR from /sys/kernel/btf/vmlinux > [1] INT '(anon)' size=4 bits

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-18 Thread Yonghong Song
On 10/18/19 9:48 AM, Andrii Nakryiko wrote: > On 10/18/19 3:34 AM, Jiri Olsa wrote: >> The bpftool interface stays the same, but now it's possible >> to run it over BTF raw data, like: > > Oh, great, I had similar patch laying around for a while, never got to > cleaning it up, though, so thanks

Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-18 Thread Andrii Nakryiko
On 10/18/19 3:34 AM, Jiri Olsa wrote: > The bpftool interface stays the same, but now it's possible > to run it over BTF raw data, like: Oh, great, I had similar patch laying around for a while, never got to cleaning it up, though, so thanks for picking this up! > >$ bpftool btf dump file /

[PATCH] bpftool: Try to read btf as raw data if elf read fails

2019-10-18 Thread Jiri Olsa
The bpftool interface stays the same, but now it's possible to run it over BTF raw data, like: $ bpftool btf dump file /sys/kernel/btf/vmlinux libbpf: failed to get EHDR from /sys/kernel/btf/vmlinux [1] INT '(anon)' size=4 bits_offset=0 nr_bits=32 encoding=(none) [2] INT 'long unsigned int