On Tue, Oct 15, 2019 at 6:03 AM Jiri Olsa <jolsa@xxxxxxxxxx> 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@xxxxxxxxxx> > --- [...]