lkml.org 
[lkml]   [2015]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tools: Fix a problem when opening old perf.data with different byte order
On Wed, Jun 17, 2015 at 03:40:42AM +0000, Wang Nan wrote:
> Following error occurs when trying to use 'perf report' on x86_64 to
> cross analysis a perf.data generated by an old perf on a big-endian
> machine:
>

SNIP

> - attr->branch_sample_type = bswap_64(attr->branch_sample_type);
> - attr->sample_regs_user = bswap_64(attr->sample_regs_user);
> - attr->sample_stack_user = bswap_32(attr->sample_stack_user);
> - attr->aux_watermark = bswap_32(attr->aux_watermark);
> -
> - swap_bitfield((u8 *) (&attr->read_format + 1), sizeof(u64));
> +#define bswap_safe(f) \
> + (attr->size > offsetof(struct perf_event_attr, f))
> +#define bswap_field(f, sz) \
> +do { \
> + if (bswap_safe(f)) \
> + attr->f = bswap_##sz(attr->f); \
> +} while(0)
> +#define bswap_field_32(f) bswap_field(f, 32)
> +#define bswap_field_64(f) bswap_field(f, 64)

all macros are function specific, please undef them
at the bottom

> +
> + bswap_field_64(config);
> + bswap_field_64(sample_period);
> + bswap_field_64(sample_type);
> + bswap_field_64(read_format);
> + bswap_field_32(wakeup_events);
> + bswap_field_32(bp_type);
> + bswap_field_64(bp_addr);
> + bswap_field_64(bp_len);
> + bswap_field_64(branch_sample_type);
> + bswap_field_64(sample_regs_user);
> + bswap_field_32(sample_stack_user);
> + bswap_field_32(aux_watermark);
> +
> + if (bswap_safe(read_format))

should this check for 'read_format + 1' ?

jirka

> + swap_bitfield((u8 *) (&attr->read_format + 1),
> + sizeof(u64));


> }
>
> static void perf_event__hdr_attr_swap(union perf_event *event,
> --
> 1.8.3.4
>


\
 
 \ /
  Last update: 2015-06-17 11:21    [W:0.469 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site