[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzYdJ-hPHVehZriS_synLWtgad9wx_eoN6-JDBUUHFjfgQ@mail.gmail.com>
Date: Tue, 15 Oct 2019 09:22:35 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Andrii Nakryiko <andriin@...com>, Yonghong Song <yhs@...com>,
Martin KaFai Lau <kafai@...com>, Daniel Xu <dxu@...uu.xyz>
Subject: Re: [RFC] libbpf: Allow to emit all dependent definitions
On Tue, Oct 15, 2019 at 6:03 AM Jiri Olsa <jolsa@...nel.org> wrote:
>
> Currently the bpf dumper does not emit definitions
> of pointers to structs. It only emits forward type
> declarations.
>
> Having 2 structs like:
>
> struct B {
> int b;
> };
>
> struct A {
> struct B *ptr;
> };
>
> the call to btf_dump__dump_type(id = struct A) dumps:
>
> struct B;
> struct A {
> struct B *ptr;
> };
>
> It'd ease up bpftrace code if we could dump definitions
> of all dependent types, like:
>
> struct B {
> int b;
> };
> struct A {
> struct B *ptr;
> };
>
> So we could dereference all the pointers easily, instead
> of searching for each access member's type and dumping it
> separately.
>
> Adding struct btf_dump_opts::emit_all to do that.
>
Hey Jiri,
Yeah, Daniel Xu mentioned that this would be useful. I haven't thought
this through very well yet, but I suspect that this simple change
might not be enough to make this work. There are cases where you are
not yet allowed to emit definition and have to emit
forward-declaration first. I suggest trying to use this on vmlinux BTF
and see if resulting header files still compiles with both Clang and
GCC. Do you mind checking?
But also, as we learned over last few months, just adding extra field
to an opts struct is not backwards-compatible, so we'll need to add
new API and follow the pattern that we used for
bpf_object__open_{file,mem).
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
[...]
Powered by blists - more mailing lists