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>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-06-09 09:31:26 -03:00
parent 06cd9f00c6
commit 4eb4c03578
3 changed files with 4 additions and 3 deletions

View File

@ -257,7 +257,7 @@ static int btf_encoder__encode_tag(struct btf_encoder *encoder, struct cu *cu, s
case DW_TAG_array_type:
/* TODO: Encode one dimension at a time. */
encoder->need_index_type = true;
return btf__encode_array(btf, ref_type_id, encoder->array_index_id, array_type__nelems(tag));
return btf_encoder__add_array(encoder, ref_type_id, encoder->array_index_id, array_type__nelems(tag));
case DW_TAG_enumeration_type:
return btf__encode_enumeration_type(btf, cu, tag);
case DW_TAG_subroutine_type:

View File

@ -348,8 +348,9 @@ int32_t btf_encoder__add_ref_type(struct btf_encoder *encoder, uint16_t kind, ui
return id;
}
int32_t btf__encode_array(struct btf *btf, uint32_t type, uint32_t index_type, uint32_t nelems)
int32_t btf_encoder__add_array(struct btf_encoder *encoder, uint32_t type, uint32_t index_type, uint32_t nelems)
{
struct btf *btf = encoder->btf;
const struct btf_type *t;
const struct btf_array *array;
int32_t id;

View File

@ -26,7 +26,7 @@ int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const struct bas
int32_t btf_encoder__add_ref_type(struct btf_encoder *encoder, uint16_t kind, uint32_t type, const char *name, bool kind_flag);
int btf_encoder__add_field(struct btf_encoder *encoder, const char *name, uint32_t type, uint32_t bitfield_size, uint32_t bit_offset);
int32_t btf_encoder__add_struct(struct btf_encoder *encoder, uint8_t kind, const char *name, uint32_t size);
int32_t btf__encode_array(struct btf *btf, uint32_t type, uint32_t index_type, uint32_t nelems);
int32_t btf_encoder__add_array(struct btf_encoder *encoder, uint32_t type, uint32_t index_type, uint32_t nelems);
int32_t btf__encode_enum(struct btf *btf, const char *name, uint32_t size);
int btf__encode_enum_val(struct btf *btf, const char *name, int32_t value);
int32_t btf__encode_func_proto(struct btf *btf, struct cu *cu, struct ftype *ftype, uint32_t type_id_off);