Commit Graph

1871 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 729da7613b btf_encoder: Adopt btf__log_member() and use encoder->verbose
This will eventually allow us to remove one more global variable,
btf_encoder__verbose.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:46:43 -03:00
Arnaldo Carvalho de Melo be75b76b6b btf_encoder: Adopt btf__log_type() and use encoder->verbose
This will eventually allow us to remove one more global variable,
btf_encoder__verbose.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:46:34 -03:00
Arnaldo Carvalho de Melo 9f19e96001 btf_encoder: No need to pass encoder->percpu_secinfo to btf_encoder__add_datasec()
As it receives the encoder and can get that field from it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:46:30 -03:00
Arnaldo Carvalho de Melo 869c177f8e btf_encoder: Make btf_encoder__add_var_secinfo() receive a btf_encoder pointer
For consistency.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:21:07 -03:00
Arnaldo Carvalho de Melo f0e8cd68f5 btf_encoder: Adopt btf__encode_var_secinfo() as btf_encoder__add_var_secinfo()
So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:18:53 -03:00
Arnaldo Carvalho de Melo cc646d93d1 btf_encoder: Adopt btf__encode_datasec_type() as btf_encoder__add_datasec()
As it is just prep work to call libbpf's btf__add_datasec() for
variables using pahole's data structures populated from another format,
normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:14:47 -03:00
Arnaldo Carvalho de Melo b0f71fabde btf_encoder: Adopt btf__encode_var_type() as btf_encoder__add_var()
As it is just prep work to call libbpf's btf__add_var for a variable
using pahole's data structures populated from another format, normally
DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:12:26 -03:00
Arnaldo Carvalho de Melo 1aece1e7e6 btf_encoder: Adopt btf__encode_enum_val() as btf_encoder__add_enum_val()
As it is just prep work to call libbpf's btf__add_enum_val for an
enumeration entry using pahole's data structures populated from another
format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:10:35 -03:00
Arnaldo Carvalho de Melo 4371b3cd5b btf_encoder: Adopt btf__encode_enum() as btf_encoder__add_enum()
As it is just prep work to call libbpf's btf__add_enum for an
enumeration using pahole's data structures populated from another
format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:08:45 -03:00
Arnaldo Carvalho de Melo b536947512 btf_encoder: Adopt btf__encode_enumeration_type() as btf_encoder__add_enum_type()
As it is just prep work to call libbpf's btf__add_enum*() APIs for an
enumeration and its entries using pahole's data structures populated
from another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:06:43 -03:00
Arnaldo Carvalho de Melo 1bc29591ec btf_encoder: Adopt btf__encode_func_proto_param() as btf_encoder__add_func_param()
As it is just prep work to call libbpf's btf__add_func_param() for an
argument in a function prototype using pahole's data structures
populated from another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:03:55 -03:00
Arnaldo Carvalho de Melo 393febe592 btf_encoder: Adopt btf__encode_func_proto() as btf_encoder__add_func_proto()
As it is just prep work to call libbpf's btf__add_func_proto() for a
function prototype using pahole's data structures populated from another
format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 10:01:22 -03:00
Arnaldo Carvalho de Melo 4eb4c03578 btf_encoder: Adopt btf__encode_array() as btf_encoder__add_array()
As it is just prep work to call libbpf's btf__add_array() for an array
using pahole's data structures populated from another format, normally
DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:59:20 -03:00
Arnaldo Carvalho de Melo 06cd9f00c6 btf_encoder: Adopt btf__encode_struct() as btf_encoder__add_struct()
As it is just prep work to call libbpf's btf__add_struct() for a
struct/union/class using pahole's data structures populated from another
format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:57:15 -03:00
Arnaldo Carvalho de Melo 0b29d5a65c btf_encoder: Adopt btf__encode_member() as btf_encoder__add_field()
As it is just prep work to call libbpf's btf__add_field() for a
struct/union/class member using pahole's data structures populated from
another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:53:45 -03:00
Arnaldo Carvalho de Melo 3e2a1f7ddc btf_encoder: Adopt btf__encode_struct_type() as btf_encoder__add_struct_type()
As it is just prep work to call the various libbpf's btf__add*() for
structs/unions and its members using pahole's data structures populated
from another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:46:22 -03:00
Arnaldo Carvalho de Melo 2c7a2f270e btf_encoder: Adopt btf__encode_ref_type() as btf_encoder__add_ref_type()
As it is just prep work to call the various libbpf's btf__add*() for
types that reference other types (volatile, const, pointers, etc) using
pahole's data structures populated from another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:42:20 -03:00
Arnaldo Carvalho de Melo 07d4ec9cef btf_encoder: Adopt btf__encode_float_type() as btf_encoder__add_float()
As it is just prep work to call libbpf's btf__add_float() using
pahole's data structures populated from another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:39:18 -03:00
Arnaldo Carvalho de Melo 68ed8af859 btf_encoder: Adopt btf__encode_base_type() as btf_encoder__add_base_type()
As it is just prep work to call libbpf's btf__add_base_type() using
pahole's data structures populated from another format, normally DWARF.

