Re: [PATCH v3 perf,bpf 08/11] perf, bpf: save btf information as headers to perf.data

Jiri Olsa
2019-02-17T23:06:46Z

On Fri, Feb 15, 2019 at 01:53:51PM -0800, Song Liu wrote:

SNIP

> +static int process_btf(struct feat_fd *ff, void *data __maybe_unused)
> +{
> + struct perf_env *env = &ff->ph->env;
> + u32 count, i;
> +
> + if (do_read_u32(ff, &count))
> + return -1;
> +
> + down_write(&env->bpf_progs.bpf_info_lock);
> +
> + for (i = 0; i < count; ++i) {
> + struct btf_node btf_node;
> + struct btf_node *node;
> +
> + if (__do_read(ff, &btf_node, sizeof(struct btf_node)))
> + return -1;
> +
> + node = malloc(sizeof(struct btf_node) + btf_node.data_size);
> + if (!node)
> + return -1;
> +
> + node->id = btf_node.id;
> + node->data_size = btf_node.data_size;
> +
> + if (__do_read(ff, node->data, btf_node.data_size)) {
> + free(node);
> + return -1;
> + }

hows endianity swap handled got struct btf_node and data in here?

thanks,
jirka