Re: [PATCH] perf tools: fix endian conversion reading event attr from header

David Ahern
2011-07-15T16:02:47Z

On 07/15/2011 09:47 AM, Frederic Weisbecker wrote:
>> - if (perf_header__getbuffer64(header, fd, &f_attr, sizeof(f_attr)))
>> + if (readn(fd, &f_attr, sizeof(f_attr)) <= 0)
>> goto out_errno;
>>
>> + if (header->needs_swap) {
>> + f_attr.attr.type = bswap_32(f_attr.attr.type);
>> + f_attr.attr.size = bswap_32(f_attr.attr.size);
>> + mem_bswap_64(&f_attr.attr.config,
>> + sizeof(struct perf_event_attr) - 8);
>> + }
>> +
>
> Good catch!

A long, painful discovery

> But would be nice to also handle the wakeup_events and bp_type fields.
>

I did not think those values were used in userspace, so did not touch
them. But then your inquiry pushed me into cscope and I found the
perf_event__attr_swap() function. I'll redo the patch leveraging the
swapping done there.

David