So that we can eventually ditch the btf_encoder__verbose and
btf_gen_float globals, making them members of 'struct btf_encoder'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:31:26 -03:00
Arnaldo Carvalho de Melo 14ab2e0361 libbtf: Ditch unused btf_elf__verbose_log() macro
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:21:43 -03:00
Arnaldo Carvalho de Melo 539c94fee9 libbtf: Ditch btf_elf class, unused
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:21:42 -03:00
Arnaldo Carvalho de Melo 282a8a2187 btf_encoder: Use 'struct btf' directly, stop using btf_elf
Now that btf_elf is only crating the 'struct btf' instance, do it
directly.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:20:23 -03:00
Arnaldo Carvalho de Melo dd0b01f568 libbtf: Remove unused ELF fields and calls from btf_elf
The continuous eroding of libbtf and the move to use libbpf APIs made
possible to ditch these aspects from libbtf.c and btf_elf, that is near
terminal death :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-09 09:10:36 -03:00
Arnaldo Carvalho de Melo a0c5f49b0c btf_encoder: Phagocytize percpu_secinfo from btf_elf
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 17:54:35 -03:00
Arnaldo Carvalho de Melo c288e29d06 pahole: Rename 'encoder' to 'btf_encoder' as we support multiple formats
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:40:14 -03:00
Arnaldo Carvalho de Melo 46a3e3a87a btf_encoder: Move the global btf_encoder to its users, like pahole
Tools should instantiate it using btf_encoder__new(), etc, ditch the
library global.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:38:48 -03:00
Arnaldo Carvalho de Melo fa849010b4 btf_encoder: Adopt the cu__encode_btf() method, as btf_encoder__encode_cu()
This should be the last user of the global btf_encoder variable, time to
ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:35:30 -03:00
Arnaldo Carvalho de Melo 3be437c5e7 btf_encoder: Set btf_encoder__verbose in just one place, its users
E.g.: pahole.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:32:55 -03:00
Arnaldo Carvalho de Melo e1e787af44 btf_encoder: Move btf_elf__verbose var to btf_encoder class
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:29:55 -03:00
Arnaldo Carvalho de Melo 66f4054252 btf_encoder: Adopt btf_elf__force, its only used in btf_encoder methods
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:20:11 -03:00
Arnaldo Carvalho de Melo 5e1207754e pahole: Adopt btf_encoder object instantiation from btf_encoder
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 15:03:05 -03:00
Arnaldo Carvalho de Melo 0208952e8f btf_encoder: Move the function encode() to be a btf_encoder method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 14:44:19 -03:00
Arnaldo Carvalho de Melo bcc5f95364 btf_encoder: Temporarily expose the 'encoder' variable
To move creation to pahole.c, i.e. outside the library, to the user,
then move the other methods still using the global variable.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 14:40:17 -03:00
Arnaldo Carvalho de Melo e27be59f10 btf_encoder: Move 'filename' member from btf_elf to btf_encoder
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 10:10:41 -03:00
Arnaldo Carvalho de Melo da9d70a16f btfdiff: Support diffing DWARF vs detached BTF
I.e.:

  $ rm -f vmlinux.btf ; pahole -j vmlinux.btf vmlinux && btfdiff vmlinux vmlinux.btf

Is much more robust in making sure we really generated new BTF from
the DWARF in a ELF file and that the detached BTF produces the same
output as the original DWARF.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-08 10:08:22 -03:00
Arnaldo Carvalho de Melo 6bc135c8f4 btf_encoder: No need for calling btf_encoder__encode() from cu__encode_btf()
For a vmlinux, the usual case, btf_encoder__encode() ends up being
called just from pahole, after processing all CUs, this looks like a
leftover from when Andrii made it support multiple CUs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:46:18 -03:00
Arnaldo Carvalho de Melo 48a0fa2ef7 btf_encoder: Move btf_elf based encode_in_elf and write_elf methods to btf_encoder
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:38:54 -03:00
Arnaldo Carvalho de Melo cc8eae604d btf_encoder: Move collect_symbols() call to btf_encoder constructor
As we'll call the constructor from users, not from inside the a
btf_constructor method updating a global variable.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo 96e59c5568 btf_encoder: Remove needless hash.h include, not used anymore
In 2e719cca66 ("btf_encoder: revamp how per-CPU variables are encoded")
hash.h stopped being used, remove the hash.h include.

Cc: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo 92f8852d8d btf_encoder: Move global elf_functions table to the btf_encoder class
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo aa48ed55a7 btf_encoder: Move ELF's ehdr from btf_elf to btf_encoder
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo b3701a8346 btf_encoder: Move 'symtab' from btf_elf to btf_encoder
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo be8dac4869 btf_encoder: Move percpu members from btf_elf to btf_encoder
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo 7f70877b19 btf_encoder: Add a 'verbose' member for encoder specific logging requests
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo ef8a48b3bc btf_encoder: Move 'array_index_id' global variable to 'struct btf_encoder'
And this reduces the btf_encoder__encode_tag() signature, since we don't
have to pass this variable, as it is now in the 'encoder' parameter.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo f3e6edffd7 btf_encoder: Move percpu vars global variables to btf_encoder class
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo 14053c490b btf_encoder: Adopt collect_function() as a btf_encoder method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo 049675f4a5 btf_encoder: Adopt collect_per_cpu_var() as a btf_encoder method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo 21b5e9b368 btf_encoder: Adopt collect_symbol() as a btf_encoder method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00
Arnaldo Carvalho de Melo e40bc12ddf btf_encoder: Move 'need_index_type' global variable to 'struct btf_encoder'
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:20 -03:00