On Fri, Jan 14, 2022 at 9:09 PM Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > > On Wed, Jan 12, 2022 at 6:27 AM Mauricio Vásquez <mauricio@xxxxxxxxxx> wrote: > > > > This command is implemented under the "gen" command in bpftool and the > > syntax is the following: > > > > $ bpftool gen btf INPUT OUTPUT OBJECT(S) > > "gen btf" doesn't really convey that it's a minimized BTF for CO-RE, > maybe let's do something more verbose but also more precise, it's not > like this is going to be used by everyone multiple times a day, so > verboseness is not a bad thing here. Naming is hard, but something > like `bpftool gen min_core_btf` probably would give a bit better > pointer as to what this command is doing (minimal CO-RE BTF, right?) > I agree. `bpftool gen min_core_btf` seems just fine to us. > > > > INPUT can be either a single BTF file or a folder containing BTF files, > > when it's a folder, a BTF file is generated for each BTF file contained > > in this folder. OUTPUT is the file (or folder) where generated files are > > stored and OBJECT(S) is the list of bpf objects we want to generate the > > BTF file(s) for (each generated BTF file contains all the types needed > > by all the objects). > > > > Signed-off-by: Mauricio Vásquez <mauricio@xxxxxxxxxx> > > Signed-off-by: Rafael David Tinoco <rafael.tinoco@xxxxxxxxxxx> > > Signed-off-by: Lorenzo Fontana <lorenzo.fontana@xxxxxxxxxx> > > Signed-off-by: Leonardo Di Donato <leonardo.didonato@xxxxxxxxxx> > > --- > > tools/bpf/bpftool/gen.c | 117 ++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 117 insertions(+) > > > > [...] > > > + > > + while ((dir = readdir(d)) != NULL) { > > + if (dir->d_type != DT_REG) > > + continue; > > + > > + if (strncmp(dir->d_name + strlen(dir->d_name) - 4, ".btf", 4)) > > + continue; > > + > > + snprintf(src_btf_path, sizeof(src_btf_path), "%s/%s", input, dir->d_name); > > + snprintf(dst_btf_path, sizeof(dst_btf_path), "%s/%s", output, dir->d_name); > > + > > + printf("SBTF: %s\n", src_btf_path); > > What's SBTF? Is this part of bpftool "protocol" now? It should be > something a bit more meaningful... > These are almost debug leftovers. I updated them to be more meaningful. > > + > > + err = btfgen(src_btf_path, dst_btf_path, objs); > > + if (err) > > + goto out; > > + } > > + > > +out: > > + if (!err) > > + printf("STAT: done!\n"); > > similar, STAT? what's that? Do we need "done!" message in tool's output? > > > + free(objs); > > + closedir(d); > > + return err; > > +} > > + > > static const struct cmd cmds[] = { > > { "object", do_object }, > > { "skeleton", do_skeleton }, > > + { "btf", do_gen_btf}, > > { "help", do_help }, > > { 0 } > > }; > > -- > > 2.25.1 > >