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

View File

@ -183,7 +183,7 @@ static int32_t btf_encoder__add_struct_type(struct btf_encoder *encoder, struct
* is required.
*/
name = dwarves__active_loader->strings__ptr(cu, pos->name);
if (btf__encode_member(encoder->btf, name, type_id_off + pos->tag.type, pos->bitfield_size, pos->bit_offset))
if (btf_encoder__add_field(encoder, name, type_id_off + pos->tag.type, pos->bitfield_size, pos->bit_offset))
return -1;
}

View File

@ -369,8 +369,9 @@ int32_t btf__encode_array(struct btf *btf, uint32_t type, uint32_t index_type, u
return id;
}
int btf__encode_member(struct btf *btf, const char *name, uint32_t type, uint32_t bitfield_size, uint32_t offset)
int btf_encoder__add_field(struct btf_encoder *encoder, const char *name, uint32_t type, uint32_t bitfield_size, uint32_t offset)
{
struct btf *btf = encoder->btf;
const struct btf_type *t;
const struct btf_member *m;
int err;

View File

@ -24,7 +24,7 @@ struct ftype;
int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const struct base_type *bt, const char *name);
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__encode_member(struct btf *btf, const char *name, uint32_t type, uint32_t bitfield_size, uint32_t bit_offset);
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__encode_struct(struct btf *btf, 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__encode_enum(struct btf *btf, const char *name, uint32_t size);