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

From: Song Liu
Date: Tue Feb 19 2019 - 00:48:55 EST




> On Feb 17, 2019, at 3:06 PM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> 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

I thought about endianity at some point, but forgot about it. Let
me see how to fix it.

Thanks,
Song