Commit Graph

1825 Commits

Author SHA1 Message Date
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
Arnaldo Carvalho de Melo
cccfeec3c7 btf_encoder: Make tag__encode_btf() its encode_tag() method
As we already need encoder->btfe->btf, so the number of args remain the
same and paves the way for other globals to be moved 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
65b3c598ab btf_encoder: Move 'has_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
Arnaldo Carvalho de Melo
a5c732e712 btf_encoder: Introduce 'struct btf_encoder' to have all the current globals
Start grouping all the state associated with the BTF encoder into a new
class, do it transparently to the user, pahole, until the last moment,
when it will call btf_encoder__new(), etc.

First step is just encapsulating the btf_elf instance, we'll adding the
globals one by one and at the end probably the btf_elf class will be
completely fagocitated. 8-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:30:18 -03:00
Arnaldo Carvalho de Melo
bd4e585d81 btf_encoder: Replace btfe with btf in tag__encode_btf()
Its all it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
de2676159d btf_encoder: Move encode_enumeration_type() from btf_elf to btf
As it is all that it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
80dec71c93 btf_encoder: Move encode_struct_type() from btf_elf to btf
As it is all that it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
6d7790a5d4 btf_encoder: Move add_datasec_type() from btf_elf to btf encode_datasec_type()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
12d340c321 btf_encoder: Move add_var_secinfo() from btf_elf to btf encode_var_secinfo()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
d90b38c1f3 btf_encoder: Move add_var_type() from btf_elf to btf encode_var_type()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
bce82c1a00 btf_encoder: Move add_func_proto() from btf_elf to btf encode_func_proto()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
188f25b741 btf_encoder: Move add_enum() from btf_elf to btf encode_enum()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
f82bd80a5c btf_encoder: Move add_struct() from btf_elf to btf encode_struct()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
1216aebd27 btf_encoder: Move add_array() from btf_elf to btf encode_array()
As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
a96c91261e btf_encoder: Move add_ref_type() from btf_elf to btf encode_ref_type()
As it is all that it needs. Rename from __add to __encode prefix for
consistency, as we have btf__add_array() and thus need to use a
different name for arrays, so do it here as well.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
a97ed8080a btf_encoder: Move add_member() from btf_elf to btf encode_member()
As it is all that it needs. Rename from __add to __encode prefix for
consistency, as we have btf__add_array() and thus need to use a
different name for arrays, so do it here as well.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
56e0c2d4cc btf_encoder: Move add_base_type() from btf_elf to btf encode_base_type()
As it is all that it needs. Rename from __add to __encode prefix for
consistency, as we have btf__add_array() and thus need to use a
different name for arrays, so do it here as well.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
adeeb9ebcf btf_encoder: Move add_float_type() from btf_elf to btf encode_float_type()
As it is all that it needs. Rename from __add to __encode prefix for
consistency, as we have btf__add_array() and thus need to use a
different name for arrays, so do it here as well.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
37d3b8a1ce btf_encoder: bpf__log_func_param() doesn't need the btfe arg
Ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
64d216f57e btf_encoder: Move log_member() from btf_elf to btf
As it is all that it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
20bb260428 btf_encoder: Move log_type() from btf_elf to btf
As it is all that it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
16d026ce5d btf_encoder: Move log_err() from btf_elf to btf
As it is all that it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
c5f594eaa9 btf_encoder: Remove 'elf' from btf_elf__int_encoding_str() name
Its not at all ELF specific, its just a BTF encoding.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
c81d11b8bb btf_elf: Remove base_btf member, used only in the constructor
And that is where its passed, so just use the constructor argument, no
need to have it in the newly created object.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
69f5fff50e btf_elf: No point in falling back to raw BTF in btf_new()
As now it is only called from the BTF _encoder_.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
3fcf804a7e btf_elf: No point in looking at the filename for /sys/kernel/btf in btf_elf__new()
As btf_elf__new() is only called from the BTF encoder, and that will not
be encoding from a BTF file, it'll be from a DWARF one.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
c9eb447502 libbtf: Ditch unused btf_elf__string() method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
a355a245fb libbtf: Remove unused btf_elf__load()
Now that bpf_loader uses libbpf directly, this can be ditched.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
3de65d433a btf_encoder: Move printable_name() from btfe to btf
Its all it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
7fb31d787d btf_loader: Stop using libbtf.h and the btf_elf class
Now we just use libbpf's API to do everything.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
e431c18b80 btf_loader: cu__fixup_btf_bitfields doesn'n need btfe parameter, ditch it
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
8c1919c10d btf_loader: class__fixup_btf_bitfields doesn'n need btfe parameter, ditch it
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
4d2ae0d904 btf_elf: Remove unused btfe->priv member
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
b54b74edfc btf_loader: Add a local 'btf' var to prep next patches
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
52bedef0fd btf_loader: Move load_sections() from btf_elf to btf
As it is all it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
ac3f2952a8 btf_loader: Move load_types() from btf_elf to btf
As it is all it needs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
1a33deae14 btf_loader: Move create_new_tag() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
8323cb33bc btf_loader: Move create_new_datasec() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
6fb41bbf8e btf_loader: Move create_new_variable() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
9122424dda btf_loader: Move create_new_typedef() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
dd3e9ab4a0 btf_loader: Move create_new_forward_decl() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
cca6b51d29 btf_loader: Move create_new_subroutine_type() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
ba1b77d01d btf_loader: Move create_new_enumeration() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
a58bc8300f btf_loader: Move create_new_union() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
367f5fe74c btf_loader: Move create_new_class() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
2460bead8a btf_loader: The create_members() function doesn't need the btfe arg
Not used at all.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo
1136795fec btf_loader: Move create_new_array() from btfe to cu
As all it needs is btfe->priv that is cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00